wait - Wait for Channel Value
Description
The wait command monitors a channel until it reaches a specific value or until a timeout occurs. This is useful for synchronization and waiting for hardware state changes.
Syntax
wait --channel <channel_name> --value <expected_value> [options]
Required Options
| Option | Short | Description |
|---|---|---|
--channel |
-c |
The name or alias of the channel to monitor |
--value |
-v |
The expected value to wait for |
Optional Options
| Option | Short | Description | Default |
|---|---|---|---|
--timeout |
-t |
Maximum time to wait in milliseconds | 1000 |
Examples
Wait for Ready Flag
wait --channel "READY_FLAG" --value "1"
Wait with Custom Timeout
wait --channel "STATUS" --value "IDLE" --timeout 5000
Wait for Voltage Stabilization
wait -c "VOUT" -v "3.3" -t 10000
Wait for String Match
wait -c "DEVICE_STATE" -v "INITIALIZED" -t 30000
Output Format
Success
READY_FLAG reached [1] after 234.56 ms
Timeout
STATUS didn't reach [IDLE] within the timeout
Output Colors
- Green: Successful match
- Red: Timeout occurred
Behavior
- Starts a timer
- Continuously reads the channel value (every 10ms)
- Compares value to expected value (exact match)
- Returns immediately when match found
- Throws timeout error if time limit exceeded
Polling Interval
The command polls the channel every 10 milliseconds for changes.
Use Cases
Wait for Device Ready
# Wait for initialization to complete
init --host 192.168.1.100
wait -c "INIT_COMPLETE" -v "1" -t 5000
Synchronize Operations
# Trigger operation and wait for completion
set -c "START_CONVERSION" -v "1"
wait -c "CONVERSION_DONE" -v "1" -t 1000
get -c "CONVERSION_RESULT"
Wait for Stable State
# Wait for voltage to settle
set -c "VOUT_TARGET" -v "1.8"
wait -c "VOUT_STABLE" -v "true" -t 2000
Boot Sequence
# Wait for multiple boot stages
wait -c "BOOT_STAGE" -v "1" -t 1000
wait -c "BOOT_STAGE" -v "2" -t 2000
wait -c "BOOT_STAGE" -v "3" -t 3000
Value Matching
The command performs exact string matching:
"1"matches"1"but not"1.0"or"true""3.3"matches"3.3"but not"3.30"or"3.3000"- Case-sensitive for strings
- Leading/trailing whitespace is preserved
Timeout Behavior
- Default timeout: 1000ms (1 second)
- Minimum polling interval: 10ms
- Maximum checks: timeout รท 10ms
- Timeout throws exception (displays in red)
Performance Considerations
| Timeout | Maximum Polls |
|---|---|
| 100ms | 10 |
| 1000ms | 100 |
| 10000ms | 1000 |
- Each poll involves network communication
- Faster channels respond quicker
- Network latency affects polling rate
- CPU usage is minimal
Error Handling
Common errors:
Timeout: Channel didn't reach expected value
- Increase timeout value
- Verify expected value is correct
- Check if hardware is responding
Channel not found: Verify channel name with
listNot connected: Run
initcommand first
Best Practices
Set Reasonable Timeouts
# Fast digital signals wait -c "FLAG" -v "1" -t 100 # Slow initialization wait -c "BOOT_COMPLETE" -v "READY" -t 30000Verify Expected Values
# Check current value first get -c "STATUS" # Then wait for change wait -c "STATUS" -v "ACTIVE" -t 5000Chain Operations
set -c "TRIGGER" -v "1" wait -c "BUSY" -v "0" -t 1000 get -c "RESULT"
Notes
- Requires an active connection (use
initfirst) - Blocking operation (no other commands execute during wait)
- Use appropriate timeouts to avoid hanging
- Consider using hardware interrupts for critical timing