Hi
This is a follow up on
Basically i need to send data and request data from a connected serial modbus device, but i am having some issues. Summary of the previous post is that the devices requires triggering to take a reading, but this causes occasional collisions when using the UI services to do this.
I was reccomended to write a script, but i am unable to get it to work in the cli.
There are several modbus devices (sensors) connected to the trb145. I have set it up in the user interface and it works fine (details below)
device created
device details
slave devices (there are more, but these are the ones being tested)
Trigger slave details
This works fine when tested
read slave details (using ConductivityTemperature as example)
All of these works fine when testing here
I have tried to follow the instructions i have found (primarily here: TRB245 Modbus RTU registers)
I ended up with the following command for triggering a measurement
ubus call modbus_master serial.test "{'serial_type': '/dev/rs485', 'baudrate': 9600, 'databits': 8, 'stopbits': 1, 'parity': 'None', 'flowctrl': 'None', 'timeout': 5, 'id': 30, 'function': 6, 'first_reg': 2, 'reg_count': '31', 'data_type': '16bit_int_hi_first', 'no_brackets': 1}"
and the following command for reading
ubus call modbus_master serial.test "{‘serial_type’: ‘/dev/rs485’, ‘baudrate’: 9600, ‘databits’: 8, ‘stopbits’: 1, 'parity': 'None', 'flowctrl': 'None', 'timeout': 5, 'id': 30, 'function': 3, 'first_reg': 83, 'reg_count': '2', 'data_type': '32bit_float4321', 'no_brackets': 1}"
a couple of important notes
- when writing (function: 6) the reg_count is not the amount of registers, but the value to be written (read this on another post: modbus_tcp_test disappeared in firmware RUTX_R_00.07.03 - Crowd Support Forum | Teltonika Networks)
- reg_count needs to be enclosed in quotes
when i run the commands i get failed to create mb context
Other things done to check that everything is running
result of ubus list command (note modbus_master doesn’t show up unless a modbus slave device has been set in the UI)
Checking if the rs485 in /dev/ is there
What could be wrong in this instance?
Best wishes
Larks