We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5c20c02 commit 13bc434Copy full SHA for 13bc434
src/Modbus.cpp
@@ -486,7 +486,7 @@ void Modbus::readInputStatus (word startreg, word numregs) {
486
byte bitn = 0;
487
word totregs = numregs;
488
word i;
489
- while (numregs--) {
+ while (numregs) {
490
i = (totregs - numregs) / 8;
491
if (ists (startreg)) {
492
bitSet (_frame[2 + i], bitn);
@@ -495,12 +495,10 @@ void Modbus::readInputStatus (word startreg, word numregs) {
495
bitClear (_frame[2 + i], bitn);
496
}
497
//increment the bit index
498
- bitn++;
499
- if (bitn == 8) {
500
- bitn = 0;
501
- }
+ bitn = (bitn + 1) % 8;
502
//increment the register
503
startreg++;
+ numregs--;
504
505
506
_reply = MB_REPLY_NORMAL;
0 commit comments