From 17615adca5cac1b50cb49dffac5f47573547248c Mon Sep 17 00:00:00 2001 From: andreas Date: Wed, 30 Aug 2023 20:20:28 +0200 Subject: [PATCH] cleanup unused code, make fallback_serial working again --- lib/channel/GwChannelList.h | 5 +++-- lib/exampletask/GwExampleTask.h | 1 + lib/exampletask/platformio.ini | 1 - lib/log/GWLog.cpp | 3 ++- src/main.cpp | 14 ++------------ 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/channel/GwChannelList.h b/lib/channel/GwChannelList.h index cbef1d4..1cca126 100644 --- a/lib/channel/GwChannelList.h +++ b/lib/channel/GwChannelList.h @@ -12,8 +12,9 @@ #define N2K_CHANNEL_ID 0 #define USB_CHANNEL_ID 1 #define SERIAL1_CHANNEL_ID 2 -#define TCP_CLIENT_CHANNEL_ID 3 -#define MIN_TCP_CHANNEL_ID 4 +#define SERIAL2_CHANNEL_ID 3 +#define TCP_CLIENT_CHANNEL_ID 4 +#define MIN_TCP_CHANNEL_ID 5 #define MIN_USER_TASK 200 class GwSocketServer; diff --git a/lib/exampletask/GwExampleTask.h b/lib/exampletask/GwExampleTask.h index 5dbb5b6..1ff2219 100644 --- a/lib/exampletask/GwExampleTask.h +++ b/lib/exampletask/GwExampleTask.h @@ -22,6 +22,7 @@ #define GWLED_PIN GPIO_NUM_27 //brightness 0...255 #define GWLED_BRIGHTNESS 64 +#define USBSerial Serial void exampleTask(GwApi *param); void exampleInit(GwApi *param); diff --git a/lib/exampletask/platformio.ini b/lib/exampletask/platformio.ini index b2cd394..096a7cd 100644 --- a/lib/exampletask/platformio.ini +++ b/lib/exampletask/platformio.ini @@ -7,7 +7,6 @@ board = m5stack-atom lib_deps = ${env.lib_deps} - own_lib build_flags= -D BOARD_TEST ${env.build_flags} diff --git a/lib/log/GWLog.cpp b/lib/log/GWLog.cpp index 936e876..65d8236 100644 --- a/lib/log/GWLog.cpp +++ b/lib/log/GWLog.cpp @@ -1,10 +1,11 @@ #include "GwLog.h" +#include "GwHardware.h" class DefaultLogWriter: public GwLogWriter{ public: virtual ~DefaultLogWriter(){}; virtual void write(const char *data){ - Serial.print(data); + USBSerial.print(data); } }; diff --git a/src/main.cpp b/src/main.cpp index c884a62..5521501 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,6 @@ #include "GwAppInfo.h" // #define GW_MESSAGE_DEBUG_ENABLED //#define FALLBACK_SERIAL -//#define CAN_ESP_DEBUG const unsigned long HEAP_REPORT_TIME=2000; //set to 0 to disable heap reporting #include #include "GwApi.h" @@ -66,15 +65,6 @@ const unsigned long HEAP_REPORT_TIME=2000; //set to 0 to disable heap reporting #include "GwChannel.h" #include "GwChannelList.h" #include "GwTimer.h" -#ifdef FALLBACK_SERIAL - #ifdef CAN_ESP_DEBUG - #define CDBS &Serial - #else - #define CDBS NULL - #endif -#else - #define CDBS NULL -#endif #define MAX_NMEA2000_MESSAGE_SEASMART_SIZE 500 @@ -709,8 +699,8 @@ void setup() { #ifdef FALLBACK_SERIAL fallbackSerial=true; //falling back to old style serial for logging - Serial.begin(115200); - Serial.printf("fallback serial enabled\n"); + USBSerial.begin(115200); + USBSerial.printf("fallback serial enabled\n"); logger.prefix="FALLBACK:"; #endif userCodeHandler.startInitTasks(MIN_USER_TASK);