mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-27 12:48:52 +01:00
IO_Modbus: move next after failure
This commit is contained in:
parent
9837cff4a5
commit
a31b671ea0
@ -555,15 +555,24 @@ void Modbus::_loop(unsigned long currentMicros) {
|
||||
break;
|
||||
}
|
||||
if (error == MODBUS_RTU_MASTER_WAITING) {
|
||||
if (_waitCounter > 10) {
|
||||
if (_waitCounter > 10) { // retry after 10 cycles of waiting.
|
||||
_resetWaiting();
|
||||
_waitCounter = 0;
|
||||
_waitCounterB++;
|
||||
} else {
|
||||
_waitCounter++;
|
||||
}
|
||||
if (_waitCounterB > 10) { // move on to next node if fails 10 times.
|
||||
_waitCounter = 0;
|
||||
_waitCounterB = 0;
|
||||
_operationCount = 0;
|
||||
_currentNode = _currentNode->getNext();
|
||||
}
|
||||
} else {
|
||||
_waitCounter = 0;
|
||||
_waitCounterB = 0;
|
||||
}
|
||||
|
||||
if (error != MODBUS_RTU_MASTER_WAITING) {
|
||||
if (_operationCount < 3) {
|
||||
_operationCount++;
|
||||
|
@ -316,6 +316,8 @@ private:
|
||||
ModbusRTUMasterError _readValues(uint8_t id, uint8_t functionCode, uint16_t startAddress, uint16_t buf[], uint16_t quantity);
|
||||
ModbusRTUMasterError _writeSingleValue(uint8_t id, uint8_t functionCode, uint16_t address, uint16_t value);
|
||||
int _waitCounter = 0;
|
||||
int _waitCounterB = 0;
|
||||
|
||||
void _resetWaiting() {
|
||||
_rtuComm._waiting_for_read = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user