I create a custom script to read Modbus slaves and then control them with this script:
------------------------------------------------------------------
#!/bin/ash
Temp=3
GSt=1
while true
do
Temp=$(modbus_serial_request_test rs485 1 1 4 8 1 16bit_int_hi_first 0)
GSt=$(modbus_serial_request_test rs485 1 1 4 1 1 16bit_uint_hi_first 0)
if [ $GSt -gt 10 ]
then
modbus_serial_request_test rs485 1 2 5 1281 65280 16bit_uint_hi_first 0
else
modbus_serial_request_test rs485 1 2 5 1283 65280 16bit_uint_hi_first 0
fi
sleep 2
done
---------------------------------------------------------------------------------
But when I retrieve a value from the Modbus slave and store it in a variable, it is stored in the form [20]. So the If statement could not read this value and the result was " [20] is out of range".
it should be only 20, without [ ].
Is there any solution for this problem?