Skip to content

GPIO

GPIO readback, static drive, timed pulses, and pulse-width trigger configuration live on AqProtocolExerciser. Import enums and value types from aqpxlib.gpio and the trigger event from aqpxlib.event—not from aqpxlib.message.

Public exports

Name Kind Use
GpioState enum Levels for set_gpio_state, pulse edges, and reported pin state (PxIoState alias)
GpioWidthTriggerMode enum set_gpio_trigger(..., mode=...) (PxGpioWidthTriggerMode alias)
GpioPinState dataclass Return type of get_gpio_state (PxGpioPinState alias)
GpioWidthTriggerConfig dataclass Return type of get_gpio_trigger

GpioState

Logical level for one GPIO line.

METHOD DESCRIPTION
to_protobuf

Encode as a wire PxIoState enum value.

from_protobuf

Build from a wire PxIoState enum value.

to_protobuf

to_protobuf() -> PxIoState

Encode as a wire PxIoState enum value.

from_protobuf

from_protobuf(value: PxIoState | None) -> GpioState | None

Build from a wire PxIoState enum value.

Logical level for one GPIO line.

Member Meaning
LOW Driven or sampled low
HIGH Driven or sampled high
HIGH_Z High impedance (not actively driven)

GpioWidthTriggerMode

Width-condition selector for set_gpio_trigger.

METHOD DESCRIPTION
to_protobuf

Encode as a wire PxGpioWidthTriggerMode enum value.

from_protobuf

Build from a wire PxGpioWidthTriggerMode enum value.

to_protobuf

to_protobuf() -> PxGpioWidthTriggerMode

Encode as a wire PxGpioWidthTriggerMode enum value.

from_protobuf

from_protobuf(value: PxGpioWidthTriggerMode) -> GpioWidthTriggerMode

Build from a wire PxGpioWidthTriggerMode enum value.

Width-condition selector for set_gpio_trigger.

Member Meaning
TRIGGER_PULSE_WIDTH_IN_RANGE Fire when width is inside [min_duration_ns, max_duration_ns] (with low_pulse / high_pulse)
TRIGGER_PULSE_WIDTH_OUT_OF_RANGE Fire when width is outside that window

GpioPinState

GpioPinState(
    pin_idx: int,
    output_state: GpioState | None = None,
    input_state: GpioState | None = None,
)

One GPIO pin snapshot from get_gpio_state.

METHOD DESCRIPTION
to_protobuf

Encode as a wire PxGpioPinState message.

from_protobuf

Build from a wire PxGpioPinState message.

to_protobuf

to_protobuf() -> PxGpioPinState

Encode as a wire PxGpioPinState message.

from_protobuf

from_protobuf(msg: PxGpioPinState) -> Self

Build from a wire PxGpioPinState message.

One pin’s snapshot from get_gpio_state(gpio_idx=…).

Field Meaning
pin_idx Pin index
output_state Driven level, if known (None when not driving / unknown)
input_state Sampled input (None when unavailable)

GpioWidthTriggerConfig

GpioWidthTriggerConfig(
    pin_idx: int,
    min_duration_ns: int,
    max_duration_ns: int,
    mode: GpioWidthTriggerMode = TRIGGER_PULSE_WIDTH_IN_RANGE,
    low_pulse: bool = False,
    high_pulse: bool = False,
)

Pulse-width trigger settings for one GPIO pin.

METHOD DESCRIPTION
to_protobuf

Encode as a wire PxGpioWidthTriggerParams message.

from_protobuf

Build from a wire PxGpioWidthTriggerParams message.

to_protobuf

to_protobuf() -> PxGpioWidthTriggerParams

Encode as a wire PxGpioWidthTriggerParams message.

from_protobuf

from_protobuf(msg: PxGpioWidthTriggerParams) -> Self

Build from a wire PxGpioWidthTriggerParams message.

Width-trigger settings returned by get_gpio_trigger(gpio_idx=…).

PxGpioTriggerEvent

PxGpioTriggerEvent(
    *, pin_idx: int = 0, pulse_duration: int = 0, pulse_polarity: bool = False
)

A GPIO width trigger fired.

METHOD DESCRIPTION
from_protobuf

Build from a wire PxGlobalEvent message.

from_protobuf

from_protobuf(msg: PxGlobalEvent) -> Self

Build from a wire PxGlobalEvent message.

Event passed to the gpio_trigger handler (from aqpxlib.event).

Field Meaning
pin_idx Pin that matched
pulse_duration Width in nanoseconds
pulse_polarity Detected polarity

Exerciser methods

AqProtocolExerciser

AqProtocolExerciser(session: PxSession | None = None, **legacy: object)

