From 20579122764d779b20a3ba357c54497c4b4b579e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 2 Mar 2021 11:44:06 +0100 Subject: [PATCH] Change TasmotaSerial library from v3.2.0 to v3.3.0 Change TasmotaSerial library from v3.2.0 to v3.3.0 --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + .../README.md | 0 .../examples/swsertest/swsertest.ino | 0 .../keywords.txt | 0 .../library.json | 2 +- .../library.properties | 2 +- .../src/TasmotaSerial.cpp | 35 ++++++++++--------- .../src/TasmotaSerial.h | 3 +- 9 files changed, 24 insertions(+), 20 deletions(-) rename lib/default/{TasmotaSerial-3.2.0 => TasmotaSerial-3.3.0}/README.md (100%) rename lib/default/{TasmotaSerial-3.2.0 => TasmotaSerial-3.3.0}/examples/swsertest/swsertest.ino (100%) rename lib/default/{TasmotaSerial-3.2.0 => TasmotaSerial-3.3.0}/keywords.txt (100%) rename lib/default/{TasmotaSerial-3.2.0 => TasmotaSerial-3.3.0}/library.json (94%) rename lib/default/{TasmotaSerial-3.2.0 => TasmotaSerial-3.3.0}/library.properties (94%) rename lib/default/{TasmotaSerial-3.2.0 => TasmotaSerial-3.3.0}/src/TasmotaSerial.cpp (94%) rename lib/default/{TasmotaSerial-3.2.0 => TasmotaSerial-3.3.0}/src/TasmotaSerial.h (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30b7395a0..02e2ce7b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. ### Changed - TuyaMcu dimmer timeout (#11121) +- TasmotaSerial library from v3.2.0 to v3.3.0 ### Fixed - Refactor acceleration function for shutter stepper and servo (#11088) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f02d78da4..ba3720df4 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -87,6 +87,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota ### Changed - TuyaMcu dimmer timeout [#11121](https://github.com/arendst/Tasmota/issues/11121) +- TasmotaSerial library from v3.2.0 to v3.3.0 ### Fixed - Refactor acceleration function for shutter stepper and servo [#11088](https://github.com/arendst/Tasmota/issues/11088) diff --git a/lib/default/TasmotaSerial-3.2.0/README.md b/lib/default/TasmotaSerial-3.3.0/README.md similarity index 100% rename from lib/default/TasmotaSerial-3.2.0/README.md rename to lib/default/TasmotaSerial-3.3.0/README.md diff --git a/lib/default/TasmotaSerial-3.2.0/examples/swsertest/swsertest.ino b/lib/default/TasmotaSerial-3.3.0/examples/swsertest/swsertest.ino similarity index 100% rename from lib/default/TasmotaSerial-3.2.0/examples/swsertest/swsertest.ino rename to lib/default/TasmotaSerial-3.3.0/examples/swsertest/swsertest.ino diff --git a/lib/default/TasmotaSerial-3.2.0/keywords.txt b/lib/default/TasmotaSerial-3.3.0/keywords.txt similarity index 100% rename from lib/default/TasmotaSerial-3.2.0/keywords.txt rename to lib/default/TasmotaSerial-3.3.0/keywords.txt diff --git a/lib/default/TasmotaSerial-3.2.0/library.json b/lib/default/TasmotaSerial-3.3.0/library.json similarity index 94% rename from lib/default/TasmotaSerial-3.2.0/library.json rename to lib/default/TasmotaSerial-3.3.0/library.json index caaa9f6f7..f6d1aaaeb 100644 --- a/lib/default/TasmotaSerial-3.2.0/library.json +++ b/lib/default/TasmotaSerial-3.3.0/library.json @@ -1,6 +1,6 @@ { "name": "TasmotaSerial", - "version": "3.2.0", + "version": "3.3.0", "keywords": [ "serial", "io", "TasmotaSerial" ], diff --git a/lib/default/TasmotaSerial-3.2.0/library.properties b/lib/default/TasmotaSerial-3.3.0/library.properties similarity index 94% rename from lib/default/TasmotaSerial-3.2.0/library.properties rename to lib/default/TasmotaSerial-3.3.0/library.properties index 30cc6138c..6b43764a6 100644 --- a/lib/default/TasmotaSerial-3.2.0/library.properties +++ b/lib/default/TasmotaSerial-3.3.0/library.properties @@ -1,5 +1,5 @@ name=TasmotaSerial -version=3.2.0 +version=3.3.0 author=Theo Arends maintainer=Theo Arends sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32. diff --git a/lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp similarity index 94% rename from lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.cpp rename to lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp index d49a5ff2a..253c3094b 100644 --- a/lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.cpp @@ -109,16 +109,27 @@ bool TasmotaSerial::isValidGPIOpin(int pin) { return (pin >= -1 && pin <= 5) || (pin >= 12 && pin <= 15); } -bool TasmotaSerial::begin(long speed, int stop_bits) { - m_stop_bits = ((stop_bits -1) &1) +1; +bool TasmotaSerial::begin(uint32_t speed, uint32_t config) { + 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_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) { #ifdef ESP8266 Serial.flush(); - if (2 == m_stop_bits) { - Serial.begin(speed, SERIAL_8N2); - } else { - Serial.begin(speed, SERIAL_8N1); - } + Serial.begin(speed, (SerialConfig)config); if (m_hardswap) { Serial.swap(); } @@ -131,11 +142,7 @@ bool TasmotaSerial::begin(long speed, int stop_bits) { m_uart = tasmota_serial_index; tasmota_serial_index--; TSerial = new HardwareSerial(m_uart); - if (2 == m_stop_bits) { - TSerial->begin(speed, SERIAL_8N2, m_rx_pin, m_tx_pin); - } else { - TSerial->begin(speed, SERIAL_8N1, m_rx_pin, m_tx_pin); - } + TSerial->begin(speed, config, m_rx_pin, m_tx_pin); if (serial_buffer_size > 256) { TSerial->setRxBufferSize(serial_buffer_size); } @@ -154,10 +161,6 @@ bool TasmotaSerial::begin(long speed, int stop_bits) { return m_valid; } -bool TasmotaSerial::begin(void) { - return begin(TM_SERIAL_BAUDRATE); -} - bool TasmotaSerial::hardwareSerial(void) { #ifdef ESP8266 return m_hardserial; diff --git a/lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h similarity index 97% rename from lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.h rename to lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h index 432344321..3a90626fe 100644 --- a/lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.3.0/src/TasmotaSerial.h @@ -40,8 +40,7 @@ class TasmotaSerial : public Stream { TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE); virtual ~TasmotaSerial(); - bool begin(long speed, int stop_bits = 1); - bool begin(void); + bool begin(uint32_t speed = TM_SERIAL_BAUDRATE, uint32_t config = SERIAL_8N1); bool hardwareSerial(void); int peek(void);