Logic Machine Forum
Modbus Script Multiple registers work in script, but not in profile - 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 Script Multiple registers work in script, but not in profile (/showthread.php?tid=4814)



Modbus Script Multiple registers work in script, but not in profile - Morten L - 07.06.2023

Here is the script
Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('192.168.0.100', 502)
mb:connect()
mb:setslave(1)


res, err = mb:writemultipleregisters(1003, 4)
log(res,err)

mb:close()

Here is the profile
Code:
{
    "manufacturer": "Nilan",
    "description": "Nilan CTS602",
    "mapping": [
    { "name": "Speed setting", "bus_datatype": "uint16", "type": "register", "address": 1003, "writable": 1, "write_multiple": 1}
]
}


The script can write and change the speed value

The profile can then read that the script has changed the value, verified by looking at the ventilation display.

The profile can not be used to write, and if i change the object value, it just jumps back to what it was and nothing happens on the display.

So the script clearly writes and the profile clearly reads.
I have to use multiple registers per the manual to get write permission.

What am i missing here?


RE: Modbus Script Multiple registers work in script, but not in profile - admin - 07.06.2023

Your profile entry is missing "datatype": "uint16"


RE: Modbus Script Multiple registers work in script, but not in profile - Morten L - 07.06.2023

Thank you, that solved it.

Is it because of the write_multiple that you need to define the datatype ?


RE: Modbus Script Multiple registers work in script, but not in profile - admin - 07.06.2023

Yes, for write_multiple to work datatype must be either int16 or uint16.