Fix serial initialization

Fix serial initialization for baudrate and config (#16970)
This commit is contained in:
Theo Arends 2022-11-02 11:24:24 +01:00
parent fe6aecc0c3
commit 0632377192
4 changed files with 13 additions and 3 deletions

View File

@ -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 Digital Addressable Lighting Interface (DALI) by Andrei Kazmirtsuk (#16938)
- Support for two phase power calibration using commands ``PowerSet2``, ``VoltageSet2`` and ``CurrentSet2`` - Support for two phase power calibration using commands ``PowerSet2``, ``VoltageSet2`` and ``CurrentSet2``
- Support for NTAG2xx tags read and write on PN532 NFC reader (#16939) - Support for NTAG2xx tags read and write on PN532 NFC reader (#16939)
- Added Berry ``bytes().reverse()`` method - Berry ``bytes().reverse()`` method (#16977)
### Breaking Changed ### Breaking Changed
@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
### Fixed ### Fixed
- Deduplicate code and fix %timer n% rule regression from v12.2.0 (#16914) - Deduplicate code and fix %timer n% rule regression from v12.2.0 (#16914)
- Serial initialization for baudrate and config (#16970)
### Removed ### Removed
- Define ``USE_PN532_DATA_RAW`` from NFC reader (#16939) - Define ``USE_PN532_DATA_RAW`` from NFC reader (#16939)

View File

@ -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 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 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) - 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) - Zigbee router firmware for Sonoff ZBBridgePro [#16900](https://github.com/arendst/Tasmota/issues/16900)
### Breaking Changed ### Breaking Changed
@ -130,6 +131,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
### Fixed ### Fixed
- BP5758D red channel corruption regression from v12.1.1.6 [#16850](https://github.com/arendst/Tasmota/issues/16850) - 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) - 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 ### Removed

View File

@ -516,7 +516,7 @@ void setup(void) {
Settings->baudrate = APP_BAUDRATE / 300; Settings->baudrate = APP_BAUDRATE / 300;
Settings->serial_config = TS_SERIAL_8N1; 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 if (1 == RtcReboot.fast_reboot_count) { // Allow setting override only when all is well
UpdateQuickPowerCycle(true); UpdateQuickPowerCycle(true);

View File

@ -1977,6 +1977,13 @@ void SetSerialBegin(void) {
#endif // ESP32 #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) { void SetSerialConfig(uint32_t serial_config) {
if (serial_config > TS_SERIAL_8O2) { if (serial_config > TS_SERIAL_8O2) {
serial_config = TS_SERIAL_8N1; serial_config = TS_SERIAL_8N1;