Add HASP_SERIAL

This commit is contained in:
fvanroie 2022-10-17 18:41:14 +02:00
parent 7e1e04ec71
commit 22d4360a2f
4 changed files with 21 additions and 19 deletions

View File

@ -87,7 +87,7 @@ static void debugPrintTimestamp(int level, Print* _logOutput)
static inline void debug_flush()
{
#if defined(ARDUINO)
Serial.flush();
HASP_SERIAL.flush();
#endif
#if defined(WINDOWS) || defined(POSIX)

View File

@ -202,6 +202,8 @@ enum {
TAG_CUSTOM = 99
};
#define HASP_SERIAL Serial
//#define TERM_COLOR_Black "\u001b[30m"
#define TERM_COLOR_GRAY "\e[37m"
#define TERM_COLOR_RED "\e[91m"

View File

@ -253,13 +253,13 @@ size_t debugHistoryIndex(size_t num)
void debugShowHistory()
{
size_t num = debugHistorycount();
Serial.println();
HASP_SERIAL.println();
for(int i = 0; i <= num; i++) {
Serial.print("[");
Serial.print(i);
Serial.print("] ");
HASP_SERIAL.print("[");
HASP_SERIAL.print(i);
HASP_SERIAL.print("] ");
size_t pos = debugHistoryIndex(i);
if(pos < sizeof(serialInputBuffer)) Serial.println((char *)(serialInputBuffer + pos));
if(pos < sizeof(serialInputBuffer)) HASP_SERIAL.println((char *)(serialInputBuffer + pos));
}
}
@ -375,18 +375,18 @@ void debugStartSerial()
#if defined(STM32F4xx) || defined(STM32F7xx)
#ifndef STM32_SERIAL1 // Define what Serial port to use for log output
Serial.setRx(PA3); // User Serial2
Serial.setTx(PA2);
HASP_SERIAL.setRx(PA3); // User Serial2
HASP_SERIAL.setTx(PA2);
#endif
#endif
Serial.begin(baudrate); /* prepare for possible serial debug */
HASP_SERIAL.begin(baudrate); /* prepare for possible serial debug */
delay(10);
Log.registerOutput(0, &Serial, HASP_LOG_LEVEL, true); // LOG_LEVEL_VERBOSE
Serial.println();
HASP_SERIAL.println();
debugPrintHaspHeader(&Serial);
Serial.flush();
HASP_SERIAL.flush();
LOG_INFO(TAG_DEBG, F(D_SERVICE_STARTED " @ %u bps"), debugSerialBaud);
LOG_INFO(TAG_DEBG, F(D_INFO_ENVIRONMENT ": " PIOENV));
@ -424,12 +424,12 @@ void printLocalTime()
timeinfo = localtime(&rawtime);
strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S.", timeinfo);
Serial.println(buffer);
HASP_SERIAL.println(buffer);
// struct tm timeinfo;
// time_t now = time(nullptr);
// Serial-.print(ctime(&now));
// Serial.print(&timeinfo, " %d %B %Y %H:%M:%S ");
// HASP_SERIAL.print(&timeinfo, " %d %B %Y %H:%M:%S ");
#if LWIP_VERSION_MAJOR > 1
@ -438,13 +438,13 @@ void printLocalTime()
IPAddress sntp = *sntp_getserver(i);
const char* name = sntp_getservername(i);
if(sntp.isSet()) {
Serial.printf("sntp%d: ", i);
HASP_SERIAL.printf("sntp%d: ", i);
if(name) {
Serial.printf("%s (%s) ", name, sntp.toString().c_str());
HASP_SERIAL.printf("%s (%s) ", name, sntp.toString().c_str());
} else {
Serial.printf("%s ", sntp.toString().c_str());
HASP_SERIAL.printf("%s ", sntp.toString().c_str());
}
Serial.printf("IPv6: %s Reachability: %o\n", sntp.isV6() ? D_YES : D_NO, sntp_getreachability(i));
HASP_SERIAL.printf("IPv6: %s Reachability: %o\n", sntp.isV6() ? D_YES : D_NO, sntp_getreachability(i));
}
}
#endif

View File

@ -19,7 +19,7 @@ extern hasp_http_config_t http_config;
#endif
// Create a new Stream that buffers all writes to serialClient
HardwareSerial* bufferedSerialClient = &Serial;
HardwareSerial* bufferedSerialClient = (HardwareSerial*)&Serial;
uint8_t consoleLoginState = CONSOLE_UNAUTHENTICATED;
uint16_t serialPort = 0;
@ -129,7 +129,7 @@ void consoleStop()
{
console_logoff();
Log.unregisterOutput(0); // serialClient
Serial.end();
HASP_SERIAL.end();
delete console;
console = NULL;