Bus Transmitter Module

class mtf.network_port.bus_transmitter.BusTransmitter

Abstract base class for a bus transmitter using the AbstractSingleton metaclass

abstract classmethod transmit_frame(*args, **kwargs)

Abstract method that transmits a frame.

Raises:

NotImplementedError: This method must be implemented by a subclass.

class mtf.network_port.bus_transmitter.CanTransmitter

Manage data transmission specifically on a CAN bus

transmitter
classmethod transmit_frame(channel_name: str, frame_id: int, payload: List, bit_rate_switch=True)

Transmits a CAN frame on the specified channel.

Args:

channel_name (str): The name of the CAN channel to transmit the frame on. frame_id (int): The ID of the CAN frame to transmit. payload (FramePayload): The payload of the CAN frame to transmit. bit_rate_switch (bool, optional): Whether to use the bit rate switch (BRS) feature

True -> BRS.ON False -> BRS.OFF Defaults to False.

Returns:

bool: True if succeeded

classmethod start_transmit_cyclic_frame(channel_name: str, frame_id: int, payload: List, cycle: int)

Initiates the cyclic transmission of a CAN frame on a specific channel Args:

channel_name (str): The channel name frame_id (int): The ID of the CAN frame payload (FramePayload): The payload of the CAN frame to transmit cycle (int): Cycle duration

Return:

bool: The method returns True if the cyclic transmission was started successfully, or False if it failed

classmethod stop_transmit_cyclic_frame(channel_name: str, frame_id: int)

Stops the cyclic transmission of a CAN frame Args:

channel_name (str): The channel name frame_id (int): The ID of the CAN frame

Return:

bool: True if the cyclic transmission was successfully stopped, False otherwise

class mtf.network_port.bus_transmitter.CanFdTransmitter

Manage data transmission specifically on a CANFD bus

classmethod transmit_frame(channel_name: str, frame_id: int, payload: List, bit_rate_switch=True)

Transmits a CANFD frame on the specified channel.

Args:

channel_name (str): The name of the CANFD channel to transmit the frame on. frame_id (int): The ID of the CANFD frame to transmit. payload (FramePayload): The payload of the CAN frame to transmit. bit_rate_switch (bool, optional): Whether to use the bit rate switch (BRS) feature

True -> BRS.ON False -> BRS.OFF Defaults to False.

Returns:

bool: True if succeeded

classmethod start_transmit_cyclic_frame(channel_name: str, frame_id: int, payload: List, cycle: int)

Initiates the cyclic transmission of a CANFD frame on a specific channel Args:

channel_name (str): The channel name frame_id (int): The ID of the CANFD frame payload (FramePayload): The payload of the CANFD frame to transmit cycle (int): Cycle duration

Return:

bool: The method returns True if the cyclic transmission was started successfully, or False if it failed

classmethod stop_transmit_cyclic_frame(channel_name: str, frame_id: int)

Stops the cyclic transmission of a CANFD frame Args:

channel_name (str): The channel name frame_id (int): The ID of the CANFD frame

Return:

bool: True if the cyclic transmission was successfully stopped, False otherwise

transmitter
class mtf.network_port.bus_transmitter.LinTransmitter

Manage data transmission specifically on a LIN bus

transmitter
classmethod transmit_frame(channel_name: str, frame_id: int, payload: List)

Transmits a LIN frame on the specified channel Args:

channel_name (str): The name of the LIN channel to transmit the frame on frame_id (int): The ID of the LIN frame to transmit payload (FramePayload): The payload of the CAN frame to transmit

Returns:

bool: True if succeeded

classmethod wake_up_lin_bus(channel_name: str)

Wakes up the LIN bus on the associated channel (Async Wake up sending). args:

channel_name (str)

Returns:

bool: True if the LIN bus wakes up successfully, False otherwise.

classmethod get_state(channel_name: str)

get the LIN bus state on the associated channel. args:

channel_name (str)

Returns:
EnumInit :

Operational : node is awake Sleep : node in sleep mode

class mtf.network_port.bus_transmitter.FlexrayTransmitter

Manage data transmission specifically on a Flexray bus

transmitter
classmethod transmit_frame(channel_name: str, frame_id: str, payload: ~typing.List, communication_channel: ~mtf.enum_types.FRCommunicationChannel = <FRCommunicationChannel.A: 0>, transmission_mode: ~mtf.enum_types.TransmissionMode = TransmissionMode.SingleShot)

Transmits a Flexray frame on the specified channel

Args:

channel_name (str): The name of the Flexray channel to transmit the frame on frame_id (int): The ID of the Flexray frame to transmit payload (FramePayload): The payload of the CAN frame to transmit communication_channel (FRCommunicationChannel) transmission_mode (TransmissionMode)

Returns:

bool: True if succeeded

classmethod stop_transmit(channel_name: str, frame_id: str | int, communication_channel: ~mtf.enum_types.FRCommunicationChannel = <FRCommunicationChannel.A: 0>)
Stops the continuous transmission of a frame on a specified communication channel
Args:

channel_name (str): The name of the Flexray channel to transmit the frame on frame_id (Union[str, int]): The ID of the Flexray frame to transmit communication_channel (FRCommunicationChannel): The specific FlexRay communication

channel where the transmission should be stopped

Returns:

bool: True if the transmission was successfully stopped, False otherwise

classmethod activate_wake_up(channel_name: str, do_wake_up: bool)

Activate wake up for a given channel args:

channel_name (str): The channel name do_wake_up (bool) Whether to wake up the FLEXRAY bus when the bus sleeps automatically

Returns:

bool: True if the FLEXRAY bus wakes up successfully, False otherwise.

class mtf.network_port.bus_transmitter.EthernetTransmitter

Manage data transmission specifically on a Ethernet bus

transmitter
lock
classmethod transmit_frame(channel_name: str, payload: List)

Transmits a Ethernet frame on the specified channel

Args:

channel_name (str): The name of the Ethernet channel to transmit the frame on frame_id (int): The ID of the Ethernet frame to transmit payload (FramePayload): The payload of the CAN frame to transmit

Returns:

bool: True if succeeded

classmethod transmit_frame_queue(channel_name: str, timestamped_queue: List[tuple[int, List[int]]])

transmit queue of packets with respect to the delays between successive frames. timestamped_queue contains list tuples, ech tuple contains:

first the delay between the previous message and the current message second the payload to be sent

note:

first delay means we will send the packets immediately or after certain delay. delay is in nanoseconds

[(0,[1,2,3]), (2,[1,2,3]) …..]

classmethod configure_frame_queue(channel_name: str, timestamped_queue: List[tuple[int, List[int]]])

Configure an ethernet frame queue transmission by specifying the dedicated channel and timestamped_queue.

Parameters:
  • channel_name – name of the ethernet channel to be configured.

  • timestamped_queue

    contains list tuples, each tuple contains:
    • first the delay between the previous message and the current message

    • second the payload to be sent

    note:

    first delay means we will send the packets immediately or after certain delay. delay is in nanoseconds

Returns:

True if the queue transmission is configured. False otherwise.

Examples: >>> MtfBase.bus_manager.bus_transmitter(BusType.ETHERNET).configure_frame_queue(“ethernet_channel_name”, [(0,[1,2,3]), (2,[1,2,3]) …..])

classmethod start_frame_queue(channel_name: str)

Start transmission of the ethernet queue associated with the given channel. For the transmission to occur, it must first be configured.

Parameters:

channel_name – name of the ethernet channel.

Returns:

True if the queue transmission task is triggered. False otherwise.

Examples: >>> MtfBase.bus_manager.bus_transmitter(BusType.ETHERNET).start_frame_queue(“ethernet_channel_name”)

classmethod send_ethernet_packet(channel_name: str, packet: Packet)

transmit packet crafted by mtf_pcpp submodule

Parameters:

channel_name – name of the ethernet channel.

Returns:

None

Examples: >>> payload = [

0x04, 0xEC, 0xD8, 0xCC, 0xA0, 0x92, 0xAC, 0x71, 0x2E, 0x41, 0x6F, 0x03, 0x08, 0x00, 0x45, 0x00, 0x00, 0x43, 0xF7, 0x56, 0x40, 0x00, 0x6C, 0x11, 0x58, 0x6B, 0x28, 0x63, 0xDC, 0xA2, 0xAC, 0x10, 0x0D, 0xD2, 0x01, 0xBB, 0xFF, 0xA1, 0x00, 0x2F, 0xF2, 0x40, 0x4A, 0xA8, 0x26, 0x18, 0xAF, 0xFF, 0x3D, 0xF4, 0x09, 0xAA, 0x5B, 0x16, 0xD9, 0xE1, 0xC7, 0xF5, 0x09, 0x2A, 0xE8, 0xA9, 0x93, 0xD5, 0xE9, 0x44, 0x7A, 0xED, 0xC7, 0xDB, 0x37, 0x9E, 0xEC, 0x97, 0xC3, 0x81, 0xA3, 0x61, 0xA6, 0xEC, 0x04,

]

>>> udp_packet = np.array(payload,dtype=np.uint8)
>>> rp = RawPacket(udp_packet)
>>> my_packet = Packet(rp)
>>> MtfBase.bus_manager.bus_transmitter(BusType.ETHERNET).send_ethernet_packet("ethernet_channel_name", my_packet)