Code: Select all
:local sensorData
:local sensorError
:do {
:set sensorData [/iot modbus read-holding-registers slave-id=3 num-regs=2 reg-addr=0 as-value once]
} on-error={
:set sensorError "not found"
}
:if ([:typeof $sensorError]="nothing") do={
:put ($sensorData->"values")
} else={
:put $sensorError
}
:put "finish"
interrupted
poll timeout
Function iot modbus transceive successfully processed in on-error when the device is turned off
Code: Select all
:local sensorData
:local sensorError
:do {
:set sensorData [/iot modbus transceive address=3 function=3 values=0,0,0,2 as-value]
} on-error={
:set sensorError "not found"
}
:if ([:typeof $sensorError]="nothing") do={
:put ($sensorData->"values")
} else={
:put $sensorError
}
:put "finish"