diff --git a/tasmota/include/tasmota.h b/tasmota/include/tasmota.h index 0ec8fa05f..a9e21c796 100644 --- a/tasmota/include/tasmota.h +++ b/tasmota/include/tasmota.h @@ -195,7 +195,9 @@ const uint8_t OTA_ATTEMPTS = 10; // Number of times to try fetching t const uint8_t OTA_ATTEMPTS = 5; // Number of times to try fetching the new firmware #endif // ESP8266 -const uint16_t INPUT_BUFFER_SIZE = 520; // Max number of characters in serial command buffer +const uint16_t INPUT_BUFFER_SIZE = 520; // Max number of characters in Tasmota serial command buffer +const uint16_t MIN_INPUT_BUFFER_SIZE = 256; // Max number of characters in Tasmota serial command buffer +const uint16_t MAX_INPUT_BUFFER_SIZE = 2048; // Max number of characters in Arduino serial command buffer const uint16_t FLOATSZ = 16; // Max number of characters in float result from dtostrfd (max 32) const uint16_t CMDSZ = 24; // Max number of characters in command const uint16_t TOPSZ = 151; // Max number of characters in topic string diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 22ebd743a..e29c3ccb9 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -1830,16 +1830,19 @@ void CmndSerialConfig(void) void CmndSerialBuffer(void) { // Allow non-pesistent serial receive buffer size change - // between 256 (default) and 520 (INPUT_BUFFER_SIZE) characters + // between MIN_INPUT_BUFFER_SIZE and MAX_INPUT_BUFFER_SIZE characters size_t size = 0; if (XdrvMailbox.data_len > 0) { size = XdrvMailbox.payload; - if (XdrvMailbox.payload < 256) { - size = 256; - } - if ((1 == XdrvMailbox.payload) || (XdrvMailbox.payload > INPUT_BUFFER_SIZE)) { + if (1 == XdrvMailbox.payload) { size = INPUT_BUFFER_SIZE; } + else if (XdrvMailbox.payload < MIN_INPUT_BUFFER_SIZE) { + size = MIN_INPUT_BUFFER_SIZE; + } + else if (XdrvMailbox.payload > MAX_INPUT_BUFFER_SIZE) { + size = MAX_INPUT_BUFFER_SIZE; + } Serial.setRxBufferSize(size); } #ifdef ESP8266