I'm using this library to monitor some integers. I found some errors and after some debug it seems that ReadInputRegisters returns always an array even if had some problems during it executions.
from what I checked in the implementation, it create the response array and after return it, even if data values are not correct:
response = new int[quantity];
for (int i = 0; i < quantity; i++)
{
byte lowByte;
byte highByte;
highByte = data[9+i2];
lowByte = data[9+i2+1];
Here is my debug watchs, after the instruction
int[] registers = client.ReadInputRegisters(bMap.from, bMap.lenght);
Note that registers return values as exepcted, but some times it cames all with 0
Watchs:
registers {int[5]} int[]
[0] 0 int
[1] 0 int
[2] 0 int
[3] 0 int
[4] 0 int
Baudrate 9600 int
Connected true bool
ConnectionTimeout 1000 int
IPAddress "xx.xx.xx.xx" string
LogFileFilename null string
NumberOfRetries 3 int
Parity Even System.IO.Ports.Parity
Port 502 int
SerialPort 'client.SerialPort' threw an exception of type 'System.NullReferenceException' string {System.NullReferenceException}
StopBits One System.IO.Ports.StopBits
UDPFlag false bool
UnitIdentifier 1 byte
receiveData null byte[]
sendData null byte[]
I'm using this library to monitor some integers. I found some errors and after some debug it seems that ReadInputRegisters returns always an array even if had some problems during it executions. from what I checked in the implementation, it create the response array and after return it, even if data values are not correct: response = new int[quantity]; for (int i = 0; i < quantity; i++) { byte lowByte; byte highByte; highByte = data[9+i2]; lowByte = data[9+i2+1];
Here is my debug watchs, after the instruction int[] registers = client.ReadInputRegisters(bMap.from, bMap.lenght); Note that registers return values as exepcted, but some times it cames all with 0
Watchs:
registers {int[5]} int[] [0] 0 int [1] 0 int [2] 0 int [3] 0 int [4] 0 int