Don't use console if Serial port is disabled

This commit is contained in:
fvanroie 2023-02-08 17:03:01 +01:00
parent 6745c38773
commit 1b9135e355
3 changed files with 10 additions and 6 deletions

View File

@ -140,7 +140,7 @@ void debugLvglLogEvent(lv_log_level_t level, const char* file, uint32_t line, co
IRAM_ATTR void debugLoop(void);
void debugEverySecond(void);
void debugStart(void);
void debugStartSerial(void);
bool debugStartSerial(void);
void debugStop(void);
void debugPrintHaspHeader(Print* output);
void debugPrintTag(uint8_t tag, Print* _logOutput);

View File

@ -16,7 +16,7 @@
#include "hasp_conf.h"
#include "ConsoleInput.h"
#include "lvgl.h"
//#include "time.h"
// #include "time.h"
#include <StreamUtils.h>
#if defined(ARDUINO_ARCH_ESP8266)
@ -373,15 +373,15 @@ void debugPrintSuffix(uint8_t tag, int level, Print* _logOutput)
}
// Start Serial Port at correct
void debugStartSerial()
bool debugStartSerial()
{
if(debugSerialBaud < 0) {
LOG_WARNING(TAG_DEBG, F(D_SERVICE_DISABLED " (%u Bps)"), debugSerialBaud);
// return;
return false;
}
uint32_t baudrate = debugSerialBaud;
if(baudrate < 9600) baudrate = SERIAL_SPEED;
if(baudrate < 9600) baudrate = SERIAL_SPEED; // 9600 baud minimum
#if defined(STM32F4xx) || defined(STM32F7xx)
#ifndef STM32_SERIAL1 // Define what Serial port to use for log output
@ -400,6 +400,7 @@ void debugStartSerial()
LOG_INFO(TAG_DEBG, F(D_SERVICE_STARTED " @ %u bps"), debugSerialBaud);
LOG_INFO(TAG_DEBG, F(D_INFO_ENVIRONMENT ": " PIOENV));
return true;
}
// Do NOT call Log function before debugSetup is called

View File

@ -107,7 +107,10 @@ void consoleStart()
LOG_TRACE(TAG_MSGR, F(D_SERVICE_STARTING));
console = new ConsoleInput(bufferedSerialClient, HASP_CONSOLE_BUFFER);
if(console) {
debugStartSerial(); // open Serial port
if(!debugStartSerial()) { // failed to open Serial port
LOG_INFO(TAG_CONS, F(D_SERVICE_DISABLED));
return;
}
/* Now register logger for serial */
Log.registerOutput(0, bufferedSerialClient, HASP_LOG_LEVEL, true);