RUT955 Read and Write RS485 from CLI

Hello,

I am trying to read and write data using the CLI on the RUT955 running latest firmware.

I can successfully read data from two connected rs485 sensors.

Read Commands:

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


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

Results:

root@Teltonika-RUT955:~# ubus call modbus_client serial.test '{"id":1,"timeout":1,"function":3,"first_reg":3,"reg_count"
:"4","data_type":"16bit_int_hi_first","no_brackets":0,"serial_type":"/dev/rs485","baudrate":9600,"databits":8,"stopbits"
:1,"parity":"none","flowcontrol":"none"}'

{
        "error": 0,
        "result": "[0,0,7040,998]"
}
root@Teltonika-RUT955:~# ubus call modbus_client serial.test '{"id":2,"timeout":1,"function":3,"first_reg":4,"reg_count"
:"1","data_type":"16bit_int_hi_first","no_brackets":0,"serial_type":"/dev/rs485","baudrate":9600,"databits":8,"stopbits"
:1,"parity":"none","flowcontrol":"none"}'

{
        "error": 0,
        "result": "[152]"
}
root@Teltonika-RUT955:~#

However I am having issues sending write request to a rensor, for example this is the command to open a value of a valve control sensor.

02 10 00 01 00 01 02 23 28 BE AF

Write Command

ubus call modbus_client serial.test '{"id":2,"timeout":1,"function":16,"first_reg":1,"reg_count":"1","data":[9000],"data_type":"16bit_int_hi_first","no_brackets":0,"serial_type":"/dev/rs485","baudrate":9600,"databits":8,"stopbits":1,"parity":"none","flowcontrol":"none"}'

Response

root@Teltonika-RUT955:~# ubus call modbus_client serial.test '{"id":2,"timeout":1,"function":16,"first_reg":1,"reg_count
":"4","data":[9000],"data_type":"16bit_int_hi_first","no_brackets":0,"serial_type":"/dev/rs485","baudrate":9600,"databit
s":8,"stopbits":1,"parity":"none","flowcontrol":"none"}'

{
        "error": -1,
        "result": "Failed to get response: Operation timed out"
}

Appreciate any help.

Hi there,

To begin with, your timeout value is generally considered too low. In other words, you’d have to increase it from “1” to a bigger value, such as “5” or maybe even “10” seconds. The reason I’m pointing this out is due to the operation timing out, as per the provided error message.

One more test - could you try writing a single register instead of multiple? Change your function value to 6 instead of 16

Regards,
M.