AqProtocolExerciser class.

Most callers use :meth:connect instead, which builds the session from a transport config and connects it. Pass a session here to supply one yourself: an already-connected session.

PARAMETER DESCRIPTION

session

The :class:~aqpxlib.sessions.PxSession to drive.

TYPE: PxSession | None DEFAULT: None

legacy

Present only so the removed host / port / protocol_version / generation constructor arguments give a clear error instead of a bare TypeError.

TYPE: object DEFAULT: {}

RAISES DESCRIPTION
TypeError

If session is omitted, or if any keyword argument is given.

METHOD DESCRIPTION
get_gpio_state

Read electrical state for one GPIO pin.

set_gpio_state

Drive a static logic level on one GPIO pin.

send_gpio_pulse

Emit one pulse: idle → active_state for active_time_ns → idle_state.

set_gpio_trigger

Configure GPIO pulse-width triggering (fires gpio_trigger global events).

get_gpio_trigger

Get GPIO pulse-width triggering configuration.

get_gpio_state

get_gpio_state(gpio_idx: int) -> GpioPinState

Read electrical state for one GPIO pin.

The instrument returns status for all pins; this method selects gpio_idx.

PARAMETER DESCRIPTION

gpio_idx

Index of the pin to read.

TYPE: int

RETURNS DESCRIPTION
GpioPinState

pin_idx plus optional output_state (driven level)

TYPE: GpioPinState

GpioPinState

and input_state (sampled level).

RAISES DESCRIPTION
ValueError

If gpio_idx is negative or not present in the reply.

set_gpio_state

set_gpio_state(gpio_idx: int, state: GpioState) -> None

Drive a static logic level on one GPIO pin.

PARAMETER DESCRIPTION

gpio_idx

Pin index to drive.

TYPE: int

state

Target level (see GpioState: LOW, HIGH, HIGH_Z).

TYPE: GpioState

Note

The server may reject the operation if the pin is owned by another protocol.

send_gpio_pulse

send_gpio_pulse(
    gpio_idx: int, active_state: GpioState, idle_state: GpioState, active_time_ns: int
) -> None

Emit one pulse: idle → active_state for active_time_ns → idle_state.

Supported only on GPIO indices 8 and 9. Pulse width must be greater than 5 ns and less than 1 second.

PARAMETER DESCRIPTION

gpio_idx

Pin index; must be 8 or 9.

TYPE: int

active_state

Level during the active portion of the pulse.

TYPE: GpioState

idle_state

Level after the pulse completes.

TYPE: GpioState

active_time_ns

Width of the active portion in nanoseconds.

TYPE: int

RAISES DESCRIPTION
ValueError

If gpio_idx is not 8 or 9, or active_time_ns is outside (5, 1_000_000_000).

set_gpio_trigger

set_gpio_trigger(
    gpio_idx: int,
    min_duration_ns: int,
    max_duration_ns: int,
    low_pulse: bool = False,
    high_pulse: bool = False,
    mode: GpioWidthTriggerMode = TRIGGER_PULSE_WIDTH_IN_RANGE,
) -> None

Configure GPIO pulse-width triggering (fires gpio_trigger global events).

Supported only on GPIO indices 8 and 9. Both duration bounds must be greater than 5 ns and less than 1 second.

PARAMETER DESCRIPTION

gpio_idx

Pin index; must be 8 or 9.

TYPE: int

min_duration_ns

Minimum pulse width for the condition (nanoseconds).

TYPE: int

max_duration_ns

Maximum pulse width for the condition (nanoseconds).

TYPE: int

low_pulse

Include low-going pulses when True.

TYPE: bool DEFAULT: False

high_pulse

Include high-going pulses when True.

TYPE: bool DEFAULT: False

mode

TRIGGER_PULSE_WIDTH_IN_RANGE or TRIGGER_PULSE_WIDTH_OUT_OF_RANGE.

TYPE: GpioWidthTriggerMode DEFAULT: TRIGGER_PULSE_WIDTH_IN_RANGE

RAISES DESCRIPTION
ValueError

If gpio_idx is invalid or durations are out of range.

get_gpio_trigger

get_gpio_trigger(gpio_idx: int) -> GpioWidthTriggerConfig | None

Get GPIO pulse-width triggering configuration.

Supported only on GPIO indices 8 and 9.

PARAMETER DESCRIPTION

gpio_idx

Pin index; must be 8 or 9.

TYPE: int

RETURNS DESCRIPTION
GpioWidthTriggerConfig

The configuration of the pin. Returns None if the pin is not configured.

TYPE: GpioWidthTriggerConfig | None