Lua-libmodbus on TRB145

Hello,

Apologies for the delay.

Could you please clarify what the intended goal of this Lua script is and elaborate on the script a bit more? As this inquiry is outside of my scope, and I’m not that familiar with Lua scripting, I can only provide you with insights/suggestions to check or try. From the code, I assume you are trying to open an RTU connection on /dev/rs485. Can you confirm if the device /dev/rs485 is actually present and visible under /dev?

Additionally, instead of using a custom Lua script, you can also call the Modbus service directly using ubus commands. For example (change parameters according to your requirements):

ubus call modbus_client.rpc serial.test '{"id":1,"timeout":1,"function":4,"first_reg":2,"reg_count":"2","data_type":"16bit_int_hi_first","no_brackets":1,"serial_type":"/dev/rs485","baudrate":19200,"databits":8,"stopbits":1,"parity":"none","flowcontrol":"none"}'

More useful information and examples for Modbus calls via ubus can be found in related forum topics here:

Best regards,