跳轉到

PWM Tx

PxPwmTx 用來設定 PWM 傳送器。以 period_nsduty_cycle_ns 定義波形。控制器掛載或重新設定後,輸出會自動開始。

PxPwmTx

PxPwmTx(
    exerciser: AqProtocolExerciser,
    config: PwmTxConfig | None = None,
    period_ns: int = 40000,
    duty_cycle_ns: int = 20000,
    *args,
    **kwargs
)

A PWM transmitter controller device class.

This class provides a high-level interface to a PWM TX device on the PWM bus. Timing is configured with period_ns and duty_cycle_ns. Output starts automatically on attach/configure.

METHOD DESCRIPTION
add_event_handler

Add an event handler to the current device instance.

remove_event_handler

Remove an event handler.

get_event_handlers

Retreive handlers registerd on this device.

on_event

Add an event handler to the instance by decorator.

set_config

Set the config of the controller.

detach_from_bus

Detach the device from the bus.

perform_operation

Send an operation.

attach_to_bus

Attach the controller to a bus.

ATTRIBUTE DESCRIPTION
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

state

Get the state of the device.

TYPE: Message | None

name

Get the name of the device.

TYPE: str

additional_data

Get the opaque additional data blob associated with this device.

TYPE: bytes

config

Get the config of the device.

TYPE: Message | None

cts_op_name

Get the name of CTS operation.

TYPE: str | None

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.

state

state: Message | None

Get the state of the device.

name

name: str

Get the name of the device.

additional_data

additional_data: bytes

Get the opaque additional data blob associated with this device.

config

config: Message | None

Get the config of the device.

cts_op_name

cts_op_name: str | None

Get the name of CTS operation.

add_event_handler

add_event_handler(event: str, handler: Callable[[Any], Any]) -> None

Add an event handler to the current device instance.

remove_event_handler

remove_event_handler(event: str) -> None

Remove an event handler.

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.

set_config

set_config(config: Message) -> None

Set the config of the controller.

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) -> PxDeviceOperation

Send an operation.

attach_to_bus

attach_to_bus(bus: PxAbstractBus) -> None

Attach the controller 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