Community discussions

MikroTik App
 
User avatar
DenSyo77
just joined
Topic Author
Posts: 24
Joined: Tue Jan 09, 2024 10:38 am
Contact:

Function iot modbus read-holding-registers is not processed in on-error

Wed Jan 10, 2024 3:21 am

I don't know if this is a bug or how it should be. When the device is turned on, the script works correctly, displays the state of the registers and a message "finish".
: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"
When the device is turned off the script ends with messages:
interrupted
poll timeout

Function iot modbus transceive successfully processed in on-error when the device is turned off
: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"

Who is online

Users browsing this forum: No registered users and 5 guests