Skip to content

Commit 58874db

Browse files
committed
Reduce size (queue management)
1 parent 44f146d commit 58874db

File tree

1 file changed

+0
-15
lines changed

1 file changed

+0
-15
lines changed

arduino-modbus-rtu-tcp-gateway/02-modbus-tcp.ino

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,6 @@ void processRequests() {
169169
queueHasRespondingSlaves = false;
170170
}
171171
}
172-
while (queueHasRespondingSlaves == true && getSlaveResponding(queueHeaders.first().uid) == false) {
173-
// move requests to non responding slaves to the tail of the queue
174-
for (byte i = 0; i < queueHeaders.first().PDUlen; i++) {
175-
queuePDUs.push(queuePDUs.shift());
176-
}
177-
queueRetries.push(queueRetries.shift());
178-
queueHeaders.push(queueHeaders.shift());
179-
}
180172
serialState = SENDING; // trigger sendSerial()
181173
}
182174
}
@@ -196,13 +188,6 @@ byte checkRequest(byte buffer[], unsigned int bufferSize) {
196188
return 0xFF; // reject: do nothing and return no error code
197189
}
198190
}
199-
if (queueHeaders.isEmpty() == false && getSlaveResponding(address) == false) { // allow only one request to non responding slaves
200-
for (byte j = queueHeaders.size(); j > 0; j--) { // start searching from tail because requests to non-responsive slaves are usually towards the tail of the queue
201-
if (queueHeaders[j - 1].uid == address) {
202-
return 0x0B; // return modbus error 11 (Gateway Target Device Failed to Respond) - usually means that target device (address) is not present
203-
}
204-
}
205-
}
206191
// check if we have space in request queue
207192
if (queueHeaders.available() < 1 || (localConfig.enableRtuOverTcp && queuePDUs.available() < bufferSize - 1) || (!localConfig.enableRtuOverTcp && queuePDUs.available() < bufferSize - 7)) {
208193
return 0x06; // return modbus error 6 (Slave Device Busy) - try again later

0 commit comments

Comments
 (0)