Ubus modbus serial command on RUT956

Firmware: RUT9M_R_00.07.18.3

Hi, I have a weird issue that when issuing ubus call modbus_client.rpc serial.test jsons for writing a single number, the response is always

{
        "error": 0,
        "result": "OK"
}

but there is no write happening on the modbus device!

I have tried with both modbus_client enabled and disabled on the webui; I also tried disabling the uci modbus client with

uci set modbus_client.main.enabled='0'

but still no luck.

Any ideas how to troubleshoot this odd behaviour?

For reference here are the commands I’m using

  1. successful read command
ubus call modbus_client.rpc serial.test '{"id":204,"timeout":1,"function":4,"first_reg":1,"reg_count":"125","data_type":"hex","no_brackets":1,"serial_type":"/dev/rs485","baudrate":19200,"databits":8,"stopbits":1,"parity":"even","flowcontrol":"none","broadcast":1}'
  1. A commands that returns OK, but doesn’t write:
ubus call modbus_client.rpc serial.test '{"id":204,"timeout":1,"function":6,"first_reg":22,"reg_count":"1","data_type":"hex","no_brackets":1,"serial_type":"/dev/rs485","baudrate":19200,"databits":8,"stopbits":1,"parity":"even","flowcontrol":"none","broadcast":1}'

I have also tried the following variations:

"function":16
"data":['${value}'] 
"data_type":"16bit_int_hi_first"

Any ideas what to try next? Many thanks

Hi there,

Tested this out locally, was able to reproduce quite easily. Will have to report to our R&D. If I’ll have any news or comments on this, I’ll get back to you.

Regards,
M.

Many thanks, Matas, let me know what comes back from R&D.

Any way to write a value over modbus would be helpful if ubus modbus write is not available at the moment. Python (minimalmodbus on a TRB145) works, but this is code destined for TRB246, so I don’t have python. My lua efforts gives me Couldn't connect: No such file or directory`, exactly the same as Lua-libmodbus on TRB145 - #7 by MichalPankau . ChatGPT suggested creating a Modbus Tag for each write, but I have yet to find out how.

Hey,

What about using API? Teltonika Networks Web API

Would this work for you?

Hi, as the user above suggested, you can utilize API calls, or you could also achieve the same result by utilizing the WebUI “Test” button, unless automation is what you’re looking for. When it comes to custom scripts / programming, we as technical support are unable to provide efficient support as we don’t work with them.

Regards,
M.

Thanks both,

yes, API calls works for our automation scripts - for proof of concept I set up a new modbus device on the WebUI with individual requests for a few individual writes and created API calls to successfully trigger those with cURL calls from within the router SSH session.

The key information I needed was that the write itself is called Test, thank you Matas.

Marking this thread as solved

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