From 2fd63ff01faab81fe91d02495151db968b7fcb34 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 28 Dec 2022 14:07:30 +0100 Subject: [PATCH] Fix Modbus transmit enable GPIO Fix Modbus transmit enable GPIO enabled once during write buffer --- CHANGELOG.md | 1 + RELEASENOTES.md | 5 +++++ .../TasmotaSerial-3.6.0/src/TasmotaSerial.cpp | 9 +++------ .../TasmotaSerial-3.6.0/src/TasmotaSerial.h | 1 - .../TasmotaModbus-3.6.0/src/TasmotaModbus.cpp | 15 ++++++++++++++- .../TasmotaModbus-3.6.0/src/TasmotaModbus.h | 1 + 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 569c21eb8..36db85b30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Shutter default motorstop set to 0 (#17403) - Shutter default tilt configuration (#17484) +- Modbus transmit enable GPIO enabled once during write buffer ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index cd293173a..064b3f00f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -111,8 +111,12 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Added - Support for up to 3 single phase modbus energy monitoring device using generic Energy Modbus driver- Support for RGB displays [#17414](https://github.com/arendst/Tasmota/issues/17414) - Support for IPv6 DNS records (AAAA) and IPv6 ``Ping`` for ESP32 and ESP8266 [#17417](https://github.com/arendst/Tasmota/issues/17417) +- Support for IPv6 only networks on Ethernet (not yet Wifi) - Berry support for ``crypto.SHA256`` [#17430](https://github.com/arendst/Tasmota/issues/17430) - Berry crypto add ``EC_P256`` and ``PBKDF2_HMAC_SHA256`` algorithms required by Matter protocol [#17473](https://github.com/arendst/Tasmota/issues/17473) +- Berry crypto add ``random`` to generate series of random bytes +- Berry crypto add ``HKDF_HMAC_SHA256`` +- Berry crypto add ``SPAKE2P_Matter`` for Matter support ### Breaking Changed @@ -122,6 +126,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Tasmota OTA scripts now support both unzipped and gzipped file uploads [#17378](https://github.com/arendst/Tasmota/issues/17378) ### Fixed +- Modbus transmit enable GPIO enabled once during write buffer - Shutter default motorstop set to 0 [#17403](https://github.com/arendst/Tasmota/issues/17403) - Shutter default tilt configuration [#17484](https://github.com/arendst/Tasmota/issues/17484) diff --git a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp index f334073a5..d690c62eb 100644 --- a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp @@ -46,7 +46,6 @@ static uint32_t tasmota_serial_uart_bitmap = 0; // Assigned UARTs TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size) { m_valid = false; - m_tx_enable_valid = false; m_hardserial = false; m_hardswap = false; m_overflow = false; @@ -56,6 +55,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal serial_buffer_size = buffer_size; m_rx_pin = receive_pin; m_tx_pin = transmit_pin; + m_tx_enable_pin = -1; m_in_pos = 0; m_out_pos = 0; #ifdef ESP8266 @@ -134,12 +134,9 @@ bool TasmotaSerial::isValidGPIOpin(int pin) { void TasmotaSerial::setTransmitEnablePin(int tx_enable_pin) { if ((tx_enable_pin > -1) && isValidGPIOpin(tx_enable_pin)) { - m_tx_enable_valid = true; m_tx_enable_pin = tx_enable_pin; pinMode(m_tx_enable_pin, OUTPUT); digitalWrite(m_tx_enable_pin, LOW); - } else { - m_tx_enable_valid = false; } } @@ -425,7 +422,7 @@ void IRAM_ATTR TasmotaSerial::_fast_write(uint8_t b) { size_t TasmotaSerial::write(uint8_t b) { if (!m_hardserial && (-1 == m_tx_pin)) { return 0; } - if (m_tx_enable_valid) { + if (m_tx_enable_pin > -1) { digitalWrite(m_tx_enable_pin, HIGH); } size_t size = 0; @@ -462,7 +459,7 @@ size_t TasmotaSerial::write(uint8_t b) { } size = 1; } - if (m_tx_enable_valid) { + if (m_tx_enable_pin > -1) { delay(1); digitalWrite(m_tx_enable_pin, LOW); } diff --git a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h index cf93f3443..c41282004 100644 --- a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h @@ -95,7 +95,6 @@ class TasmotaSerial : public Stream { uint32_t m_out_pos; uint32_t serial_buffer_size = TM_SERIAL_BUFFER_SIZE; bool m_valid; - bool m_tx_enable_valid; bool m_nwmode; bool m_hardserial; bool m_hardswap; diff --git a/lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.cpp b/lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.cpp index 4860e6b84..baf66f8b0 100644 --- a/lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.cpp +++ b/lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.cpp @@ -29,7 +29,13 @@ enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_D TasmotaModbus::TasmotaModbus(int receive_pin, int transmit_pin, int tx_enable_pin) : TasmotaSerial(receive_pin, transmit_pin, 2) { - setTransmitEnablePin(tx_enable_pin); +// setTransmitEnablePin(tx_enable_pin); + mb_tx_enable_pin = tx_enable_pin; + if (mb_tx_enable_pin > -1) { + pinMode(mb_tx_enable_pin, OUTPUT); + digitalWrite(mb_tx_enable_pin, LOW); + } + mb_address = 0; } @@ -150,7 +156,14 @@ uint8_t TasmotaModbus::Send(uint8_t device_address, uint8_t function_code, uint1 #endif flush(); + if (mb_tx_enable_pin > -1) { + digitalWrite(mb_tx_enable_pin, HIGH); + } write(frame, framepointer); + if (mb_tx_enable_pin > -1) { + delay(1); + digitalWrite(mb_tx_enable_pin, LOW); + } free(frame); return 0; } diff --git a/lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.h b/lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.h index ced5fb969..7997ae329 100644 --- a/lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.h +++ b/lib/lib_basic/TasmotaModbus-3.6.0/src/TasmotaModbus.h @@ -66,6 +66,7 @@ class TasmotaModbus : public TasmotaSerial { uint8_t ReceiveCount(void) { return mb_len; } private: + int mb_tx_enable_pin; uint8_t mb_address; uint8_t mb_len; };