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); IRAM_ATTR void debugLoop(void);
void debugEverySecond(void); void debugEverySecond(void);
void debugStart(void); void debugStart(void);
void debugStartSerial(void); bool debugStartSerial(void);
void debugStop(void); void debugStop(void);
void debugPrintHaspHeader(Print* output); void debugPrintHaspHeader(Print* output);
void debugPrintTag(uint8_t tag, Print* _logOutput); void debugPrintTag(uint8_t tag, Print* _logOutput);

View File

@ -373,15 +373,15 @@ void debugPrintSuffix(uint8_t tag, int level, Print* _logOutput)
} }
// Start Serial Port at correct // Start Serial Port at correct
void debugStartSerial() bool debugStartSerial()
{ {
if(debugSerialBaud < 0) { if(debugSerialBaud < 0) {
LOG_WARNING(TAG_DEBG, F(D_SERVICE_DISABLED " (%u Bps)"), debugSerialBaud); LOG_WARNING(TAG_DEBG, F(D_SERVICE_DISABLED " (%u Bps)"), debugSerialBaud);
// return; return false;
} }
uint32_t baudrate = debugSerialBaud; uint32_t baudrate = debugSerialBaud;
if(baudrate < 9600) baudrate = SERIAL_SPEED; if(baudrate < 9600) baudrate = SERIAL_SPEED; // 9600 baud minimum
#if defined(STM32F4xx) || defined(STM32F7xx) #if defined(STM32F4xx) || defined(STM32F7xx)
#ifndef STM32_SERIAL1 // Define what Serial port to use for log output #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_SERVICE_STARTED " @ %u bps"), debugSerialBaud);
LOG_INFO(TAG_DEBG, F(D_INFO_ENVIRONMENT ": " PIOENV)); LOG_INFO(TAG_DEBG, F(D_INFO_ENVIRONMENT ": " PIOENV));
return true;
} }
// Do NOT call Log function before debugSetup is called // 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)); LOG_TRACE(TAG_MSGR, F(D_SERVICE_STARTING));
console = new ConsoleInput(bufferedSerialClient, HASP_CONSOLE_BUFFER); console = new ConsoleInput(bufferedSerialClient, HASP_CONSOLE_BUFFER);
if(console) { 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 */ /* Now register logger for serial */
Log.registerOutput(0, bufferedSerialClient, HASP_LOG_LEVEL, true); Log.registerOutput(0, bufferedSerialClient, HASP_LOG_LEVEL, true);