Skip to content

Wait Until ​

Purpose: read repeatedly until the value meets a condition, the device starts responding, or the device stops responding. Typically used to wait for a device to boot or for an action to finish.

Wait Until settings

Wait Until has the same read fields as Read, plus:

FieldWhat it sets
Compare= equals, ≠ not equal, In range, and two communication-only choices: Any answer (met when the device responds) and No response (met when the device stops responding)
Give up afterThe longest to wait. 0 means no limit
Check everyHow often to read

JSON ​

json
{ "wait_until": { "address": "0x0200", "expected": 5, "timeout_ms": 2000, "interval_ms": 100 } }
{ "wait_until": { "address": "0x0200", "compare": false, "timeout_ms": 0 } }
{ "wait_until": { "channel": "B", "address": "0x0000", "no_response": true, "timeout_ms": 3000 } }
FieldRequiredMeaning
Read and compare fields—Same as Read (address, expected, compare_op, range, tolerance, store…)
timeout_msNoDefault 3000. 0 means no limit. At most 3600000 (1 hour)
interval_msNoDefault 100. At least 10
compareNofalse = Any answer: met when the device responds
no_responseNotrue = No response: met when the device stops responding

Result ​

ResultWhen
PASSThe condition is met in time
FAILTime runs out while the device responds but the value never matches; or, with No response, the device keeps responding
DISCONNECTTime runs out and the device never responded at all

No response while waiting is not a failure: the step keeps waiting, because the device may still be booting.

Example ​

About the example: channel B deliberately points at 127.0.0.1:1503, where there is no device, and on_error is continue.

CaseWhat it doesResult
Met at onceWrites 5, then waits for 0x0200 == 5, which holds on the first readPASS
Times outWaits for 0x0200 == 6, which does not happen within 1 secondFAIL
Any answerWaits only for the device to respondPASS
No responseWaits for channel B to stop responding (there is no device there)PASS

Wait Until example result

In Times out, the Actual column shows the last value read and timed out after 1000 ms.

Notes ​

  • timeout_ms: 0 waits forever, so make sure the condition will be met, or be ready to click Stop.
  • Full power-cycle tests are covered in the Script examples and in the sample library's Power cycle.json.

Download the sample script ​

Sample script

Before running it, start a Slave window on 127.0.0.1:502 and click Listen, then open the script with Open JSON in Script mode and click Run. See How to use the examples.

Roach Modbus Tool by Mr.Roach