This is adding to my post above, just confirmed there is something wrong with pollmb.py (to be fair it hasn’t been updated in nearly 3 years )
after running “pollmb.py -h 127.0.0.1 -p 502 -t 2 -f 16 -a 05 -q 2 -d 42C8999A”
use this to read it back: http://www.modbusdriver.com/modpoll.html - it’ll tell you it’s been set to 100, not 100.3
root@web:~# ./modpoll -m tcp -t4:float -r 05 -c 2 -1 127.0.0.1
modpoll 3.4 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2013 proconX Pty Ltd
Visit http://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: MODBUS/TCP
Slave configuration...: address = 1, start reference = 5, count = 2
Communication.........: 127.0.0.1, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 32-bit float, output (holding) register table
-- Polling slave...
[5]: 100.000000
[7]: 0.000000
this agrees with all my other hardware and software…pollmb.py and openhab are the only things that think it’s actually 100.3?
reading them back as uint16 shows that pollmb.py is not setting the first register in a way that is legal with the modbus spec? modpoll, CAS scanner etc all show the first register in the float pair as a value of 0
root@web:~# ./modpoll -m tcp -t 3 -r 05 -c 2 -1 127.0.0.1
Protocol configuration: MODBUS/TCP
Slave configuration...: address = 1, start reference = 5, count = 2
Communication.........: 127.0.0.1, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table
-- Polling slave...
[5]: 0
[6]: 17096
EDIT AGAIN: well it seems I may have found the issue, pollmb.py and openhab are using an address offset of 1 and not 0 like everything else. if you use modpoll, you’ll see pollmb.py set to register 05 is actually writing the float pair to 06 and 07, one higher.
If you run “./modpoll -m tcp -t 3:hex -r 06 -c 2 -1 127.0.0.1” you’ll see the hex values that should be at 5 and 6 are at 6 and 7. However oddly when I compensate for this and try to read a float value starting at 6 with “./modpoll -m tcp -t4:float -r 06 -c 2 -1 127.0.0.1” it returns 0
what is going on!?!?!?!
EDIT 900: it seems pollmb.py and openhab are swapping the two register values used for float as well, that’s why I recieve an error trying to read it back. if you both compensate for the 1 offset and not 0 (so poll register 6), and tell modpoll the values are backwards by using the flag -f for “big indian” mode, it retrieves the correct value
root@web:~# ./modpoll -m tcp -t4:float -r 06 -c 1 -1 127.0.0.1 -f
modpoll 3.4 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2013 proconX Pty Ltd
Visit http://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: MODBUS/TCP
Slave configuration...: address = 1, start reference = 6, count = 1
Communication.........: 127.0.0.1, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 32-bit float, output (holding) register table
Word swapping.........: Slave configured as big-endian float machine
-- Polling slave...
[6]: 100.300003
I’m going to go through my openhab.cfg, lower all my start offsets by 1, and change the mode to “float32_swap” and I guess that’ll fix it? This is the first software I’ve ran into that needed swapped values. What a journey!