From b8752b7272495ebbc485ee4eca140aae0b4184f0 Mon Sep 17 00:00:00 2001 From: wir3z Date: Wed, 22 Dec 2021 09:23:15 -0700 Subject: [PATCH 1/7] TasmotaSerial: - Added transmit parity to software TX. Software RX just consumes in the incoming parity bit with no error checking. - Fixed issue where Serial.begin for the ESP8266 was not passing the UART SerialConfig compatible values. support.ino - Cleanup to use already present ConvertSerialConfig API. tasmota.ino: - Force the baudrate + serial config settings after boot. Previously, the baudrate would change, but any non 8N1 settings were not applied. xdrv_08_serial_bridge.ino: - Increased the software serial bridge buffer size and changed type to prevent overflow. - Added missing serial config settings to the serial begin. Previously was forcing 8N1. xdrv_10_scripter.ino - Cleanup to use already present ConvertSerialConfig API. --- .../TasmotaSerial-3.3.0/src/TasmotaSerial.cpp | 52 +++++++++++++------ .../TasmotaSerial-3.3.0/src/TasmotaSerial.h | 3 ++ tasmota/support.ino | 5 +- tasmota/tasmota.ino | 2 +- tasmota/xdrv_08_serial_bridge.ino | 10 +++- tasmota/xdrv_10_scripter.ino | 10 +--- 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp index 07754719e..507f079e6 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp @@ -55,6 +55,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal m_hardserial = false; m_hardswap = false; m_stop_bits = 1; + m_parity = -1; m_nwmode = nwmode; serial_buffer_size = buffer_size; m_rx_pin = receive_pin; @@ -121,26 +122,23 @@ bool TasmotaSerial::isValidGPIOpin(int pin) { bool TasmotaSerial::begin(uint32_t speed, uint32_t config) { if (!m_valid) { return false; } - if (config > 2) { - // Legacy support where software serial fakes two stop bits if either stop bits is 2 or parity is not None - m_stop_bits = ((config &0x30) >> 5) +1; - if ((1 == m_stop_bits) && (config &0x03)) { - m_stop_bits++; + // get the number of stop bits + m_stop_bits = (config &0x20) ? 2 : 1; + // check for parity + if (config &0x02) { // parity is enabled + if (config &0x01) { + m_parity = HIGH; // odd parity + } else { + m_parity = LOW; // even parity } } else { - m_stop_bits = ((config -1) &1) +1; -#ifdef ESP8266 - config = (2 == m_stop_bits) ? (uint32_t)SERIAL_8N2 : (uint32_t)SERIAL_8N1; -#endif // ESP8266 -#ifdef ESP32 - config = (2 == m_stop_bits) ? SERIAL_8N2 : SERIAL_8N1; -#endif // ESP32 + m_parity = -1; // no parity } if (m_hardserial) { #ifdef ESP8266 Serial.flush(); - Serial.begin(speed, (SerialConfig)config); + Serial.begin(speed, (SerialConfig)ConvertSerialConfig(config)); if (m_hardswap) { Serial.swap(); } @@ -285,14 +283,23 @@ int TasmotaSerial::available(void) { void IRAM_ATTR TasmotaSerial::_fast_write(uint8_t b) { uint32_t wait = m_bit_time; uint32_t start = ESP.getCycleCount(); + uint8_t numOnes = 0; + uint8_t bit; // Start bit; digitalWrite(m_tx_pin, LOW); TM_SERIAL_WAIT_SND_FAST; for (uint32_t i = 0; i < 8; i++) { - digitalWrite(m_tx_pin, (b & 1) ? HIGH : LOW); + bit = (b &1); + numOnes += bit; + digitalWrite(m_tx_pin, bit ? HIGH : LOW); TM_SERIAL_WAIT_SND_FAST; b >>= 1; } + // parity bit + if (m_parity != -1) { + digitalWrite(m_tx_pin, (numOnes %2) ? !m_parity : m_parity); + TM_SERIAL_WAIT_SND_FAST; + } // Stop bit(s) digitalWrite(m_tx_pin, HIGH); for (uint32_t i = 0; i < m_stop_bits; i++) { @@ -318,14 +325,23 @@ size_t TasmotaSerial::write(uint8_t b) { uint32_t wait = m_bit_time; //digitalWrite(m_tx_pin, HIGH); // already in HIGH mode uint32_t start = ESP.getCycleCount(); + uint8_t numOnes = 0; + uint8_t bit; // Start bit; digitalWrite(m_tx_pin, LOW); TM_SERIAL_WAIT_SND; for (uint32_t i = 0; i < 8; i++) { - digitalWrite(m_tx_pin, (b & 1) ? HIGH : LOW); + bit = (b &1); + numOnes += bit; + digitalWrite(m_tx_pin, bit ? HIGH : LOW); TM_SERIAL_WAIT_SND; b >>= 1; } + // parity bit + if (m_parity != -1) { + digitalWrite(m_tx_pin, (numOnes %2) ? !m_parity : m_parity); + TM_SERIAL_WAIT_SND; + } // Stop bit(s) digitalWrite(m_tx_pin, HIGH); // re-enable interrupts during stop bits, it's not an issue if they are longer than expected @@ -359,6 +375,12 @@ void IRAM_ATTR TasmotaSerial::rxRead(void) { m_in_pos = next; } + // just consume the parity bit -- no parity checking is occuring + if (m_parity != -1) { + TM_SERIAL_WAIT_RCV_LOOP; // wait for the parity bit + wait += m_bit_time / 4; + } + TM_SERIAL_WAIT_RCV_LOOP; // wait for stop bit if (2 == m_stop_bits) { wait += m_bit_time; diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h index 3a90626fe..141991f64 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h @@ -35,6 +35,8 @@ #include #endif +extern uint32_t ConvertSerialConfig(uint8_t serial_config); + class TasmotaSerial : public Stream { public: TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE); @@ -68,6 +70,7 @@ class TasmotaSerial : public Stream { int m_rx_pin; int m_tx_pin; uint32_t m_stop_bits; + uint32_t m_parity; uint32_t ss_byte; uint32_t ss_bstart; uint32_t ss_index; diff --git a/tasmota/support.ino b/tasmota/support.ino index 303a66e87..429236033 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1885,15 +1885,14 @@ void SetSerialBegin(void) { AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_SERIAL "Set to %s %d bit/s"), GetSerialConfig().c_str(), TasmotaGlobal.baudrate); Serial.flush(); #ifdef ESP8266 - Serial.begin(TasmotaGlobal.baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings->serial_config)); + Serial.begin(TasmotaGlobal.baudrate, (SerialConfig)ConvertSerialConfig(Settings->serial_config)); SetSerialSwap(); #endif // ESP8266 #ifdef ESP32 delay(10); // Allow time to cleanup queues - if not used hangs ESP32 Serial.end(); delay(10); // Allow time to cleanup queues - if not used hangs ESP32 - uint32_t config = pgm_read_dword(kTasmotaSerialConfig + Settings->serial_config); - Serial.begin(TasmotaGlobal.baudrate, config); + Serial.begin(TasmotaGlobal.baudrate, ConvertSerialConfig(Settings->serial_config)); #endif // ESP32 } diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 6ebe7d7d2..8def8103f 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -337,7 +337,7 @@ void setup(void) { Settings->baudrate = APP_BAUDRATE / 300; Settings->serial_config = TS_SERIAL_8N1; } - SetSerialBaudrate(Settings->baudrate * 300); // Reset serial interface if current baudrate is different from requested baudrate + SetSerialBegin(); // Reset serial interface if current serial settings are different from requested serial settings if (1 == RtcReboot.fast_reboot_count) { // Allow setting override only when all is well UpdateQuickPowerCycle(true); diff --git a/tasmota/xdrv_08_serial_bridge.ino b/tasmota/xdrv_08_serial_bridge.ino index aac2c1bea..9073cb610 100644 --- a/tasmota/xdrv_08_serial_bridge.ino +++ b/tasmota/xdrv_08_serial_bridge.ino @@ -25,7 +25,7 @@ #define XDRV_08 8 #define HARDWARE_FALLBACK 2 -const uint8_t SERIAL_BRIDGE_BUFFER_SIZE = 130; +const uint16_t SERIAL_BRIDGE_BUFFER_SIZE = 256; const char kSerialBridgeCommands[] PROGMEM = "|" // No prefix D_CMND_SSERIALSEND "|" D_CMND_SBAUDRATE; @@ -106,7 +106,13 @@ void SerialBridgeInit(void) serial_bridge_active = false; if (PinUsed(GPIO_SBR_RX) && PinUsed(GPIO_SBR_TX)) { SerialBridgeSerial = new TasmotaSerial(Pin(GPIO_SBR_RX), Pin(GPIO_SBR_TX), HARDWARE_FALLBACK); - if (SerialBridgeSerial->begin(Settings->sbaudrate * 300)) { // Baud rate is stored div 300 so it fits into 16 bits +#ifdef ESP8266 + if (SerialBridgeSerial->begin(Settings->sbaudrate * 300, (SerialConfig)ConvertSerialConfig(Settings->serial_config))) // Baud rate is stored div 300 so it fits into 16 bits +#endif // ESP8266 +#ifdef ESP32 + if (SerialBridgeSerial->begin(Settings->sbaudrate * 300, ConvertSerialConfig(Settings->serial_config))) // Baud rate is stored div 300 so it fits into 16 bits +#endif // ESP32 + { if (SerialBridgeSerial->hardwareSerial()) { ClaimSerial(); serial_bridge_buffer = TasmotaGlobal.serial_in_buffer; // Use idle serial buffer to save RAM diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index b567864c1..64de0f425 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -3620,15 +3620,7 @@ chknext: glob_script_mem.sp = new TasmotaSerial(rxpin, txpin, 1, 0, rxbsiz); if (glob_script_mem.sp) { - uint32_t config; -#ifdef ESP8266 - config = pgm_read_byte(kTasmotaSerialConfig + sconfig); -#endif // ESP8266 - -#ifdef ESP32 - config = pgm_read_dword(kTasmotaSerialConfig + sconfig); -#endif // ESP32 - fvar = glob_script_mem.sp->begin(br, config); + fvar = glob_script_mem.sp->begin(br, ConvertSerialConfig(sconfig)); uint32_t savc = Settings->serial_config; //setRxBufferSize(TMSBSIZ); From ee39f84bc25a4959706c30430bb129d001273b0c Mon Sep 17 00:00:00 2001 From: wir3z Date: Wed, 22 Dec 2021 09:47:20 -0700 Subject: [PATCH 2/7] Rolled out parity changes due to potential timing issues. --- .../TasmotaSerial-3.3.0/src/TasmotaSerial.cpp | 50 ++++++------------- .../TasmotaSerial-3.3.0/src/TasmotaSerial.h | 3 -- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp index 507f079e6..a678e2e16 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp @@ -55,7 +55,6 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal m_hardserial = false; m_hardswap = false; m_stop_bits = 1; - m_parity = -1; m_nwmode = nwmode; serial_buffer_size = buffer_size; m_rx_pin = receive_pin; @@ -122,17 +121,20 @@ bool TasmotaSerial::isValidGPIOpin(int pin) { bool TasmotaSerial::begin(uint32_t speed, uint32_t config) { if (!m_valid) { return false; } - // get the number of stop bits - m_stop_bits = (config &0x20) ? 2 : 1; - // check for parity - if (config &0x02) { // parity is enabled - if (config &0x01) { - m_parity = HIGH; // odd parity - } else { - m_parity = LOW; // even parity + if (config > 2) { + // Legacy support where software serial fakes two stop bits if either stop bits is 2 or parity is not None + m_stop_bits = ((config &0x30) >> 5) +1; + if ((1 == m_stop_bits) && (config &0x03)) { + m_stop_bits++; } } else { - m_parity = -1; // no parity + m_stop_bits = ((config -1) &1) +1; +#ifdef ESP8266 + config = (2 == m_stop_bits) ? (uint32_t)SERIAL_8N2 : (uint32_t)SERIAL_8N1; +#endif // ESP8266 +#ifdef ESP32 + config = (2 == m_stop_bits) ? SERIAL_8N2 : SERIAL_8N1; +#endif // ESP32 } if (m_hardserial) { @@ -283,23 +285,14 @@ int TasmotaSerial::available(void) { void IRAM_ATTR TasmotaSerial::_fast_write(uint8_t b) { uint32_t wait = m_bit_time; uint32_t start = ESP.getCycleCount(); - uint8_t numOnes = 0; - uint8_t bit; // Start bit; digitalWrite(m_tx_pin, LOW); TM_SERIAL_WAIT_SND_FAST; for (uint32_t i = 0; i < 8; i++) { - bit = (b &1); - numOnes += bit; - digitalWrite(m_tx_pin, bit ? HIGH : LOW); + digitalWrite(m_tx_pin, (b & 1) ? HIGH : LOW); TM_SERIAL_WAIT_SND_FAST; b >>= 1; } - // parity bit - if (m_parity != -1) { - digitalWrite(m_tx_pin, (numOnes %2) ? !m_parity : m_parity); - TM_SERIAL_WAIT_SND_FAST; - } // Stop bit(s) digitalWrite(m_tx_pin, HIGH); for (uint32_t i = 0; i < m_stop_bits; i++) { @@ -325,23 +318,14 @@ size_t TasmotaSerial::write(uint8_t b) { uint32_t wait = m_bit_time; //digitalWrite(m_tx_pin, HIGH); // already in HIGH mode uint32_t start = ESP.getCycleCount(); - uint8_t numOnes = 0; - uint8_t bit; // Start bit; digitalWrite(m_tx_pin, LOW); TM_SERIAL_WAIT_SND; for (uint32_t i = 0; i < 8; i++) { - bit = (b &1); - numOnes += bit; - digitalWrite(m_tx_pin, bit ? HIGH : LOW); + digitalWrite(m_tx_pin, (b & 1) ? HIGH : LOW); TM_SERIAL_WAIT_SND; b >>= 1; } - // parity bit - if (m_parity != -1) { - digitalWrite(m_tx_pin, (numOnes %2) ? !m_parity : m_parity); - TM_SERIAL_WAIT_SND; - } // Stop bit(s) digitalWrite(m_tx_pin, HIGH); // re-enable interrupts during stop bits, it's not an issue if they are longer than expected @@ -375,12 +359,6 @@ void IRAM_ATTR TasmotaSerial::rxRead(void) { m_in_pos = next; } - // just consume the parity bit -- no parity checking is occuring - if (m_parity != -1) { - TM_SERIAL_WAIT_RCV_LOOP; // wait for the parity bit - wait += m_bit_time / 4; - } - TM_SERIAL_WAIT_RCV_LOOP; // wait for stop bit if (2 == m_stop_bits) { wait += m_bit_time; diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h index 141991f64..3a90626fe 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h @@ -35,8 +35,6 @@ #include #endif -extern uint32_t ConvertSerialConfig(uint8_t serial_config); - class TasmotaSerial : public Stream { public: TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE); @@ -70,7 +68,6 @@ class TasmotaSerial : public Stream { int m_rx_pin; int m_tx_pin; uint32_t m_stop_bits; - uint32_t m_parity; uint32_t ss_byte; uint32_t ss_bstart; uint32_t ss_index; From b8e9d9401e6d3da4e3e5ee19d29494f3d1620199 Mon Sep 17 00:00:00 2001 From: wir3z Date: Wed, 22 Dec 2021 09:50:35 -0700 Subject: [PATCH 3/7] Added back missing external. --- lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h index 3a90626fe..c4795a608 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h @@ -35,6 +35,7 @@ #include #endif +extern uint32_t ConvertSerialConfig(uint8_t serial_config); class TasmotaSerial : public Stream { public: TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE); From 4554a5ba9e4fff2fffb6c7a0b13feb6af7e1e185 Mon Sep 17 00:00:00 2001 From: wir3z Date: Wed, 22 Dec 2021 09:53:06 -0700 Subject: [PATCH 4/7] Revert "Added back missing external." This reverts commit b8e9d9401e6d3da4e3e5ee19d29494f3d1620199. --- lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h index c4795a608..3a90626fe 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h @@ -35,7 +35,6 @@ #include #endif -extern uint32_t ConvertSerialConfig(uint8_t serial_config); class TasmotaSerial : public Stream { public: TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE); From 223314804d530b37bb02b2bad96a5fe063df903c Mon Sep 17 00:00:00 2001 From: wir3z Date: Wed, 22 Dec 2021 10:22:16 -0700 Subject: [PATCH 5/7] Removed external function call, referenced header. --- lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp index a678e2e16..81fc94834 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp @@ -29,6 +29,11 @@ extern "C" { #ifdef ESP8266 +// added to access kTasmotaSerialConfig +#include "..\..\..\..\tasmota\tasmota_compat.h" +#include "..\..\..\..\tasmota\tasmota.h" + + void IRAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); }; // As the Arduino attachInterrupt has no parameter, lists of objects @@ -140,7 +145,7 @@ bool TasmotaSerial::begin(uint32_t speed, uint32_t config) { if (m_hardserial) { #ifdef ESP8266 Serial.flush(); - Serial.begin(speed, (SerialConfig)ConvertSerialConfig(config)); + Serial.begin(speed, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + config)); if (m_hardswap) { Serial.swap(); } From 3c8cda25fbe9991e4bca68da1b6d8bf17b21fbf9 Mon Sep 17 00:00:00 2001 From: wir3z Date: Wed, 22 Dec 2021 10:28:55 -0700 Subject: [PATCH 6/7] Added linux safe path. --- lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp index 81fc94834..e47e0d224 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp @@ -30,8 +30,8 @@ extern "C" { #ifdef ESP8266 // added to access kTasmotaSerialConfig -#include "..\..\..\..\tasmota\tasmota_compat.h" -#include "..\..\..\..\tasmota\tasmota.h" +#include "../../../../tasmota/tasmota_compat.h" +#include "../../../../tasmota/tasmota.h" void IRAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); }; From 30d35b8c15800c964d9dc3d150cfed35418832e8 Mon Sep 17 00:00:00 2001 From: wir3z Date: Wed, 22 Dec 2021 12:23:17 -0700 Subject: [PATCH 7/7] Moved kTasmotaSerialConfig to TasmotaSerial.h from Tasmota.h. --- .../TasmotaSerial-3.3.0/src/TasmotaSerial.cpp | 6 ------ .../TasmotaSerial-3.3.0/src/TasmotaSerial.h | 21 +++++++++++++++++++ tasmota/support.ino | 1 + tasmota/tasmota.h | 21 ------------------- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp index e47e0d224..a0087d0f4 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp @@ -28,12 +28,6 @@ extern "C" { #include #ifdef ESP8266 - -// added to access kTasmotaSerialConfig -#include "../../../../tasmota/tasmota_compat.h" -#include "../../../../tasmota/tasmota.h" - - void IRAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); }; // As the Arduino attachInterrupt has no parameter, lists of objects diff --git a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h index 3a90626fe..f2af363f1 100644 --- a/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h @@ -35,6 +35,27 @@ #include #endif +#ifdef ESP8266 +const uint8_t kTasmotaSerialConfig[] PROGMEM = { + SERIAL_5N1, SERIAL_6N1, SERIAL_7N1, SERIAL_8N1, + SERIAL_5N2, SERIAL_6N2, SERIAL_7N2, SERIAL_8N2, + SERIAL_5E1, SERIAL_6E1, SERIAL_7E1, SERIAL_8E1, + SERIAL_5E2, SERIAL_6E2, SERIAL_7E2, SERIAL_8E2, + SERIAL_5O1, SERIAL_6O1, SERIAL_7O1, SERIAL_8O1, + SERIAL_5O2, SERIAL_6O2, SERIAL_7O2, SERIAL_8O2 +}; +#endif // ESP8266 +#ifdef ESP32 +const uint32_t kTasmotaSerialConfig[] PROGMEM = { + SERIAL_5N1, SERIAL_6N1, SERIAL_7N1, SERIAL_8N1, + SERIAL_5N2, SERIAL_6N2, SERIAL_7N2, SERIAL_8N2, + SERIAL_5E1, SERIAL_6E1, SERIAL_7E1, SERIAL_8E1, + SERIAL_5E2, SERIAL_6E2, SERIAL_7E2, SERIAL_8E2, + SERIAL_5O1, SERIAL_6O1, SERIAL_7O1, SERIAL_8O1, + SERIAL_5O2, SERIAL_6O2, SERIAL_7O2, SERIAL_8O2 +}; +#endif // ESP32 + class TasmotaSerial : public Stream { public: TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE); diff --git a/tasmota/support.ino b/tasmota/support.ino index 429236033..b1b61a799 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -28,6 +28,7 @@ bool knx_started = false; /*********************************************************************************************\ * Watchdog extension (https://github.com/esp8266/Arduino/issues/1532) \*********************************************************************************************/ +#include #ifdef ESP8266 #include diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index 9aa5c1b27..c71f910ec 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -431,27 +431,6 @@ enum TasmotaSerialConfig { TS_SERIAL_5O1, TS_SERIAL_6O1, TS_SERIAL_7O1, TS_SERIAL_8O1, TS_SERIAL_5O2, TS_SERIAL_6O2, TS_SERIAL_7O2, TS_SERIAL_8O2 }; -#ifdef ESP8266 -const SerConfu8 kTasmotaSerialConfig[] PROGMEM = { - SERIAL_5N1, SERIAL_6N1, SERIAL_7N1, SERIAL_8N1, - SERIAL_5N2, SERIAL_6N2, SERIAL_7N2, SERIAL_8N2, - SERIAL_5E1, SERIAL_6E1, SERIAL_7E1, SERIAL_8E1, - SERIAL_5E2, SERIAL_6E2, SERIAL_7E2, SERIAL_8E2, - SERIAL_5O1, SERIAL_6O1, SERIAL_7O1, SERIAL_8O1, - SERIAL_5O2, SERIAL_6O2, SERIAL_7O2, SERIAL_8O2 -}; -#endif // ESP8266 -#ifdef ESP32 -const uint32_t kTasmotaSerialConfig[] PROGMEM = { - SERIAL_5N1, SERIAL_6N1, SERIAL_7N1, SERIAL_8N1, - SERIAL_5N2, SERIAL_6N2, SERIAL_7N2, SERIAL_8N2, - SERIAL_5E1, SERIAL_6E1, SERIAL_7E1, SERIAL_8E1, - SERIAL_5E2, SERIAL_6E2, SERIAL_7E2, SERIAL_8E2, - SERIAL_5O1, SERIAL_6O1, SERIAL_7O1, SERIAL_8O1, - SERIAL_5O2, SERIAL_6O2, SERIAL_7O2, SERIAL_8O2 -}; -#endif // ESP32 - enum TuyaSupportedFunctions { TUYA_MCU_FUNC_NONE, TUYA_MCU_FUNC_SWT1 = 1, TUYA_MCU_FUNC_SWT2, TUYA_MCU_FUNC_SWT3, TUYA_MCU_FUNC_SWT4, TUYA_MCU_FUNC_REL1 = 11, TUYA_MCU_FUNC_REL2, TUYA_MCU_FUNC_REL3, TUYA_MCU_FUNC_REL4, TUYA_MCU_FUNC_REL5,