Problem with reading 8 byte unsigned modbus data
-
I am reading an 8 byte modbus parameters and it seems to be returning the least significant byte as a zero. Has anyone else had this issue?
-
It's only zero'ing a byte, not a register? Here's the code that would be doing the transformation from the byte array over the wire to a number for the consumer: https://github.com/infiniteautomation/modbus4j/blob/master/Modbus4J/src/com/serotonin/modbus4j/locator/NumericLocator.java
If you actually mean the register (two bytes) then I would wonder if you documentation is 1-indexed and your offsets need to be shifted by 1 as Mango is 0-indexed.
If you do indeed mean a single byte, then I wonder if that was something bizarre with the device.
-
If I simply read the registers from the device, I get back what I expect. If I split the read into two 4 byte unsigned reads, then the data is correct in each part. I actually wrote the device code and am sure it works as intended.
One more question: Is it possible to access the actual array of bytes read from the device if the point data is set to a fixed length string?
This would really simplify my script processing of special data types.Thanks!
Malcolm
-
Hmm. Well, I'll think about it more but I'm fairly confident Modbus4J handles it properly.
Yeah you should be able to unpack the string the same way you packed it.
Edit: My recommendation, to prove what you're saying, would be to disable all the points on your modbus data source, the enable IO logging and the two points as 4 byte variants. Do the read, disable the points. Enable the 8 byte single point, do a read. Post the resultant IO log.