E-Sharp Helpcenter
Breadcrumbs

Wait command

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

Bash
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

Bash
wait --channel "READY_FLAG" --value "1"

Wait with Custom Timeout

Bash
wait --channel "STATUS" --value "IDLE" --timeout 5000

Wait for Voltage Stabilization

Bash
wait -c "VOUT" -v "3.3" -t 10000

Wait for String Match

Bash
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

  1. Starts a timer

  2. Continuously reads the channel value (every 10ms)

  3. Compares value to expected value (exact match)

  4. Returns immediately when match found

  5. 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

Bash
# Wait for initialization to complete
init --host 192.168.1.100
wait -c "INIT_COMPLETE" -v "1" -t 5000

Synchronize Operations

Bash
# 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

Bash
# Wait for voltage to settle
set -c "VOUT_TARGET" -v "1.8"
wait -c "VOUT_STABLE" -v "true" -t 2000

Boot Sequence

Bash
# 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 list

  • Not connected: Run init command first

Best Practices

  1. Set Reasonable Timeouts

    Bash
    # Fast digital signals
    wait -c "FLAG" -v "1" -t 100
    
    # Slow initialization
    wait -c "BOOT_COMPLETE" -v "READY" -t 30000
    
  2. Verify Expected Values

    Bash
    # Check current value first
    get -c "STATUS"
    # Then wait for change
    wait -c "STATUS" -v "ACTIVE" -t 5000
    
  3. Chain Operations

    Bash
    set -c "TRIGGER" -v "1"
    wait -c "BUSY" -v "0" -t 1000
    get -c "RESULT"
    

Notes

  • Requires an active connection (use init first)

  • Blocking operation (no other commands execute during wait)

  • Use appropriate timeouts to avoid hanging

  • Consider using hardware interrupts for critical timing