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