A library that allows your Arduino to communicate via Modbus protocol, acting as a slave (master in development). Supports serial (RS-232, RS-485) and IP via Ethernet (Modbus IP).
I am doing a coding test using Arduino board.
Unwanted results occur during testing.
If you try to read data remotely after inserting m_Modbus.Ists value, an error occurs in multiples of 8.
I think that the Modbus.cpp file contains an error in the void Modbus :: readInputStatus () function.
please check.
Temporarily modifying and testing as below.
`#if 0
while (numregs--) {
i = (totregs - numregs) / 8;
if (this->Ists(startreg))
bitSet(_frame[2+i], bitn);
else
bitClear(_frame[2+i], bitn);
//increment the bit index
bitn++;
if (bitn == 8) bitn = 0;
//increment the register
startreg++;
}
else
do{
i = (totregs - numregs) / 8;
if (this->Ists(startreg))
bitSet(_frame[2+i], bitn);
else
bitClear(_frame[2+i], bitn);
//increment the bit index
bitn++;
if (bitn == 8) bitn = 0;
//increment the register
startreg++;
} while (numregs--);
I am doing a coding test using Arduino board. Unwanted results occur during testing. If you try to read data remotely after inserting m_Modbus.Ists value, an error occurs in multiples of 8. I think that the Modbus.cpp file contains an error in the void Modbus :: readInputStatus () function. please check.
![di error 1](https://user-images.githubusercontent.com/53113079/61577073-34d0a100-ab1d-11e9-9da6-4ea04e28c700.PNG)
Temporarily modifying and testing as below.
`#if 0 while (numregs--) { i = (totregs - numregs) / 8; if (this->Ists(startreg)) bitSet(_frame[2+i], bitn); else bitClear(_frame[2+i], bitn); //increment the bit index bitn++; if (bitn == 8) bitn = 0; //increment the register startreg++; }
else
endif`