Skip to main content
Read the digital input state of GPIO pins, with optional blocking wait for a target level.

Syntax

Arguments

Options


Usage

Basic Read

Wait for Level

Block until a pin reaches a target level. Useful for waiting on hardware events like button presses, interrupt lines, or device ready signals.

Advanced Streaming Options

For LabJack T7 hardware, the --wait-for command uses high-speed streaming to detect level changes. You can tune the streaming parameters:

Output

Basic Read

Returns the digital state:
  • 0 - Low (0V)
  • 1 - High (3.3V or 5V depending on hardware)

Wait for Level

Returns the elapsed time in seconds when the target level is reached:
If the timeout expires before the target level is reached, the command exits with an error.

Supported Hardware

The pin column lists the exact channel tokens that lager nets add accepts. On a multi-channel FTDI part, the net’s interface selects channel A, B, C or D.

LabJack U3 Pins

  • FIO0-FIO3 are not offered as gpio channels. On a U3-HV they are fixed high-voltage analog inputs. Read them with an adc net on AIN0-AIN3.
  • Lager treats every U3 as a U3-HV, so a U3-LV also loses these four digital lines.
  • A U3 reads a pin without a change to its direction. A write sets the pin to output.
  • FIO4-FIO7 and EIO0-EIO7 are also analog inputs. A gpio read sets the pin to digital mode, and an adc read sets it back to analog mode.
  • A gpio net saved on FIO0-FIO3 before version 0.46.1 still lists, but fails when you use it. Delete that net.

Aardvark Pin Mapping

The Aardvark I2C/SPI adapter exposes 6 GPIO pins on its 10-pin header. Give the signal name as the channel:

FT232H Pin Mapping

The FT232H and FT2232H offer 12 GPIO channels. AD0-AD3 are not offered as gpio channels:

Examples



Notes

  • GPI is for reading input pins only
  • Use lager gpo to set output pins
  • Default net can be set with lager defaults add --gpio-net
  • Pin must be configured as input in net configuration
  • USB-202 channels are DIO0-DIO7
  • For a script, use --json: a read gives value (0 or 1) and level, and a wait gives elapsed_s
  • --wait-for blocks the process until the target level is detected or the timeout expires
  • --scan-rate and --scans-per-read only apply to LabJack T7 streaming; they are ignored by other drivers
  • --poll-interval applies to non-streaming drivers (LabJack U3, USB-202, Aardvark, FTDI, YKUSH3); ignored by LabJack T7