mirror of https://github.com/arendst/Tasmota.git
Removed delays in TasmotaSerial and TasmotaModbus Tx enable switching
This commit is contained in:
parent
e375448090
commit
ea6a5a2d4e
|
@ -11,9 +11,11 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
### Changed
|
||||
- Energy totals max supported value from +/-21474.83647 to +/-2147483.647 kWh
|
||||
- Removed delays in TasmotaSerial and TasmotaModbus Tx enable switching
|
||||
|
||||
### Fixed
|
||||
- Energy dummy switched voltage and power regression from v12.2.0.2
|
||||
- Orno WE517 modbus serial config 8E1 setting (#17545)
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -125,6 +125,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||
### Changed
|
||||
- ESP32 Framework (Core) from v2.0.5.3 to v2.0.6 (IPv6 support)
|
||||
- Energy totals max supported value from +/-21474.83647 to +/-2147483.647 kWh
|
||||
- Removed delays in TasmotaSerial and TasmotaModbus Tx enable switching
|
||||
- TuyaMcu rewrite by btsimonh [#17051](https://github.com/arendst/Tasmota/issues/17051)
|
||||
- Tasmota OTA scripts now support both unzipped and gzipped file uploads [#17378](https://github.com/arendst/Tasmota/issues/17378)
|
||||
|
||||
|
@ -134,5 +135,6 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||
- ESP8266 set GPIO's to input on power on fixing relay spikes [#17531](https://github.com/arendst/Tasmota/issues/17531)
|
||||
- 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)
|
||||
- Orno WE517 modbus serial config 8E1 setting [#17545](https://github.com/arendst/Tasmota/issues/17545)
|
||||
|
||||
### Removed
|
||||
|
|
|
@ -424,7 +424,6 @@ size_t TasmotaSerial::write(uint8_t b) {
|
|||
|
||||
if (m_tx_enable_pin > -1) {
|
||||
digitalWrite(m_tx_enable_pin, HIGH);
|
||||
delayMicroseconds(10); // delay(1) will exception here
|
||||
}
|
||||
size_t size = 0;
|
||||
if (m_hardserial) {
|
||||
|
@ -461,7 +460,6 @@ size_t TasmotaSerial::write(uint8_t b) {
|
|||
size = 1;
|
||||
}
|
||||
if (m_tx_enable_pin > -1) {
|
||||
delayMicroseconds(10); // delay(1) will exception here
|
||||
digitalWrite(m_tx_enable_pin, LOW);
|
||||
}
|
||||
return size;
|
||||
|
|
|
@ -27,10 +27,15 @@ enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_D
|
|||
|
||||
//#define TASMOTAMODBUSDEBUG
|
||||
|
||||
#define TASMOTA_MODBUS_TX_ENABLE // Use local Tx enable on write buffer
|
||||
|
||||
TasmotaModbus::TasmotaModbus(int receive_pin, int transmit_pin, int tx_enable_pin) : TasmotaSerial(receive_pin, transmit_pin, 2)
|
||||
{
|
||||
// setTransmitEnablePin(tx_enable_pin);
|
||||
mb_tx_enable_pin = tx_enable_pin;
|
||||
#ifdef TASMOTA_MODBUS_TX_ENABLE
|
||||
mb_tx_enable_pin = tx_enable_pin; // Use local Tx enable on write buffer
|
||||
#else
|
||||
setTransmitEnablePin(tx_enable_pin); // Use TasmotaSerial Tx enable on write byte
|
||||
#endif // TASMOTA_MODBUS_TX_ENABLE
|
||||
mb_address = 0;
|
||||
}
|
||||
|
||||
|
@ -59,10 +64,12 @@ int TasmotaModbus::Begin(long speed, uint32_t config)
|
|||
if (begin(speed, config)) {
|
||||
result = 1;
|
||||
if (hardwareSerial()) { result = 2; }
|
||||
#ifdef TASMOTA_MODBUS_TX_ENABLE
|
||||
if (mb_tx_enable_pin > -1) {
|
||||
pinMode(mb_tx_enable_pin, OUTPUT);
|
||||
digitalWrite(mb_tx_enable_pin, LOW);
|
||||
}
|
||||
#endif // TASMOTA_MODBUS_TX_ENABLE
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -148,22 +155,25 @@ uint8_t TasmotaModbus::Send(uint8_t device_address, uint8_t function_code, uint1
|
|||
buf = (uint8_t *)malloc(bufsize);
|
||||
memset(buf, 0, bufsize);
|
||||
uint16_t i;
|
||||
for (i = 0; i < framepointer;i++)
|
||||
for (i = 0; i < framepointer;i++) {
|
||||
snprintf((char *)&buf[i*3], (bufsize-i*3), "%02X ",frame[i]);
|
||||
}
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MBS: Serial Send: %s"), buf);
|
||||
free(buf);
|
||||
#endif
|
||||
|
||||
flush();
|
||||
#ifdef TASMOTA_MODBUS_TX_ENABLE
|
||||
if (mb_tx_enable_pin > -1) {
|
||||
digitalWrite(mb_tx_enable_pin, HIGH);
|
||||
delayMicroseconds(10); // delay(1) will exception here
|
||||
}
|
||||
#endif // TASMOTA_MODBUS_TX_ENABLE
|
||||
write(frame, framepointer);
|
||||
#ifdef TASMOTA_MODBUS_TX_ENABLE
|
||||
if (mb_tx_enable_pin > -1) {
|
||||
delayMicroseconds(10); // delay(1) will exception here
|
||||
digitalWrite(mb_tx_enable_pin, LOW);
|
||||
}
|
||||
#endif // TASMOTA_MODBUS_TX_ENABLE
|
||||
free(frame);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue