Ubus call modbus_client not working anymore

This used to work on previous firmware:

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

Now it returns:
Command failed: Not found

Why?

Good afternoon,

A few observations from your query:

The newer firmware versions have changed the Modbus client CLI interface.
Change your command to use modbus_client.rpc serial.test instead of modbus_client serial.test.
Make sure parameters like serial_type start with a slash: "/dev/rs485".
Use integer values for numeric parameters like baudrate, databits, stopbits, timeout, etc., not strings.

Example of a corrected command :

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

Regards,
Arturas

Hello,

Thanks for your fast response. I have done the changes you wrote:
ubus call modbus_client.rpc serial.test '{"id":1,"timeout":1,"function":4,"first_reg":1,"reg_count":1,"data_type":"16bit_int_hi_first","no_brackets":1,"serial_type":"/dev/rs485","baudrate":19200,"databits":8,"stopbits":1,"parity":"none","flowcontrol":"none"}'

Now I get:

{
        "error": 1,
        "result": "failed to parse arguments: Argument ('reg_count') is missing."
}

That is very interesting.

Just for the record, I am using a TRB145

Hi there,

Your error is caused by the reg_count parameter being sent as a number instead of a string. Changing "reg_count": 1 to "reg_count": "1" should resolve the issue.

Confirm your device path /dev/rs485 is correct and accessible.

Regards,
Arturas

thanks, this now works:
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"}'

answer is: 
{
        "error": 0,
        "result": "278,306"
}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.