diff --git a/esp3d/esp3d.ino.generic.bin b/esp3d/esp3d.ino.generic.bin new file mode 100644 index 00000000..6426e016 Binary files /dev/null and b/esp3d/esp3d.ino.generic.bin differ diff --git a/esp3d/src/core/espcmd/ESP800.cpp b/esp3d/src/core/espcmd/ESP800.cpp index 1db955bb..35db05b8 100644 --- a/esp3d/src/core/espcmd/ESP800.cpp +++ b/esp3d/src/core/espcmd/ESP800.cpp @@ -215,11 +215,11 @@ bool Commands::ESP800(const char* cmd_params, level_authenticate_type auth_type, output->print(",\"WebUpdate\":\""); } #ifdef WEB_UPDATE_FEATURE - if (ESP_FileSystem::max_update_size()!=0){ - output->print("Enabled"); - } else { - output->print("Disabled"); - } + if (ESP_FileSystem::max_update_size()!=0) { + output->print("Enabled"); + } else { + output->print("Disabled"); + } #else output->print("Disabled"); #endif //WEB_UPDATE_FEATURE diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index d33874dc..8e29c1bd 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.a59" +#define FW_VERSION "3.0.0.a60" #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 aa0cb2c4..5f210f9a 100644 --- a/esp3d/src/modules/serial/serial_service.cpp +++ b/esp3d/src/modules/serial/serial_service.cpp @@ -39,7 +39,14 @@ #define ESP3D_SERIAL Serial2 #endif //USE_SERIAL_2 +#define ESP3DSERIAL_RUNNING_PRIORITY 1 + +#define ESP3DSERIAL_RUNNING_CORE 1 + SerialService serial_service; +#ifdef ARDUINO_ARCH_ESP32 +TaskHandle_t _hserialtask= nullptr; +#endif //ARDUINO_ARCH_ESP32 const long SupportedBaudList[] = {9600, 19200, 38400, 57600, 74880, 115200, 230400, 250000, 500000, 921600}; @@ -57,6 +64,18 @@ SerialService::~SerialService() end(); } +//dedicated serial task +#ifdef ARDUINO_ARCH_ESP32 +void ESP3DSerialTaskfn( void * parameter ) +{ + for(;;) { + serial_service.process(); + Hal::wait(0); // Yield to other tasks + } + vTaskDelete( NULL ); +} +#endif //ARDUINO_ARCH_ESP32 + //Setup Serial bool SerialService::begin() { @@ -69,6 +88,7 @@ bool SerialService::begin() if ( !is_valid_baudrate(br)) { br = Settings_ESP3D::get_default_int32_value(ESP_BAUD_RATE); } + 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); #if ESP_RX_PIN != -1 @@ -77,9 +97,24 @@ bool SerialService::begin() #endif //ARDUINO_ARCH_ESP8266 #ifdef ARDUINO_ARCH_ESP32 ESP3D_SERIAL.begin (br, ESP_SERIAL_PARAM, ESP_RX_PIN, ESP_TX_PIN); + //create serial task once + if (_hserialtask == nullptr) { + xTaskCreatePinnedToCore( + ESP3DSerialTaskfn, /* Task function. */ + "ESP3D Serial Task", /* name of task. */ + 8096, /* Stack size of task */ + NULL, /* parameter of the task */ + ESP3DSERIAL_RUNNING_PRIORITY, /* priority of the task */ + &_hserialtask, /* Task handle to keep track of created task */ + ESP3DSERIAL_RUNNING_CORE /* Core to run the task */ + ); + } + if (_hserialtask == nullptr) { + log_esp3d("Serial Task creation failed"); + return false; + } #endif //ARDUINO_ARCH_ESP32 } - ESP3D_SERIAL.setRxBufferSize (SERIAL_RX_BUFFER_SIZE); _started = true; return true; } @@ -117,7 +152,7 @@ bool SerialService::is_valid_baudrate(long br) } //Function which could be called in other loop -void SerialService::handle() +void SerialService::process() { //Do we have some data waiting size_t len = available(); @@ -141,6 +176,16 @@ void SerialService::handle() } } +//Function which could be called in other loop +void SerialService::handle() +{ +//for ESP32 there is dedicated task for it +#ifdef ARDUINO_ARCH_ESP8266 + process(); +#endif //ARDUINO_ARCH_ESP8266 + +} + void SerialService::flushbuffer() { ESP3DOutput output(ESP_SERIAL_CLIENT); diff --git a/esp3d/src/modules/serial/serial_service.h b/esp3d/src/modules/serial/serial_service.h index 8cf8d173..cfcecb4b 100644 --- a/esp3d/src/modules/serial/serial_service.h +++ b/esp3d/src/modules/serial/serial_service.h @@ -33,6 +33,7 @@ public: bool begin(); bool end(); void handle(); + void process(); bool reset(); long baudRate(); const long * get_baudratelist(uint8_t * count);