I can use mbpoll to poll my modbus temperature and depth sensor using
mbpoll -m RTU -t 4 -a 1 -b 19200 -r 45 -c 16 /dev/ttyUSB1
however when I try to display the data as a float in order to make it legible I get an error. I attempt this using the code
mbpoll -m RTU -t 4:FLOAT -a 1 -b 19200 -r 45 -c 16 /dev/ttyUSB1
Right now the data is displayed as a figure such as 16824
but It should read something like 22.4
(being degrees C). Using Modbus Poll on my PC I am able to do this by selecting the cell and choosing to display it is a FLOAT AB CD
, so I assumed (probably incorrectly) that this was what I was supposed to do in MBPOLL.
Thanks!
Expanding on the answer in the comments in case someone finds this in the future:
When using modpoll
with floating point numbers (e.g. -t 4:FLOAT
) two 16 bit registers will be combined to output each 32 bit floating point value. This may mean that modpoll
is requesting more registers (32) than expected. The result may be an error if non-existent registers, at the end of the range, are being requested (I'd expect exception 2 - ILLEGAL DATA ADDRESS
). This can be resolved by reducing the number of values requested.
I believe you will also need -B (Big Endian) but that would not cause an error (just an unexpected result).