From bb2b7a8e62da2d8ecc8ff191d434f4bb666a4188 Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Mon, 2 Nov 2020 11:32:46 +0100 Subject: [PATCH] Fixes #394 Finally --- esp3d/configuration.h | 3 ++- esp3d/src/core/debug_esp3d.cpp | 17 +++++++++++++++++ esp3d/src/core/debug_esp3d.h | 5 ++++- esp3d/src/include/pins.h | 7 +++++++ esp3d/src/include/version.h | 2 +- esp3d/src/modules/serial/serial_service.cpp | 2 +- 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/esp3d/configuration.h b/esp3d/configuration.h index 80ace657..9b0bd3e3 100644 --- a/esp3d/configuration.h +++ b/esp3d/configuration.h @@ -242,9 +242,10 @@ //DEBUG_OUTPUT_SERIAL2 3 //DEBUG_OUTPUT_TELNET 4 //DEBUG_OUTPUT_WEBSOCKET 5 -//#define ESP_DEBUG_FEATURE DEBUG_OUTPUT_SERIAL0 +//#define ESP_DEBUG_FEATURE DEBUG_OUTPUT_SERIAL2 #ifdef ESP_DEBUG_FEATURE +#define DEBUG_BAUDRATE 115200 #define DEBUG_ESP3D_OUTPUT_PORT 8000 #endif //ESP_DEBUG_FEATURE diff --git a/esp3d/src/core/debug_esp3d.cpp b/esp3d/src/core/debug_esp3d.cpp index f9e8dc30..bf4d52d6 100644 --- a/esp3d/src/core/debug_esp3d.cpp +++ b/esp3d/src/core/debug_esp3d.cpp @@ -21,6 +21,10 @@ #include "../include/esp3d_config.h" #if defined(ESP_DEBUG_FEATURE) +#ifndef DEBUG_BAUDRATE +#define DEBUG_BAUDRATE 115200 +#ndif //~DEBUG_BAUDRATE + #if defined(ARDUINO_ARCH_ESP8266) const char * pathToFileName(const char * path) { @@ -38,6 +42,19 @@ const char * pathToFileName(const char * path) } #endif //ARDUINO_ARCH_ESP8266 +void initDebug() +{ +#ifdef ARDUINO_ARCH_ESP8266 + DEBUG_OUTPUT_SERIAL.begin(DEBUG_BAUDRATE, SERIAL_8N1, SERIAL_FULL, (ESP_DEBUG_TX_PIN == -1)?1:ESP_DEBUG_TX_PIN); +#if ESP_DEBUG_RX_PIN != -1 + DEBUG_OUTPUT_SERIAL.pins((ESP_DEBUG_TX_PIN == -1)?1:ESP_DEBUG_TX_PIN, ESP_DEBUG_RX_PIN) +#endif //ESP_DEBUG_RX_PIN != -1 +#endif //ARDUINO_ARCH_ESP8266 +#if defined(ARDUINO_ARCH_ESP32) + DEBUG_OUTPUT_SERIAL.begin (DEBUG_BAUDRATE, SERIAL_8N1, ESP_DEBUG_RX_PIN, ESP_DEBUG_TX_PIN); +#endif //ARDUINO_ARCH_ESP32 +} + //Telnet #if ESP_DEBUG_FEATURE == DEBUG_OUTPUT_TELNET Telnet_Server telnet_debug; diff --git a/esp3d/src/core/debug_esp3d.h b/esp3d/src/core/debug_esp3d.h index 0c5cdcb5..ee9e85b6 100644 --- a/esp3d/src/core/debug_esp3d.h +++ b/esp3d/src/core/debug_esp3d.h @@ -37,6 +37,8 @@ extern const char * pathToFileName(const char * path); //Serial #if (ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL0) || (ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL1) || (ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL2) +extern void initDebug(); + #if ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL0 #define DEBUG_OUTPUT_SERIAL Serial #endif //DEBUG_OUTPUT_SERIAL0 @@ -46,8 +48,9 @@ extern const char * pathToFileName(const char * path); #if ESP_DEBUG_FEATURE == DEBUG_OUTPUT_SERIAL2 #define DEBUG_OUTPUT_SERIAL Serial2 #endif //DEBUG_OUTPUT_SERIAL2 + #undef DEBUG_ESP3D_INIT -#define DEBUG_ESP3D_INIT DEBUG_OUTPUT_SERIAL.begin(115200); +#define DEBUG_ESP3D_INIT initDebug(); #define log_esp3d(format, ...) DEBUG_OUTPUT_SERIAL.printf("[ESP3D][%s:%u] %s(): " format "\r\n", pathToFileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__) #define log_esp3dS(format, ...) DEBUG_OUTPUT_SERIAL.printf(format "\r\n", ##__VA_ARGS__) #endif //DEBUG_OUTPUT_SERIAL0 || DEBUG_OUTPUT_SERIAL1 || DEBUG_OUTPUT_SERIAL2 diff --git a/esp3d/src/include/pins.h b/esp3d/src/include/pins.h index 3076e276..4aa80aa9 100644 --- a/esp3d/src/include/pins.h +++ b/esp3d/src/include/pins.h @@ -29,6 +29,13 @@ #define ESP_TX_PIN -1 #endif //~ESP_TX_PIN +#ifndef ESP_DEBUG_RX_PIN +#define ESP_DEBUG_RX_PIN -1 +#endif //~ESP_DEBUG_RX_PIN +#ifndef ESP_DEBUG_TX_PIN +#define ESP_DEBUG_TX_PIN -1 +#endif //~ESP_DEBUG_TX_PIN + //I2C Pins #ifndef ESP_SDA_PIN #define ESP_SDA_PIN SDA diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index 01a5ebcd..2d96a543 100644 --- a/esp3d/src/include/version.h +++ b/esp3d/src/include/version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H //version and sources location -#define FW_VERSION "3.0.0.a67" +#define FW_VERSION "3.0.0.a68" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H diff --git a/esp3d/src/modules/serial/serial_service.cpp b/esp3d/src/modules/serial/serial_service.cpp index bd769332..e3d7c010 100644 --- a/esp3d/src/modules/serial/serial_service.cpp +++ b/esp3d/src/modules/serial/serial_service.cpp @@ -90,7 +90,7 @@ bool SerialService::begin() } ESP3D_SERIAL.setRxBufferSize (SERIAL_RX_BUFFER_SIZE); #ifdef ARDUINO_ARCH_ESP8266 - ESP3D_SERIAL.begin(br, SERIAL_8N1, SERIAL_FULL, (ESP_TX_PIN == -1)?1:ESP_TX_PIN); + ESP3D_SERIAL.begin(br, ESP_SERIAL_PARAM, SERIAL_FULL, (ESP_TX_PIN == -1)?1:ESP_TX_PIN); #if ESP_RX_PIN != -1 ESP3D_SERIAL.pins((ESP_TX_PIN == -1)?1:ESP_TX_PIN, ESP_RX_PIN) #endif //ESP_RX_PIN != -1