TRB145, help needed with ubus calls

Hello,

I am trying to use ubus calls to read data from MODBUS RTU units connected to the TRB145.

When I had firmware TRB1_R_00.07.05.1, this used to work:

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

I upgraded to TRB1_R_00.07.07.1, and it doesn’t work anymore.

What us the problem?
By the way, is there somewhere a description of the ubus command for the TRB145? I can’t find it.

Thanks

Hello,

Parameter naming changed a bit instead of flowctrl it became flowcontrol. Try changing in your command and it should work.

Best regards,

Hello Marijus,

Thanks now it works.

But if I send this, it still doesn’t work:

ubus call modbus_client serial.test ‘{“id”:4,“timeout”:1,“function”:4,“first_reg”:301,“reg_count”:“1”,“data_type”:“32bit INT, Byte order 1,2,3,4”,“no_brackets”:1,“serial_type”:“/dev/rs485”,“baudrate”:9600,“databits”:8,“stopbits”:1,“parity”:“None”,“flowcontrol”:“None”}’

What shall I do? I just changed the requested data-type.

Could you please also send me a link to the documentation of the ubus command? I suppose it exists somewhere at Teltonika.

Regards,

Hello,

I don’t have any documentation to give you, but I can assist you in resolving the issue you’ve encountered.

Firstly, the function code 4 stands for “Read Input Registers.” Since you mentioned that you want to read data, this number should be changed to 3. Here’s what the other numbers mean:

  • 1: Read Coils
  • 2: Read Discrete Inputs
  • 3: Read Holding Registers
  • 4: Read Input Registers

Additionally, make sure to set the “data_type” to the required format, as this could also affect reading from registers. If you still are encountering issues, please copy the command you are trying to execute and the error output too.

Best regards,

Hello Marijus,

The Modbus RTU unit that I want to read is a Seneca 24DI and it answers to both function code 3 or function code 4. So the problem is not with the function code. But I tried as you suggested, still get the following:

call:

ubus call modbus_client serial.test ‘{“id”:4,“timeout”:1,“function”:3,“first_reg”:301,“reg_count”:“1”,“data_type”:“32bit INT, Byte order 1,2,3,4”,“no_brackets”:1,“serial_type”:“/dev/rs485”,“baudrate”:9600,“databits”:8,“stopbits”:1,“parity”:“None”,“flowcontrol”:“None”}’

answer:

{
        "error": -1,
        "result": "Failed to get response: No error information"
}

But if I try it from the WEBUI, it works! I also attached printscreens to show that it works from the WEBUI


.

Regards,

Hello,

Problem solved, instead of “data_type”:“32bit INT, Byte order 1,2,3,4”, “data_type”:“32bit_uint1234” should be used. For anyone that bumps into this problem, here is the solution. The available data types are the following:

          "8bit_int",
          "8bit_uint",
          "16bit_int_hi_first",
          "16bit_int_low_first",
          "16bit_uint_hi_first",
          "16bit_uint_low_first",
          "32bit_float1234",
          "32bit_float4321",
          "32bit_float2143",
          "32bit_float3412",
          "32bit_int1234",
          "32bit_int4321",
          "32bit_int2143",
          "32bit_int3412",
          "32bit_uint1234",
          "32bit_uint4321",
          "32bit_uint2143",
          "32bit_3412",
          "ascii",
          "hex",
          "bool"

If you use any of these data types, the ubus call will work. This can be checked in one of the source files of RUTOS sdk, namely in 03_modbus_serial_request.json.

Regards,

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

Hello,

Thank you for sharing the solution!

Kind regards,