mirror of https://github.com/arendst/Tasmota.git
Fix exception 9 when modbus tx enable is used
This commit is contained in:
parent
2e1f8fd756
commit
c1484f761c
|
@ -460,7 +460,7 @@ size_t TasmotaSerial::write(uint8_t b) {
|
||||||
size = 1;
|
size = 1;
|
||||||
}
|
}
|
||||||
if (m_tx_enable_pin > -1) {
|
if (m_tx_enable_pin > -1) {
|
||||||
delay(1);
|
delayMicroseconds(800); // delay(1) will exception here
|
||||||
digitalWrite(m_tx_enable_pin, LOW);
|
digitalWrite(m_tx_enable_pin, LOW);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
|
|
|
@ -31,11 +31,6 @@ TasmotaModbus::TasmotaModbus(int receive_pin, int transmit_pin, int tx_enable_pi
|
||||||
{
|
{
|
||||||
// setTransmitEnablePin(tx_enable_pin);
|
// setTransmitEnablePin(tx_enable_pin);
|
||||||
mb_tx_enable_pin = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +59,10 @@ int TasmotaModbus::Begin(long speed, uint32_t config)
|
||||||
if (begin(speed, config)) {
|
if (begin(speed, config)) {
|
||||||
result = 1;
|
result = 1;
|
||||||
if (hardwareSerial()) { result = 2; }
|
if (hardwareSerial()) { result = 2; }
|
||||||
|
if (mb_tx_enable_pin > -1) {
|
||||||
|
pinMode(mb_tx_enable_pin, OUTPUT);
|
||||||
|
digitalWrite(mb_tx_enable_pin, LOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +160,7 @@ uint8_t TasmotaModbus::Send(uint8_t device_address, uint8_t function_code, uint1
|
||||||
}
|
}
|
||||||
write(frame, framepointer);
|
write(frame, framepointer);
|
||||||
if (mb_tx_enable_pin > -1) {
|
if (mb_tx_enable_pin > -1) {
|
||||||
delay(1);
|
delayMicroseconds(800); // delay(1) will exception here
|
||||||
digitalWrite(mb_tx_enable_pin, LOW);
|
digitalWrite(mb_tx_enable_pin, LOW);
|
||||||
}
|
}
|
||||||
free(frame);
|
free(frame);
|
||||||
|
|
Loading…
Reference in New Issue