mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-28 21:23:06 +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;
|
break;
|
||||||
}
|
}
|
||||||
if (error == MODBUS_RTU_MASTER_WAITING) {
|
if (error == MODBUS_RTU_MASTER_WAITING) {
|
||||||
if (_waitCounter > 10) {
|
if (_waitCounter > 10) { // retry after 10 cycles of waiting.
|
||||||
_resetWaiting();
|
_resetWaiting();
|
||||||
_waitCounter = 0;
|
_waitCounter = 0;
|
||||||
|
_waitCounterB++;
|
||||||
} else {
|
} else {
|
||||||
_waitCounter++;
|
_waitCounter++;
|
||||||
}
|
}
|
||||||
|
if (_waitCounterB > 10) { // move on to next node if fails 10 times.
|
||||||
|
_waitCounter = 0;
|
||||||
|
_waitCounterB = 0;
|
||||||
|
_operationCount = 0;
|
||||||
|
_currentNode = _currentNode->getNext();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_waitCounter = 0;
|
_waitCounter = 0;
|
||||||
|
_waitCounterB = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error != MODBUS_RTU_MASTER_WAITING) {
|
if (error != MODBUS_RTU_MASTER_WAITING) {
|
||||||
if (_operationCount < 3) {
|
if (_operationCount < 3) {
|
||||||
_operationCount++;
|
_operationCount++;
|
||||||
|
@ -316,6 +316,8 @@ private:
|
|||||||
ModbusRTUMasterError _readValues(uint8_t id, uint8_t functionCode, uint16_t startAddress, uint16_t buf[], uint16_t quantity);
|
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);
|
ModbusRTUMasterError _writeSingleValue(uint8_t id, uint8_t functionCode, uint16_t address, uint16_t value);
|
||||||
int _waitCounter = 0;
|
int _waitCounter = 0;
|
||||||
|
int _waitCounterB = 0;
|
||||||
|
|
||||||
void _resetWaiting() {
|
void _resetWaiting() {
|
||||||
_rtuComm._waiting_for_read = false;
|
_rtuComm._waiting_for_read = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user