Major issue with new firmware

Hello.
I have been using the ubus library on many teltonika router to remotely setup and calibrate modbus device. However with the new firmware update the ubus library has become completely useless and doesn’t even try to read a modbus register.

This is the results im getting. As you can see the only thing being returned is a counter value. The reason why I believe the ubus library isn’t even trying to read a modbus register is because if I switch of the modbus device then it keeps returning the counter value. I have tested my code with the same modbus device but with a new router that hasn’t been updated yet and there I am getting the correct results. Please look into this issue because this is a major problem for me. Rolling back to old firmware is also not an option for me because the device gets reset, causing me to lose access to devices that are in remote locations.

Hello,

Unfortunately, ubus commands were always used internally and at your own risk, without a guarantee that shell commands or their output would remain unchanged. The latest 7.13.1 firmware release is an example where ubus command output has changed, and there is no way to revert this behavior.

Instead of ubus, we strongly recommend using API calls, which provide a more reliable and structured approach. You can find all necessary details for API Modbus calls here:

:link: Modbus API Documentation

Best regards,

Hello,
Thank you for your response. So if I understand you correctly I can use the API calls to read my modbus device using custom scripts?
I might be missing it but I am not seeing this information in the document you added.

Kind regards,

Hello,
unfortunately using the API would not be an option as it is incredibly slow. I need to read 6 registers every 10 seconds then send them to a server using mqtt. Ubus was excellent at doing this so I don’t understand as to why it would be removed.

Hi,

Separate API requests have a lot of overhead. To remove it use less calls as some endpoints supports getting array of data instead of single object or if it does not - call all endpoints in single bulk request.

Also If you are using API inside scripts running on router you can use API command. This probably wont speed up execution but is much more comfortable way to use it

e.g. (change with your status calling endpoints) api POST /bulk "{'data': [{'method': 'GET', 'endpoint': '/api/interfaces/basic/status'}]}"

For anyone that still has this issue basically the solution was to make to ubus calls. One to modbus_client.rpc serial.test then a second one to modbus_client.rpc request_status. The first ubus call just returns an Id value for the modbus request then the second returns the modbus value for that Id value.
Here’s a demo code to help:
#!/bin/ash

REQUEST_ID=$(ubus call modbus_client.rpc serial.test ‘{“id”:1,“timeout”:5,“function”:3,“first_reg”:421,“reg_count”:“2”,“data_type”:“32bit_int1234”,“no_brackets”:1,“serial_type”:“/dev/rs485”,“baudrate”:9600,“databits”:8,“stopbits”:1,“parity”:“None”,“flowcontrol”:“None”}’ | grep -o ‘“result”: “[^”]"’ | cut -d’"’ -f4)

echo “Request ID:$REQUEST_ID”
if [ -z “$REQUEST_ID” ]; then
echo “Failed to get request ID”
fi

RESPONSE=$(ubus call modbus_client.rpc request_status “{"id":$REQUEST_ID}"” | grep -o ‘“result”: “[^”]"’ | cut -d’"’ -f4)

if [ -n “$RESPONSE” ]; then
echo “Modbus Value: $RESULT”
fi