Skip to content

I2C 32-bit Register Target

The PxI2C32BitRegisterTarget class represents a generic I2C target device that exposes a set of 32-bit addressable registers. This is useful for emulating sensors, memory devices, or other peripherals.

PxI2C32BitRegisterTarget

PxI2C32BitRegisterTarget(
    exerciser: AqProtocolExerciser,
    address: int = 0,
    sub_address_type: SubAddressType = NONE,
    config: PxI2C32BitRegisterTargetConfig | None = None,
    *args,
    **kwargs
)

Bases: PxAbstractTarget[PxI2C32BitRegisterTargetConfig, PxI2C32BitRegisterTargetState]

I2C Base Target Class.

CLASS DESCRIPTION
SubAddressType

Sub-address type enumeration.

METHOD DESCRIPTION
add_event_handler

Add an event handler to the current device instance, by event class or event name.

remove_event_handler

Remove an event handler from the current device instance, by event class or event name.

get_event_handlers

Retreive handlers registerd on this device.

on_event

Add an event handler to the instance by decorator, by event class or event name.

match

Return whether a device config describes a device of this class.

update_additional_data

Atomically update additional_data with revision-aware retry.

update_config

Set the config of the target.

set_config

Set the config of the target.

attach_to_bus

Attach the target to a bus.

detach_from_bus

Detach the device from the bus.

perform_operation

Send an operation.

ATTRIBUTE DESCRIPTION
available_events_map

Map each available event name to its id in event topics.

TYPE: dict[str, str]

is_attached

Check if the device is attached to a bus.

TYPE: bool

state

Get the state of the device.

TYPE: DeviceStateT | None

name

Get the name of the device.

TYPE: str

cts_op_name

Get the name of CTS operation. Currently not available now.

TYPE: str | None

additional_data

Get the opaque additional data blob associated with this device.

TYPE: bytes

config

Get the config of the device.

TYPE: DeviceConfigT | None

address

Static address of the device.

TYPE: int

sub_address_type

Sub-address type of the device.

TYPE: SubAddressType

register_value

Get the register value of the target.

TYPE: int

available_events_map

available_events_map: dict[str, str]

Map each available event name to its id in event topics.

is_attached

is_attached: bool

Check if the device is attached to a bus.

state

state: DeviceStateT | None

Get the state of the device.

name

name: str

Get the name of the device.

cts_op_name

cts_op_name: str | None

Get the name of CTS operation. Currently not available now.

additional_data

additional_data: bytes

Get the opaque additional data blob associated with this device.

config

config: DeviceConfigT | None

Get the config of the device.

address

address: int

Static address of the device.

sub_address_type

sub_address_type: SubAddressType

Sub-address type of the device.

register_value

register_value: int

Get the register value of the target.

SubAddressType

Bases: IntEnum

Sub-address type enumeration.

This is intended to avoid exporting protobuf enum to the interface.

add_event_handler

add_event_handler(event: str, handler: Callable[[Any], Any]) -> None
add_event_handler(event: type[EventT], handler: Callable[[EventT], Any]) -> None
add_event_handler(
    event: str | type[PxAbstractEvent], handler: Callable[[Any], Any]
) -> None

Add an event handler to the current device instance, by event class or event name.

remove_event_handler

remove_event_handler(
    event: str | type[PxAbstractEvent], handler: Callable[[Any], Any] | None = None
) -> None

Remove an event handler from the current device instance, by event class or event name.

get_event_handlers

get_event_handlers(
    filter_by: Callable[[str], bool] | None = None,
) -> dict[str, list[Callable[[Any], Any]]]

Retreive handlers registerd on this device.

Handlers are always scoped to this device; an optional filter_by is applied on friendly event names.

on_event

on_event(event_type: str) -> Callable[[Callable[..., Any]], Callable[..., Any]]
on_event(
    event_type: type[EventT],
) -> Callable[[Callable[[EventT], Any]], Callable[[EventT], Any]]
on_event(
    event_type: str | type[PxAbstractEvent],
) -> Callable[[Callable[..., Any]], Callable[..., Any]]

Add an event handler to the instance by decorator, by event class or event name.

match

match(config: PxAbstractDeviceConfig) -> bool

Return whether a device config describes a device of this class.

update_additional_data

update_additional_data(updater: Callable[[bytes], bytes]) -> None

Atomically update additional_data with revision-aware retry.

update_config

update_config(updater: Callable[[Any], Any]) -> None

Set the config of the target.

set_config

set_config(config: DeviceConfigT) -> None

Set the config of the target.

attach_to_bus

attach_to_bus(bus: PxAbstractBus) -> None

Attach the target to a bus.

This method is used to make the device aware of the bus it is connected to. It is used to set the bus attribute of the device.

Note

This method will not automatically create an actual instance on the Protocol Exerciser until user call the attach_to_bus method.

PARAMETER DESCRIPTION

bus

The bus to attach the device to

TYPE: PxAbstractBus

RAISES DESCRIPTION
ValueError

If the device is already attached to a bus

detach_from_bus

detach_from_bus() -> None

Detach the device from the bus.

The opposite of the attach_to_bus method.

perform_operation

perform_operation(
    operation: PxDeviceOperation, *, timeout: int | None = None
) -> PxDeviceOperation

Send an operation.

PARAMETER DESCRIPTION

operation

Device operation to perform.

TYPE: PxDeviceOperation

timeout

Optional base STOP-handshake wait in milliseconds. When omitted, the instrument uses subsystem defaults.

TYPE: int | None DEFAULT: None