From 0632377192d63d4b9678391e0b6a9be87fa69af9 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 2 Nov 2022 11:24:24 +0100 Subject: [PATCH] Fix serial initialization Fix serial initialization for baudrate and config (#16970) --- CHANGELOG.md | 3 ++- RELEASENOTES.md | 4 +++- tasmota/tasmota.ino | 2 +- tasmota/tasmota_support/support.ino | 7 +++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e4175b87..cd5d59493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file. - Support for Digital Addressable Lighting Interface (DALI) by Andrei Kazmirtsuk (#16938) - Support for two phase power calibration using commands ``PowerSet2``, ``VoltageSet2`` and ``CurrentSet2`` - Support for NTAG2xx tags read and write on PN532 NFC reader (#16939) -- Added Berry ``bytes().reverse()`` method +- Berry ``bytes().reverse()`` method (#16977) ### Breaking Changed @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Deduplicate code and fix %timer n% rule regression from v12.2.0 (#16914) +- Serial initialization for baudrate and config (#16970) ### Removed - Define ``USE_PN532_DATA_RAW`` from NFC reader (#16939) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 3177f027d..ab0e97a8a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -115,7 +115,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - Support for up to four DS18x20 GPIOs by md5sum-as [#16833](https://github.com/arendst/Tasmota/issues/16833) - Support for Digital Addressable Lighting Interface (DALI) by Andrei Kazmirtsuk [#16938](https://github.com/arendst/Tasmota/issues/16938) - Support for NTAG2xx tags read and write on PN532 NFC reader [#16939](https://github.com/arendst/Tasmota/issues/16939) -- Berry add `bytes().setbytes()` [#16892](https://github.com/arendst/Tasmota/issues/16892) +- Berry ``bytes().setbytes()`` method [#16892](https://github.com/arendst/Tasmota/issues/16892) +- Berry ``bytes().reverse()`` method [#16977](https://github.com/arendst/Tasmota/issues/16977) - Zigbee router firmware for Sonoff ZBBridgePro [#16900](https://github.com/arendst/Tasmota/issues/16900) ### Breaking Changed @@ -130,6 +131,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo ### Fixed - BP5758D red channel corruption regression from v12.1.1.6 [#16850](https://github.com/arendst/Tasmota/issues/16850) - Deduplicate code and fix %timer n% rule regression from v12.2.0 [#16914](https://github.com/arendst/Tasmota/issues/16914) +- Serial initialization for baudrate and config [#16970](https://github.com/arendst/Tasmota/issues/16970) ### Removed diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 707f95771..c0652c563 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -516,7 +516,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 + SetSerialInitBegin(); // Reset serial interface if current baudrate and/or config is different from requested settings if (1 == RtcReboot.fast_reboot_count) { // Allow setting override only when all is well UpdateQuickPowerCycle(true); diff --git a/tasmota/tasmota_support/support.ino b/tasmota/tasmota_support/support.ino index 3dbebd6e0..f082a2206 100755 --- a/tasmota/tasmota_support/support.ino +++ b/tasmota/tasmota_support/support.ino @@ -1977,6 +1977,13 @@ void SetSerialBegin(void) { #endif // ESP32 } +void SetSerialInitBegin(void) { + TasmotaGlobal.baudrate = Settings->baudrate * 300; + if ((GetSerialBaudrate() != TasmotaGlobal.baudrate) || (TS_SERIAL_8N1 != Settings->serial_config)) { + SetSerialBegin(); + } +} + void SetSerialConfig(uint32_t serial_config) { if (serial_config > TS_SERIAL_8O2) { serial_config = TS_SERIAL_8N1;