GPIO: read, drive, and pulse¶
GPIO helpers live on AqProtocolExerciser: they talk directly to the instrument’s GPIO layer (not to a bus device). Import enums and GPIO protobuf types from aqpxlib or aqpxlib.gpio—you do not need aqpxlib.message for typical scripts.
from aqpxlib import AqProtocolExerciser, PxIoState
with AqProtocolExerciser.connect(host="localhost", port=60600) as px:
...
Typed reference: GPIO (API).
Logical levels (PxIoState)¶
Use PxIoState when driving or interpreting states:
| Member | Meaning |
|---|---|
PxIoState.LOW |
Driven or sampled low |
PxIoState.HIGH |
Driven or sampled high |
PxIoState.HIGH_Z |
High impedance (not actively driven) |
Read pin state (get_gpio_state)¶
The exerciser returns status for all pins; the library selects gpio_idx and returns a single PxGpioPinState with:
| Field | Meaning |
|---|---|
pin_idx |
Pin index (echo of hardware indexing) |
output_state |
Level the instrument is driving (None / unset if not driving) |
input_state |
Last sampled input level (None / unset if unavailable) |
If gpio_idx is negative or past the last pin in the response, the library raises ValueError.
Drive a static level (set_gpio_state)¶
This sends a set state operation for one pin. If that GPIO is already assigned to another protocol on the instrument, the server may reject the request.
There is no Python-side restriction on gpio_idx here (unlike pulse); valid indices depend on hardware and firmware.
Send a pulse (send_gpio_pulse)¶
Emit one pulse: idle → active foractive_time_ns→ idle.
px.send_gpio_pulse(
gpio_idx=8,
active_state=PxIoState.HIGH,
idle_state=PxIoState.LOW,
active_time_ns=5000,
)
| Constraint | Detail |
|---|---|
| Pins | Only gpio_idx 8 or 9 (same as width-trigger tooling). |
| Width | active_time_ns must be greater than 5 ns and less than 1 second (1_000_000_000 ns). |
See also: GPIO width trigger for set_gpio_trigger and the gpio_trigger global event.
Related GPIO (API).