From c09d3c65ebf09d36ca5ccfb723c9fd670db949c3 Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Sat, 16 Dec 2023 16:39:21 +0800 Subject: [PATCH] Fix compilation issues --- src/core/esp3d_settings.cpp | 4 +++ src/esp3dlib.cpp | 28 ++++++++++++------- src/esp3dlib_config.h | 11 ++++++-- src/include/esp3d_version.h | 2 +- src/modules/filesystem/sd/sd_sdfat2_esp32.cpp | 24 ++++++++-------- src/modules/http/handlers/handle-SD-files.cpp | 11 +++++--- src/modules/serial2socket/serial2socket.cpp | 2 +- src/modules/serial2socket/serial2socket.h | 9 ++++-- 8 files changed, 58 insertions(+), 33 deletions(-) diff --git a/src/core/esp3d_settings.cpp b/src/core/esp3d_settings.cpp index e0d6097..09691b7 100644 --- a/src/core/esp3d_settings.cpp +++ b/src/core/esp3d_settings.cpp @@ -19,7 +19,9 @@ */ #include "../include/esp3d_config.h" +#ifndef STRINGIFY #define STRINGIFY(x) #x +#endif // STRINGIFY #define STRING(x) STRINGIFY(x) #if defined(ESP_SAVE_SETTINGS) #include "esp3d_message.h" @@ -853,6 +855,7 @@ bool ESP3DSettings::isValidIntegerSetting(uint32_t value, return false; } switch (settingElement) { +#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL case ESP_SERIAL_BRIDGE_BAUD: case ESP_BAUD_RATE: for (uint8_t i = 0; i < SupportedBaudListSize; i++) { @@ -861,6 +864,7 @@ bool ESP3DSettings::isValidIntegerSetting(uint32_t value, } } break; +#endif //#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL case ESP_WEBDAV_PORT: case ESP_HTTP_PORT: case ESP_TELNET_PORT: diff --git a/src/esp3dlib.cpp b/src/esp3dlib.cpp index bc0619e..ff07129 100644 --- a/src/esp3dlib.cpp +++ b/src/esp3dlib.cpp @@ -28,8 +28,8 @@ #include #endif //FILESYSTEM_FEATURE #include "core/esp3d.h" -#include "core/esp3doutput.h" -#include "core/commands.h" +#include "core/esp3d_commands.h" +#include "core/esp3d_hal.h" #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 #include #endif //CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 @@ -38,6 +38,7 @@ #endif //SDSUPPORT + Esp3DLib esp3dlib; Esp3D myesp3d; @@ -54,7 +55,7 @@ void ESP3DLibTaskfn( void * parameter ) #endif //#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 vTaskDelay(1 / portTICK_RATE_MS); } - vTaskDelete( Hal::xHandle ); + vTaskDelete( ESP3DHal::xHandle ); } @@ -74,10 +75,17 @@ void Esp3DLib::init() bool Esp3DLib::parse(char * cmd) { if (myesp3d.started() && esp3d_commands.is_esp_command((uint8_t *)cmd, strlen(cmd))) { - //command come from other serial port - ESP3DOutput output(ESP_ECHO_SERIAL_CLIENT); - esp3d_commands.process((uint8_t *)cmd, strlen(cmd),& output, LEVEL_ADMIN); - return true; + //command come from other serial port + ESP3DMessage *msg = ESP3DMessageManager::newMsg( + ESP3DClientType::echo_serial,ESP3DClientType::command ,(uint8_t *)cmd, + strlen(cmd), ESP3DAuthenticationLevel::admin); + if (msg) { + // process command + esp3d_commands.process(msg); + } else { + esp3d_log_e("Cannot create message"); + } + return true; } return false; } @@ -106,14 +114,14 @@ void Esp3DLib::idletask() 8192, /* Stack size of task */ NULL, /* parameter of the task */ ESP3DLIB_RUNNING_PRIORITY, /* priority of the task */ - &(Hal::xHandle), /* Task handle to keep track of created task */ + &(ESP3DHal::xHandle), /* Task handle to keep track of created task */ ESP3DLIB_RUNNING_CORE /* Core to run the task */ ); #ifdef DISABLE_WDT_ESP3DLIB_TASK - esp_task_wdt_delete(Hal::xHandle); + esp_task_wdt_delete(ESP3DHal::xHandle); #endif //DISABLE_WDT_ESP3DLIB_TASK } } - Hal::wait (0); // Yield to other tasks + ESP3DHal::wait (0); // Yield to other tasks } #endif //ESP3DLIB_ENV diff --git a/src/esp3dlib_config.h b/src/esp3dlib_config.h index 9d98883..f53f46a 100644 --- a/src/esp3dlib_config.h +++ b/src/esp3dlib_config.h @@ -30,7 +30,14 @@ #define ESP_XSTR_(M) #M #define ESP_XSTR(M) ESP_XSTR_(M) #endif -#define MARLIN_PATH(PATH) ESP_XSTR(../../../../../Marlin/src/PATH) +#ifndef SRCHOME +#define SRCHOME ../../../../../Marlin/src +#endif +#ifndef HALHOME +#define HALHOME SRCHOME/HAL +#endif +#define MARLIN_HAL_PATH(PATH) HAL_PATH(HALHOME, PATH) +#define MARLIN_PATH(PATH) ESP_XSTR(SRCHOME/PATH) #include MARLIN_PATH(inc/MarlinConfig.h) #undef DISABLED @@ -43,7 +50,7 @@ #else #define OTASUPPORT #define WEBSUPPORT -#define SHORT_BUILD_VERSION "2.0.9.3+" +#define SHORT_BUILD_VERSION "2.1.x" /********************************************************* * diff --git a/src/include/esp3d_version.h b/src/include/esp3d_version.h index 031e433..b7e485f 100644 --- a/src/include/esp3d_version.h +++ b/src/include/esp3d_version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H // version and sources location -#define FW_VERSION "3.0.0.a225" +#define FW_VERSION "3.0.0.a226" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H diff --git a/src/modules/filesystem/sd/sd_sdfat2_esp32.cpp b/src/modules/filesystem/sd/sd_sdfat2_esp32.cpp index cee7209..613c573 100644 --- a/src/modules/filesystem/sd/sd_sdfat2_esp32.cpp +++ b/src/modules/filesystem/sd/sd_sdfat2_esp32.cpp @@ -230,15 +230,15 @@ bool ESP_SD::rename(const char* oldpath, const char* newpath) { return SD.rename(oldpath, newpath); } -bool ESP_SD::format() { +bool ESP_SD::format() { + uint32_t const ERASE_SIZE = 262144L; + uint32_t cardSectorCount = 0; + uint8_t sectorBuffer[512]; + // SdCardFactory constructs and initializes the appropriate card. + SdCardFactory cardFactory; + // Pointer to generic SD card. + SdCard* m_card = nullptr; if (ESP_SD::getState(true) == ESP_SDCARD_IDLE) { - uint32_t const ERASE_SIZE = 262144L; - uint32_t cardSectorCount = 0; - uint8_t sectorBuffer[512]; - // SdCardFactory constructs and initializes the appropriate card. - SdCardFactory cardFactory; - // Pointer to generic SD card. - SdCard* m_card = nullptr; // prepare m_card = cardFactory.newCard(SD_CONFIG); if (!m_card || m_card->errorCode()) { @@ -253,6 +253,9 @@ bool ESP_SD::format() { } esp3d_log("Capacity detected :%d GB", cardSectorCount * 5.12e-7); + } else { + esp3d_log_e("SD not ready"); + return false; } uint32_t firstBlock = 0; @@ -287,14 +290,11 @@ bool ESP_SD::format() { : fatFormatter.format(m_card, sectorBuffer, nullptr); if (!rtn) { - esp3d_log_e(("erase failed"); + esp3d_log_e("erase failed"); return false; } return true; -} - esp3d_log_e(("cannot erase"); -return false; } ESP_SDFile ESP_SD::open(const char* path, uint8_t mode) { diff --git a/src/modules/http/handlers/handle-SD-files.cpp b/src/modules/http/handlers/handle-SD-files.cpp index e6933c8..52f6075 100644 --- a/src/modules/http/handlers/handle-SD-files.cpp +++ b/src/modules/http/handlers/handle-SD-files.cpp @@ -29,6 +29,7 @@ #endif // ARDUINO_ARCH_ESP8266 #include "../../authentication/authentication_service.h" #include "../../filesystem/esp_sd.h" +#include "../../../core/esp3d_string.h" // SD // SD files list and file commands @@ -238,10 +239,12 @@ void HTTP_Server::handleSDFileList() { buffer2send += "\"occupation\":\"0\","; } buffer2send += "\"status\":\"" + status + "\","; - buffer2send += - "\"total\":\"" + esp3d_string::formatBytes(ESP_SD::totalBytes()) + "\","; - buffer2send += - "\"used\":\"" + esp3d_string::formatBytes(ESP_SD::usedBytes()) + "\"}"; + buffer2send += "\"total\":\"" ; + buffer2send += esp3d_string::formatBytes(ESP_SD::totalBytes()) ; + buffer2send += "\","; + buffer2send += "\"used\":\""; + buffer2send += esp3d_string::formatBytes(ESP_SD::usedBytes()); + buffer2send += "\"}"; path = ""; _webserver->sendContent_P(buffer2send.c_str(), buffer2send.length()); _webserver->sendContent(""); diff --git a/src/modules/serial2socket/serial2socket.cpp b/src/modules/serial2socket/serial2socket.cpp index fd40049..20e9643 100644 --- a/src/modules/serial2socket/serial2socket.cpp +++ b/src/modules/serial2socket/serial2socket.cpp @@ -23,7 +23,7 @@ #if defined(ESP3DLIB_ENV) && COMMUNICATION_PROTOCOL == SOCKET_SERIAL #include - +#include "../../core/esp3d_message.h" #include "../../core/esp3d_commands.h" #include "serial2socket.h" diff --git a/src/modules/serial2socket/serial2socket.h b/src/modules/serial2socket/serial2socket.h index 4d170a6..1007827 100644 --- a/src/modules/serial2socket/serial2socket.h +++ b/src/modules/serial2socket/serial2socket.h @@ -22,12 +22,15 @@ #define _SERIAL_2_SOCKET_H_ #include - -#include "../../core/esp3d_message.h" - +#include "../authentication/authentication_level_types.h" #define S2S_TXBUFFERSIZE 1200 #define S2S_RXBUFFERSIZE 128 #define S2S_FLUSHTIMEOUT 500 + + +class ESP3DMessage; // forward declaration + + class Serial_2_Socket : public Stream { public: Serial_2_Socket();