Modbus int16 negative numbers conversion - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10) +--- Thread: Modbus int16 negative numbers conversion (/showthread.php?tid=3939) |
Modbus int16 negative numbers conversion - flajzi - 20.03.2022 Hello, I'm running home solar system. I'm trying to read electricity consumption (positive number) or supplying electricity to grid (negative number) from registry over Modbus TCP connection. Victron manual says it is signed int16. Positive numbers are shown correctly, but I have problems with negative numbers using profile in Modbus section. When I repeately run script reading Victron registry, manually convert uint to int16, it's ok. Code: if not mb then Log correctly shows: Code: modbus1 20.03.2022 14:05:01 Then I have created this profile: Code: { But using this profile when it reads negative number, it mostly shows 32767 (0x7FFFF) in object value. I tried all read_swap options but with no success. Does anynone has any idea, what is wrong with this profile? RE: Modbus int16 negative numbers conversion - admin - 21.03.2022 "datatype:" field has a typo, it should be "datatype" RE: Modbus int16 negative numbers conversion - flajzi - 21.03.2022 Thanks a lot! I spent many hours solving this issue and I'm just blind... |