Skip to content

Commit

Permalink
Merge pull request #1 from JSC-electronics/bugfix/coil-indexing
Browse files Browse the repository at this point in the history
Bug fix issue andresarmento#35 coil indexing
  • Loading branch information
Robert-Faltus authored Jan 22, 2020
2 parents c1ae76a + abd13ab commit 51147cc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libraries/Modbus/Modbus.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Modbus.cpp - Source for Modbus Base Library
Copyright (C) 2014 André Sarmento Barbosa
Copyright (C) 2014 André Sarmento Barbosa
*/
#include "Modbus.h"

Expand Down Expand Up @@ -326,8 +326,9 @@ void Modbus::readCoils(word startreg, word numregs) {
byte bitn = 0;
word totregs = numregs;
word i;
while (numregs--) {
while (numregs) {
i = (totregs - numregs) / 8;
numregs--;
if (this->Coil(startreg))
bitSet(_frame[2+i], bitn);
else
Expand Down Expand Up @@ -377,8 +378,9 @@ void Modbus::readInputStatus(word startreg, word numregs) {
byte bitn = 0;
word totregs = numregs;
word i;
while (numregs--) {
while (numregs) {
i = (totregs - numregs) / 8;
numregs--;
if (this->Ists(startreg))
bitSet(_frame[2+i], bitn);
else
Expand Down

0 comments on commit 51147cc

Please sign in to comment.