mirror of https://github.com/arendst/Tasmota.git
Fix Modbus transmit enable GPIO
Fix Modbus transmit enable GPIO enabled once during write buffer
This commit is contained in:
parent
ef4138bdaa
commit
2fd63ff01f
|
@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
|
||||||
### Fixed
|
### Fixed
|
||||||
- Shutter default motorstop set to 0 (#17403)
|
- Shutter default motorstop set to 0 (#17403)
|
||||||
- Shutter default tilt configuration (#17484)
|
- Shutter default tilt configuration (#17484)
|
||||||
|
- Modbus transmit enable GPIO enabled once during write buffer
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,12 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
||||||
### Added
|
### 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 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 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 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 ``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
|
### 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)
|
- Tasmota OTA scripts now support both unzipped and gzipped file uploads [#17378](https://github.com/arendst/Tasmota/issues/17378)
|
||||||
|
|
||||||
### Fixed
|
### 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 motorstop set to 0 [#17403](https://github.com/arendst/Tasmota/issues/17403)
|
||||||
- Shutter default tilt configuration [#17484](https://github.com/arendst/Tasmota/issues/17484)
|
- Shutter default tilt configuration [#17484](https://github.com/arendst/Tasmota/issues/17484)
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size) {
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
m_tx_enable_valid = false;
|
|
||||||
m_hardserial = false;
|
m_hardserial = false;
|
||||||
m_hardswap = false;
|
m_hardswap = false;
|
||||||
m_overflow = false;
|
m_overflow = false;
|
||||||
|
@ -56,6 +55,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal
|
||||||
serial_buffer_size = buffer_size;
|
serial_buffer_size = buffer_size;
|
||||||
m_rx_pin = receive_pin;
|
m_rx_pin = receive_pin;
|
||||||
m_tx_pin = transmit_pin;
|
m_tx_pin = transmit_pin;
|
||||||
|
m_tx_enable_pin = -1;
|
||||||
m_in_pos = 0;
|
m_in_pos = 0;
|
||||||
m_out_pos = 0;
|
m_out_pos = 0;
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
@ -134,12 +134,9 @@ bool TasmotaSerial::isValidGPIOpin(int pin) {
|
||||||
|
|
||||||
void TasmotaSerial::setTransmitEnablePin(int tx_enable_pin) {
|
void TasmotaSerial::setTransmitEnablePin(int tx_enable_pin) {
|
||||||
if ((tx_enable_pin > -1) && isValidGPIOpin(tx_enable_pin)) {
|
if ((tx_enable_pin > -1) && isValidGPIOpin(tx_enable_pin)) {
|
||||||
m_tx_enable_valid = true;
|
|
||||||
m_tx_enable_pin = tx_enable_pin;
|
m_tx_enable_pin = tx_enable_pin;
|
||||||
pinMode(m_tx_enable_pin, OUTPUT);
|
pinMode(m_tx_enable_pin, OUTPUT);
|
||||||
digitalWrite(m_tx_enable_pin, LOW);
|
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) {
|
size_t TasmotaSerial::write(uint8_t b) {
|
||||||
if (!m_hardserial && (-1 == m_tx_pin)) { return 0; }
|
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);
|
digitalWrite(m_tx_enable_pin, HIGH);
|
||||||
}
|
}
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
@ -462,7 +459,7 @@ size_t TasmotaSerial::write(uint8_t b) {
|
||||||
}
|
}
|
||||||
size = 1;
|
size = 1;
|
||||||
}
|
}
|
||||||
if (m_tx_enable_valid) {
|
if (m_tx_enable_pin > -1) {
|
||||||
delay(1);
|
delay(1);
|
||||||
digitalWrite(m_tx_enable_pin, LOW);
|
digitalWrite(m_tx_enable_pin, LOW);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,6 @@ class TasmotaSerial : public Stream {
|
||||||
uint32_t m_out_pos;
|
uint32_t m_out_pos;
|
||||||
uint32_t serial_buffer_size = TM_SERIAL_BUFFER_SIZE;
|
uint32_t serial_buffer_size = TM_SERIAL_BUFFER_SIZE;
|
||||||
bool m_valid;
|
bool m_valid;
|
||||||
bool m_tx_enable_valid;
|
|
||||||
bool m_nwmode;
|
bool m_nwmode;
|
||||||
bool m_hardserial;
|
bool m_hardserial;
|
||||||
bool m_hardswap;
|
bool m_hardswap;
|
||||||
|
|
|
@ -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)
|
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;
|
mb_address = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +156,14 @@ uint8_t TasmotaModbus::Send(uint8_t device_address, uint8_t function_code, uint1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flush();
|
flush();
|
||||||
|
if (mb_tx_enable_pin > -1) {
|
||||||
|
digitalWrite(mb_tx_enable_pin, HIGH);
|
||||||
|
}
|
||||||
write(frame, framepointer);
|
write(frame, framepointer);
|
||||||
|
if (mb_tx_enable_pin > -1) {
|
||||||
|
delay(1);
|
||||||
|
digitalWrite(mb_tx_enable_pin, LOW);
|
||||||
|
}
|
||||||
free(frame);
|
free(frame);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ class TasmotaModbus : public TasmotaSerial {
|
||||||
uint8_t ReceiveCount(void) { return mb_len; }
|
uint8_t ReceiveCount(void) { return mb_len; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int mb_tx_enable_pin;
|
||||||
uint8_t mb_address;
|
uint8_t mb_address;
|
||||||
uint8_t mb_len;
|
uint8_t mb_len;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue