Pdu Module

class mtf.network_port.pdus.pdu.Pdu
static __new__(cls, channel_name: str, frame_id: str, pdu_name: str)

Overrides the __new__ method to ensure only one instance of Pdu class is created for each triple (channel_name, frame_id, pdu_name).

Args:

channel_name (str): The name of the channel. frame_id (str): The ID of the frame pdu_name (str): The name of the pdu.

Returns:

Pdu: The pdu instance associated with the triple (channel_name, frame_id, pdu_name).

__init__(channel_name: str, frame_id: str, pdu_name: str)

Initializes a Pdu instance with the given triple (channel_name, frame_id, pdu_name).

Args:

channel_name (str): The name of the channel. frame_id (str): The ID of the frame. pdu_name (str): The name of the pdu.

property channel_name: str

Retrieves the name of the channel.

Returns:

str: The name of the channel.

property frame_id: str

Retrieves the ID of the frame.

Returns:

str: The ID of the frame.

property pdu_name: str

Retrieves the name of the pdu.

Returns:

str: The name of the pdu.

get_last_received_pdu() List

Retrieves the last received PDU associated with the Pdu instance.

Returns:

FramePayload: The last received PDU associated with the Pdu instance.

transmit_pdu(payload: List, immediate: bool = False) bool

Transmits a PDU with the given payload and optional immediate flag.

Args:

payload (FramePayload): The payload of the PDU. immediate (bool, optional): A flag indicating if the transmission should be immediate. Defaults to False.

Returns:

bool: True if the PDU transmission was successful, False otherwise.

pdu_apply_faulty_corrupt_crc(on_off: bool = True) bool

Applies a faulty behavior to corrupt the CRC of the PDU.

Args:
on_off (bool, optional): A flag indicating if the faulty behavior should be enabled or disabled.

Defaults to True.

Returns:

pdu_apply_faulty_halt_alive_counter(on_off: bool = True) bool

Applies a faulty behavior to halt the alive counter of the PDU.

Args:
on_off (bool, optional): A flag indicating if the faulty behavior should be enabled or disabled.

Defaults to True.

Returns:

bool: True if the faulty behavior was applied successfully, False otherwise.

pdu_apply_faulty_corrupt_data_id_nibble(on_off: bool = True) bool

Applies a faulty behavior to corrupt the data ID nibble of the PDU.

Args:
on_off (bool, optional): A flag indicating if the faulty behavior should be enabled or disabled.

Defaults to True.

Returns:

bool: True if the faulty behavior was applied successfully, False otherwise.

get_signal(signal_name: str) Signal

Retrieves a Pdu object associated with the given pdu_name.

Args:

signal_name: The name of the pdu.

Returns:

Signal: The Pdu object associated with the pdu_name.

classmethod clear_registered_pdus()

Clears the instances dictionary of registered pdus.