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: I2C32BitRegisterTargetConfig | None = None,
    *args,
    **kwargs
)

Bases: PxAbstractTarget

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.

attach_to_bus

Attach the target to a bus.

config

Set the config of the target.

detach_from_bus

Detach the device from the bus.

get_event_handlers

Retreive handlers registerd on this device.

on_event

Add an event handler to the instance by decorator.

perform_operation

Send an operation.

remove_event_handler

Remove an event handler.

ATTRIBUTE DESCRIPTION
address

Static address of the device.

TYPE: int

available_events_map

A reverse mapping of field_name_by_number, which uses field name as key.

TYPE: dict[str, str]

is_attached

Check if the device is attached to a bus.

TYPE: bool

name

Get the name of the device.

TYPE: str

register_value

Get the register value of the target.

TYPE: int

state

Get the state of the device.

TYPE: Message | None

sub_address_type

Sub-address type of the device.

TYPE: SubAddressType

address

address: int

Static address of the device.

available_events_map

available_events_map: dict[str, str]

A reverse mapping of field_name_by_number, which uses field name as key.

is_attached

is_attached: bool

Check if the device is attached to a bus.

name

name: str

Get the name of the device.

register_value

register_value: int

Get the register value of the target.

state

state: Message | None

Get the state of the device.

sub_address_type

sub_address_type: SubAddressType

Sub-address type of the device.

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 an event handler to the current device instance.

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

config

config(config: Message) -> None

Set the config of the target.

detach_from_bus

detach_from_bus() -> None

Detach the device from the bus.

The opposite of the attach_to_bus method.

get_event_handlers

get_event_handlers() -> dict[str, Callable]

Retreive handlers registerd on this device.

on_event

on_event(event_type: str) -> Callable[[Callable[..., Any]], Callable[..., Any]]

Add an event handler to the instance by decorator.

perform_operation

perform_operation(operation: PxDeviceOperation) -> PxDeviceOperation

Send an operation.

remove_event_handler

remove_event_handler(event: str) -> None

Remove an event handler.