### Attach target to bus example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/spi.md Example of creating a PxSPI32BitRegisterTarget and attaching it to a bus. ```python target = PxSPI32BitRegisterTarget(exerciser) target.attach_to_bus(spi_bus) ``` -------------------------------- ### SPI bus and controller usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/spi.md Example of creating a PxSPIBus, attaching a controller, sending data, and sending transactions. ```python spi_bus = PxSPIBus(exerciser, clk=0, miso=1, mosi=2, cs=3) spi_controller = PxSPIController(exerciser) spi_controller.attach_to_bus(spi_bus) resp = spi_controller.send_data([0x90, 0x00, 0x00, 0x00], dummy_count=0) print(resp) # bytes read back from the target txns = spi_controller.send_transactions([ pxmsg.SpiTransaction(mode=0, write_data=b"\x9f", read_data=b"", dummy_count=0, dummy_val=0xFF, should_rise_cs=True), ]) ``` -------------------------------- ### Using connect with send_request and async_request Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/toplevel.md Example using a connected AqProtocolExerciser as a context manager: sends a synchronous request, starts an async request, and retrieves the result with a 5-second timeout. ```python with AqProtocolExerciser.connect() as px: resp = px.send_request(PxProtobufMsg(get_handles_request=TopologyPxHandlesRequest())) fut = px.async_request(PxProtobufMsg(get_handles_request=TopologyPxHandlesRequest())) handles = fut.result(timeout=5) ``` -------------------------------- ### PxUartBus and PxUartTx usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/uart.md Example of creating a PxUartBus, a PxUartTx, attaching it to the bus, and writing bytes. ```python uart_bus = PxUartBus(exerciser, tx=0, rx=1, baud_rate=115200) tx = PxUartTx(exerciser, baud_rate=115200, data_bits=8, stop_bits=1, parity=PxUartParityMode.PARITY_MODE_NONE) tx.attach_to_bus(uart_bus) tx.write_bytes(b"AT\r\n") ``` -------------------------------- ### Electrical configuration usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/abstract-bus.md Example usage of electrical configuration properties on a PxI2CBus instance. Sets voltage and pullup resistance, and prints the la_threshold_voltage. ```python bus = PxI2CBus(px, scl=0, sda=1) bus.voltage = 1800 # mV print(bus.la_threshold_voltage) # int | None bus.pullup_resistance = 4000 # ohms ``` -------------------------------- ### PxUartRx event handling example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/uart.md Example of creating a PxUartRx, attaching it to a bus, and handling the uart_rx_data event. ```python rx = PxUartRx(exerciser, baud_rate=115200) rx.attach_to_bus(uart_bus) @rx.on_event("uart_rx_data") def on_rx(evt): print(evt.data, evt.has_parity_error) ``` -------------------------------- ### connect usage examples Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/toplevel.md Example calls to AqProtocolExerciser.connect: default localhost:60600 v2, legacy host/port/protocol_version kwargs, and explicit PxZMQConfig. The first uses all defaults; the others override transport settings. ```python px = AqProtocolExerciser.connect() # default localhost:60600, v2 px = AqProtocolExerciser.connect(host="10.0.0.5", port=60602, protocol_version="v2") px = AqProtocolExerciser.connect(PxZMQConfig(host="10.0.0.5")) ``` -------------------------------- ### PxZMQSession.connect Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/sessions.md Connects the session to the server, opens the command channel, and starts the event monitor thread. ```APIDOC ## PxZMQSession.connect ### Description Connects the session to the server. Opens the concrete command channel, connects a SUB socket to `tcp://host:port+1`, subscribes to `b""`, and starts the event monitor thread. ### Method `connect(self) -> None` ### Behavior - Opens the command channel via `_open_command_channel`. - Connects SUB socket to `tcp://host:port+1`. - Subscribes to `b""`. - Starts event monitor thread (daemon, poll every 1000 ms). ### Errors - `BackendError` - Raised if the event monitor thread does not start within 10 seconds. ``` -------------------------------- ### Usage example for private transactions Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i3c-controller.md Shows how to initialize the controller, attach to the bus, init the bus at 1200 mV, perform DAA, and then use private_write and private_read. ```python ctrl = PxI3CBaseController(exerciser) ctrl.attach_to_bus(bus) ctrl.init_bus(voltage=1200) ctrl.do_daa() ok = ctrl.private_write(0x20, [0x01, 0x02]) data = ctrl.private_read(0x20, 4) ``` -------------------------------- ### CircuitPython/MicroPython-compatible API usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i2c-common.md Example of using the compatible API to write and read from an I2C device, including handling a NACK with an OSError exception. ```python ctrl.writeto(0x50, b"\x00\xde\xad\xbe\xef") # write without sub-address ctrl.writeto_mem(0x50, 0x00, b"\x01\x02\x03") # write with 8-bit memory address data = ctrl.readfrom_mem(0x50, 0x00, 16, addrsize=8) buf = bytearray(16) ctrl.readfrom_into(0x50, buf) try: ctrl.readfrom(0x51, 1) # address with no target except OSError as e: print("NACK:", e.errno) # errno.EIO ``` -------------------------------- ### PxI3C32BitRegisterTarget usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i3c-targets.md Shows how to create a PxI3C32BitRegisterTarget, attach it to a bus, and after DAA send an IBI request and a hot-join. ```python target = PxI3C32BitRegisterTarget(exerciser, bcr=0x06) target.attach_to_bus(bus) # after DAA: target.ibi_request(ibi_type=target.IbiType.IMMEDIATE, mdb_value=b"\x01", additional_data=b"\xAA\xBB") target.send_hotjoin(target.HotJoinType.ARBITRATED) ``` -------------------------------- ### PWM bus and transmitter example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/pwm-data-generator.md Example usage of PxPwmBus and PxPwmTx. Creates a PWM bus with pin 0, a transmitter with 1 kHz and 25% duty cycle, and attaches the transmitter to the bus. ```python pwm_bus = PxPwmBus(exerciser, pin=0) tx = PxPwmTx(exerciser, period_ns=1_000_000, duty_cycle_ns=250_000) # 1 kHz, 25% duty tx.attach_to_bus(pwm_bus) ``` -------------------------------- ### PxI2CController Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i2c.md Documentation for the PxI2CController class, including its constructor, methods, and usage example. ```APIDOC ## PxI2CController ### Description Controller for I2C bus operations. Inherits from PxAbstractController and PxI2CCommonOperations. ### Constructor ```python def __init__( self, exerciser: "AqProtocolExerciser", *args, config: PxI2CControllerConfig | None = None, **kwargs, ) -> None: ``` When `config` is omitted a `PxI2CControllerConfig(enabled=1)` is used. `I2CControllerConfig` fields: `enabled: int`, `timing: I2CTimingConfig | None`. ### Methods #### send_i2c_transactions ```python def send_i2c_transactions( self, transactions: list[pxmsg.I2CTransaction], *, timeout: int | None = None, ) -> list[pxmsg.I2CTransaction]: ``` Sends a transaction list between START and STOP. Each element is `pxmsg.I2CTransaction` with one of `i2_c_write=I2CWriteTransaction(address, data)` or `i2_c_read=I2CReadTransaction(address, count)` (plus `idle_time`). Returns the response transactions with `is_ack` / `bytes_written` / `data` filled. #### send_transactions ```python def send_transactions(self, transactions: list[pxmsg.I2CTransaction], *, timeout: int | None = None) -> list[pxmsg.I2CTransaction]: ``` Alias for `send_i2c_transactions`. #### scan ```python def scan(self) -> list[int]: ``` ACKs an empty write in [0x08, 0x78) and returns a list of addresses that ACK. #### i2c_scan_all ```python def i2c_scan_all(self) -> list[bool]: ``` Returns a boolean ACK map over addresses 0..127. ### Example ```python i2c_bus = PxI2CBus(exerciser, scl=0, sda=1) i2c_controller = PxI2CController(exerciser) i2c_controller.attach_to_bus(i2c_bus) resp = i2c_controller.send_i2c_transactions([ pxmsg.I2CTransaction(i2_c_write=pxmsg.I2CWriteTransaction(address=0x50, data=b"\x00\xaa")), pxmsg.I2CTransaction(i2_c_read=pxmsg.I2CReadTransaction(address=0x50, count=4)), ]) print(resp[0].i2_c_write.is_ack, resp[1].i2_c_read.data) print(i2c_controller.scan()) # [0x50, ...] i2c_controller.detach_from_bus() ``` ``` -------------------------------- ### PxSPI32BitRegisterTarget Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/spi.md Documentation for the PxSPI32BitRegisterTarget class, including constructor and usage example. ```APIDOC ## PxSPI32BitRegisterTarget ### Description SPI 32-bit register target device. No public methods beyond the abstract device surface. ### Constructor ```python def __init__(self, exerciser: "AqProtocolExerciser", config: PxSPI32BitRegisterTargetConfig | None = None, *args, **kwargs) -> None: ``` ### Parameters - **exerciser** (`AqProtocolExerciser`) - Required - Connected exerciser. - **config** (`PxSPI32BitRegisterTargetConfig`, optional) - Optional - Target configuration. If omitted, an empty `PxSPI32BitRegisterTargetConfig()` is created. ### Example ```python target = PxSPI32BitRegisterTarget(exerciser) target.attach_to_bus(spi_bus) ``` ``` -------------------------------- ### Legacy API usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i2c-common.md Example of using the legacy API to write and read from an I2C device. The code checks if the write returned None to detect a NACK. ```python n = ctrl.i2c_write(0x50, [0x00, 0x11, 0x22]) data = ctrl.i2c_read_addr(0x50, 0x00, 8) if n is None: print("target NACKed") ``` -------------------------------- ### Topology API usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/toplevel.md Example usage of the topology API: connect, create or find an I2C bus, retrieve all bus objects and raw handles, then set a handle slot. `create_bus` with "i2c" creates or finds a `PxI2CBus`. ```python px = AqProtocolExerciser.connect() bus = px.create_bus("i2c", scl=0, sda=1) # creates/finds a PxI2CBus buses = px.get_buses() # all existing bus objects handles = px.get_handles() # raw PxHandle list px.set_handle(0, PxHandle(i2_c=I2CChannel(scl=0, sda=1))) ``` -------------------------------- ### GPIO usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/toplevel.md Example usage of GPIO methods: set a pin high, send a pulse on pin 8, configure a trigger on pin 9, and read the state of pin 3. Uses PxIoState and PxGpioWidthTriggerMode from aqpxlib.gpio. ```python from aqpxlib.gpio import PxIoState, PxGpioWidthTriggerMode px.set_gpio_state(3, PxIoState.HIGH) px.send_gpio_pulse(8, active_state=PxIoState.HIGH, idle_state=PxIoState.LOW, active_time_ns=5000) px.set_gpio_trigger(9, min_duration_ns=1000, max_duration_ns=100000, high_pulse=True, mode=PxGpioWidthTriggerMode.TRIGGER_PULSE_WIDTH_OUT_OF_RANGE) pin_state = px.get_gpio_state(3) ``` -------------------------------- ### PxI2CBus methods Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i2c.md Method signatures for getting the current controller, converting to protobuf handle config, equality comparison, and string representation. ```python def get_current_controller(self) -> PxI2CController | None: # i2c_bus.py:63 def _to_protobuf_handle_config(self, *args, **kwargs) -> pxmsg.PxHandle: # i2c_bus.py:87 (ValueError if scl/sda kwargs missing) def __eq__(self, other: object) -> bool: # compares PxI2CBus / I2CChannel / PxHandle def __str__(self) -> str: # "I2C Bus (SCL: ..., SDA: ...)" ``` -------------------------------- ### Set DC output voltage and current limit Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/toplevel.md Example of setting DC output voltage and current limit, then reading the derived `dc_output_enabled` property and fetching the full DC output configuration. Values are in millivolts and milliamps respectively. ```python px.dc_output_voltage = 3300 # mV px.dc_output_current_limit = 500 # mA print(px.dc_output_enabled) # True cfg = px.get_pod_dc_output_config() ``` -------------------------------- ### PxPwmTx Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/pwm-data-generator.md Constructor for the PWM transmitter (controller) device. Output starts automatically on attach/configure. ```APIDOC ## PxPwmTx ### Description Creates a PWM transmitter device. The output starts automatically when attached to a bus and configured. ### Constructor ```python def __init__( self, exerciser: "AqProtocolExerciser", config: PxPwmTxConfig | None = None, period_ns: int = 40_000, duty_cycle_ns: int = 20_000, *args, **kwargs, ) -> None: ``` ### Parameters - **exerciser** (AqProtocolExerciser) - Required - Connected exerciser - **config** (PxPwmTxConfig | None) - Optional - Configuration object; if None, default config is used - **period_ns** (int) - Optional - PWM period in nanoseconds (default: 40000) - **duty_cycle_ns** (int) - Optional - PWM duty cycle in nanoseconds (default: 20000) ### Configuration Fields - **period_ns** (int) - uint32 - PWM period in nanoseconds - **duty_cycle_ns** (int) - uint32 - PWM duty cycle in nanoseconds ### Example ```python pwm_bus = PxPwmBus(exerciser, pin=0) tx = PxPwmTx(exerciser, period_ns=1_000_000, duty_cycle_ns=250_000) # 1 kHz, 25% duty tx.attach_to_bus(pwm_bus) ``` ``` -------------------------------- ### PxPwmTx constructor Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/pwm-data-generator.md Constructor for PxPwmTx. Default config is PxPwmTxConfig(period_ns=40_000, duty_cycle_ns=20_000). Output starts automatically on attach/configure. ```python def __init__( self, exerciser: "AqProtocolExerciser", config: PxPwmTxConfig | None = None, period_ns: int = 40_000, duty_cycle_ns: int = 20_000, *args, **kwargs, ) -> None: ``` -------------------------------- ### Attach and remove devices on PxI2CBus Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/abstract-bus.md Example of attaching a controller and target to an I2C bus, then removing the target. Shows the expected output of `get_controllers` and `get_targets` after attachment. ```python bus = PxI2CBus(px, scl=0, sda=1) controller = PxI2CController(px) controller.attach_to_bus(bus) # -> bus.attach_controller(self) target = PxI2C32BitRegisterTarget(px, address=0x50) target.attach_to_bus(bus) print(bus.get_controllers()) # [PxI2CController] print(bus.get_targets()) # [PxI2C32BitRegisterTarget] bus.remove_device(target) ``` -------------------------------- ### DealerTransport.__init__ Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/sessions.md Initializes a DealerTransport instance with a ZeroMQ context, endpoint, and identity. Starts a dedicated I/O thread that handles the socket. ```APIDOC ## DealerTransport.__init__ ### Description Initializes a DealerTransport instance with a ZeroMQ context, endpoint, and identity. Starts a dedicated I/O thread that handles the socket. ### Method Constructor ### Signature ```python def __init__(self, ctx: zmq.Context, endpoint: str, identity: bytes) -> None ``` ### Parameters - **ctx** (zmq.Context) - Required - The ZeroMQ context. - **endpoint** (str) - Required - The endpoint to connect to. - **identity** (bytes) - Required - The socket identity. ### Errors - **BackendError** - Raised if the DEALER I/O thread fails to start within 5 seconds. ``` -------------------------------- ### PxZMQSession base class method signatures Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/sessions.md Method signatures for the PxZMQSession base class. connect() is a template method that opens the command channel, connects a SUB socket to tcp://host:port+1, subscribes to b"", and starts the event monitor thread; subscriber raises BackendError("Not connected to server") if connect() was not called. ```python def __init__(self, config: PxZMQConfig) -> None: # zmq_base.py:33 @property def subscriber(self) -> SynchronousSocketWrapper[pxmsg.PxProtobufMsg, pxmsg.PxEventMsg]: # zmq_base.py:55 # BackendError("Not connected to server") if connect() not called def connect(self) -> None: # zmq_base.py:76 (template method) def disconnect(self) -> None: # zmq_base.py:104 def subscribe(self, event_topic: str) -> None: # zmq_base.py:125 def _open_command_channel(self, host: str, port: int) -> None: # abstract, zmq_base.py:63 def _close_command_channel(self) -> None: # abstract, zmq_base.py:67 ``` -------------------------------- ### PxZMQSession.__init__ Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/sessions.md Initializes a PxZMQSession with the given configuration. ```APIDOC ## PxZMQSession.__init__ ### Description Initializes a new PxZMQSession instance with the provided configuration. ### Method `__init__(self, config: PxZMQConfig) -> None` ### Parameters - **config** (PxZMQConfig) - Required - The ZeroMQ configuration for the session. ``` -------------------------------- ### Import AqProtocolExerciser Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/toplevel.md Import the AqProtocolExerciser class from the aqpxlib package. This is the top-level entry point for interacting with the instrument. ```python from aqpxlib import AqProtocolExerciser ``` -------------------------------- ### Direct CCC usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i3c-controller.md Example usage of direct_setdasa and direct_getpid. Assigns dynamic addresses and then reads PIDs, printing the ACK list and PID data. ```python acks = ctrl.direct_setdasa([0x32, 0x33], [0x20, 0x21]) pids = ctrl.direct_getpid([0x20, 0x21]) print(acks, pids) ``` -------------------------------- ### Import PxI3CBaseController and config Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i3c-controller.md Import the PxI3CBaseController class and its config alias from the aqpxlib.i3c module. ```python from aqpxlib.i3c import PxI3CBaseController, PxI3CBaseControllerConfig ``` -------------------------------- ### PxI2CController usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i2c.md Example usage of PxI2CController: attach to a bus, send write and read transactions, print ACK and data, scan for devices, and detach. ```python i2c_bus = PxI2CBus(exerciser, scl=0, sda=1) i2c_controller = PxI2CController(exerciser) i2c_controller.attach_to_bus(i2c_bus) resp = i2c_controller.send_i2c_transactions([ pxmsg.I2CTransaction(i2_c_write=pxmsg.I2CWriteTransaction(address=0x50, data=b"\x00\xaa")), pxmsg.I2CTransaction(i2_c_read=pxmsg.I2CReadTransaction(address=0x50, count=4)), ]) print(resp[0].i2_c_write.is_ack, resp[1].i2_c_read.data) print(i2c_controller.scan()) # [0x50, ...] i2c_controller.detach_from_bus() ``` -------------------------------- ### PxI2CFifoTarget usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i2c.md Example usage of PxI2CFifoTarget: attach to an I2C bus, enqueue data, and check tx_fill. A controller read drains the FIFO and triggers fifo_target_sent events. ```python fifo = PxI2CFifoTarget(exerciser, address=0x30) fifo.attach_to_bus(i2c_bus) fifo.enqueue([0xDE, 0xAD, 0xBE, 0xEF]) print(fifo.tx_fill) # 4 # a controller read on the bus drains the FIFO; fifo_target_sent events fire ``` -------------------------------- ### connect (classmethod) Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/toplevel.md Builds a session, connects it, and wraps it in an AqProtocolExerciser instance. Supports passing a PxSessionConfig or legacy host/port/protocol_version kwargs. Defaults to a v2 ZeroMQ session on localhost:60600. ```APIDOC ## connect (classmethod) ### Description Builds a session (`PxSession.from_config(config)`), connects it, and wraps it. With no arguments it defaults to a v2 ZeroMQ session on `localhost:60600`. Raises `ValueError` if `config` and any of `host`/`port`/`protocol_version` are passed together. ### Method classmethod ### Signature ```python @classmethod def connect( cls, config: PxSessionConfig | None = None, **kwargs: object, ) -> "AqProtocolExerciser": ``` ### Parameters - **config** (`PxSessionConfig | None`) - Optional - Transport config, e.g. `PxZMQConfig`. - **kwargs** (`object`) - Optional - Legacy `host` / `port` / `protocol_version` kwargs. ### Returns - `AqProtocolExerciser` - The connected exerciser instance. ### Errors - `ValueError` - If `config` and any of `host`/`port`/`protocol_version` are passed together. ### Example ```python px = AqProtocolExerciser.connect() # default localhost:60600, v2 px = AqProtocolExerciser.connect(host="10.0.0.5", port=60602, protocol_version="v2") px = AqProtocolExerciser.connect(PxZMQConfig(host="10.0.0.5")) ``` ``` -------------------------------- ### Data generator bus and counter example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/pwm-data-generator.md Example usage of PxDataGeneratorBus and PxDataGeneratorCounter. Creates a data generator bus with channels 0 and 1, a counter with clk_div=4, and attaches the counter to the bus. ```python dg_bus = PxDataGeneratorBus(exerciser, ch0=0, ch1=1) counter = PxDataGeneratorCounter(exerciser, clk_div=4) counter.attach_to_bus(dg_bus) ``` -------------------------------- ### PxI3CFifoTarget usage example Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i3c-targets.md Example usage of PxI3CFifoTarget: create a target with BCR 0x06 and DCR 0x33, attach it to a bus, enqueue data via the controller, and print the current FIFO fill and capacity. ```python fifo = PxI3CFifoTarget(exerciser, bcr=0x06, dcr=0x33) fifo.attach_to_bus(bus) ctrl.enqueue([1, 2, 3]) print(fifo.tx_fill, fifo.tx_capacity) ``` -------------------------------- ### Import PxSession and ZMQ session classes Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/sessions.md Import the main session classes and configuration from the aqpxlib.sessions module. ```python from aqpxlib.sessions import PxSession, PxZMQConfig, PxZMQV1Session, PxZMQV2Session ``` -------------------------------- ### Import PxAbstract classes Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/abstract-device.md Import the abstract base classes for buses and devices from the aqpxlib.abstract module. ```python from aqpxlib.abstract import PxAbstractInstance, PxAbstractDevice, PxAbstractController, PxAbstractTarget ``` -------------------------------- ### PxI3C32BitRegisterTarget.assigned_address Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i3c-targets.md Get the assigned address of the I3C target on the bus. ```APIDOC ## [PROPERTY] PxI3C32BitRegisterTarget.assigned_address ### Description Get the assigned address of the I3C target on the bus. ### Property Signature ```python @property def assigned_address(self) -> int ``` ### Returns - **int** - The assigned address of the target. ``` -------------------------------- ### Import PxI2CCommonOperations Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i2c-common.md Import the shared I2C convenience mixin from the aqpxlib.abstract module. This mixin is mixed into PxI2CController and PxI3CBaseController and provides CircuitPython/MicroPython-compatible helper methods plus legacy i2c_write/i2c_read methods. ```python from aqpxlib.abstract import PxI2CCommonOperations ``` -------------------------------- ### PxSPIBus get_current_controller method Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/spi.md Method to get the current controller from the bus. ```python def get_current_controller(self) -> PxSPIController | None: # spi_bus.py:67 ``` -------------------------------- ### Passing PxZMQConfig to AqProtocolExerciser.connect Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/configuration.md Shows three ways to pass connection configuration to AqProtocolExerciser.connect: using all defaults, passing a PxZMQConfig instance, or using legacy keyword arguments. Passing both config and any of host/port/protocol_version raises ValueError. ```python from aqpxlib import AqProtocolExerciser from aqpxlib.sessions import PxZMQConfig px = AqProtocolExerciser.connect() # all defaults above px = AqProtocolExerciser.connect(PxZMQConfig(host="10.0.0.5", port=60602, protocol_version="v2")) px = AqProtocolExerciser.connect(host="10.0.0.5", port=60602, protocol_version="v1") # legacy kwargs ``` -------------------------------- ### Typical internal use and error handling Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/channels.md Shows how to create a SynchronousSocketWrapper, send a request, and handle transport and backend errors. ```python # Typical internal use (v1 session client) socket = ctx.socket(zmq.DEALER) wrapper = SynchronousSocketWrapper[PxProtobufMsg, PxProtobufMsg](socket) result = wrapper.request(msg, timeout=5000) reply: PxProtobufMsg = result.result # Error handling try: result = wrapper.recv(timeout=5000) except TransportTimeoutError: print("no reply in time") except BackendError: print("zeroMQ failure") ``` -------------------------------- ### PxI2CFifoTarget Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/i2c.md Documentation for the PxI2CFifoTarget class, including constructor, properties, methods, events, and a usage example. ```APIDOC ## PxI2CFifoTarget ### Description Emulates an I2C target with host-accessible RX and TX FIFOs. It is valid on both `"i2c"` and `"i3c"` buses. Bus writes are delivered as packets via the `fifo_target_recv` event, and bus reads drain the TX FIFO, firing `fifo_target_sent` events. ### Constructor `__init__(self, exerciser, address: int = 0, config: PxI2CFifoTargetConfig | None = None, *args, **kwargs) -> None` ### Properties - **address** (`int`) - The I2C/I3C address of the target. - **tx_fill** (`int`) - The current fill level of the TX FIFO. Raises `ValueError` if detached, `TypeError` on wrong state. - **total_read** (`int`) - Total number of bytes read from the FIFO. - **total_written** (`int`) - Total number of bytes written to the FIFO. ### Methods - **enqueue(data: list[int] | bytes) -> None** - Loads data into the TX FIFO. No bus transaction is performed. ### Events - `fifo_target_recv` - Fired on bus writes; provides `data` and `last`. - `fifo_target_sent` - Fired on bus reads; provides `count` and `last`. ### Usage ```python fifo = PxI2CFifoTarget(exerciser, address=0x30) fifo.attach_to_bus(i2c_bus) fifo.enqueue([0xDE, 0xAD, 0xBE, 0xEF]) print(fifo.tx_fill) # 4 # a controller read on the bus drains the FIFO; fifo_target_sent events fire ``` ``` -------------------------------- ### PxAbstractBus.__init__ Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/abstract-bus.md Constructor for the abstract bus class. Initializes the bus with a connected exerciser and optional subclass-specific channel pins. Sets the handle index to -1, which must be assigned before any request is made. ```APIDOC ## PxAbstractBus.__init__ ### Description Constructor for the abstract bus class. Initializes the bus with a connected exerciser and optional subclass-specific channel pins. Sets the handle index to -1, which must be assigned before any request is made. ### Method Constructor ### Signature python def __init__(self, exerciser: "AqProtocolExerciser", *args: object, **kwargs: object) -> None: ### Parameters - **exerciser** (AqProtocolExerciser) - Required - Connected exerciser used for all requests - **\*args** (object) - Optional - Subclass-specific channel pins (e.g., `scl`/`sda`, `clk`/`miso`/`mosi`/`cs`, `tx`/`rx`, `pin`, `ch0`–`ch7`) - **\*\*kwargs** (object) - Optional - Subclass-specific channel pins (e.g., `config`+`handle_index` for reconstruction) ### Notes - Sets `self._handle_index = -1`; must be assigned before any request is made, otherwise `assert self._handle_index != -1` fires. ``` -------------------------------- ### Import from aqpxlib.channels Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/channels.md Import the main classes and functions from the channels module. ```python from aqpxlib.channels import SynchronousSocketWrapper, Result, decode_protobuf_response ``` -------------------------------- ### Register event handler with on_event Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/abstract-device.md Example of using the on_event decorator to register a handler for the memory_target_read_event. ```python @target.on_event("memory_target_read_event") def on_read(evt): print("read at", hex(evt.addr), evt.count) ``` -------------------------------- ### dc_output_voltage Source: https://github.com/acute-technology-inc/pxlib-docs/blob/main/_autodocs/api-reference/toplevel.md Property to get or set the DC output voltage in millivolts. Setting a negative value raises ValueError. ```APIDOC ## dc_output_voltage ### Description Property to get or set the DC output voltage in millivolts. Setting a negative value raises ValueError. ### Method dc_output_voltage (property) ### Signature ```python @property def dc_output_voltage(self) -> int | None @dc_output_voltage.setter def dc_output_voltage(self, voltage: int) -> None ``` ### Parameters (setter) - **voltage** (int) - Required - The DC output voltage in millivolts. Must be non-negative. ### Returns (getter) - **int | None** - The current DC output voltage in millivolts, or None if not set. ### Example ```python px.dc_output_voltage = 3300 # mV ``` ```