Skip to content

Bug fix issue #35 coil indexing #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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