5.3.1.3.5.1. cli.cmd_bootloader.bootloader_can_basics.BootloaderCanBasics

class cli.cmd_bootloader.bootloader_can_basics.BootloaderCanBasics(can_bus: BusABC, dbc_file: Path = WindowsPath('D:/_github/foxbms-2/tools/dbc/foxbms-bootloader.dbc'))

Bases: object

Implement all CAN-relevant functions used to wait for or receive specified messages on CAN bus.

send_can_message_to_bootloader(*args: dict) → None

Send any CAN messages from dbc file.

Parameters:

*args – list of CAN messages to be sent.

send_crc_to_bootloader(crc_8_bytes: int) → None

Send a CRC CAN message (8 bytes) to bootloader.

Parameters:

crc_8_bytes – maximal 0xffffffffffffffff.

send_data_to_bootloader(data_8_bytes: int) → None

Send a data CAN message (8 bytes) to bootloader.

Parameters:

data_8_bytes – maximal 0xffffffffffffffff.

send_loop_number_to_bootloader(num_of_loop: int) → None

Send loop number CAN message to bootloader.

Parameters:

num_of_loop – the number of data transfer loops.

send_request_to_bootloader(request_code: Enum) → None

Send a request CAN message to bootloader.

Parameters:

request_code – a member of the enum BootloaderAction.

send_transfer_program_info_to_bootloader(len_of_program_in_bytes: int, num_of_transfer_loops: int) → None

Send a transfer process info CAN message to the bootloader.

Parameters:
  • len_of_program_in_bytes – the length of the program in bytes.

  • num_of_transfer_loops – the number of total transfer loops.

wait_bootloader_state_msg() → BootloaderFsmStatesType | None

Wait for the CAN messages containing the state of bootloader.

Returns:

CAN message containing FSM states of bootloader.

wait_bootloader_version_info_msg() → BootloaderVersionInfoType | None

Wait for the messages containing the version information of the bootloader.

Returns:

CAN message containing bootloader version info.

wait_can_ack_msg(acknowledge_msg: Enum, timeout_total: float = 1.0, timeout_ack: float = 0.3, processed_level: Enum = StatusCode.ReceivedAndProcessed) → AcknowledgeMessageType | None

Wait for a certain CAN acknowledge message

Parameters:
  • acknowledge_msg – the type of ACK message

  • timeout_total – total time to wait

  • timeout_ack – time to wait for a single message

  • processed_level – the ACK message need to have at least this processed_level

Returns:

acknowledged message

wait_can_message(arbitration_id: int, dbc_file: Path | None = None, mux_value: str | None = None, params: dict | None = None, timeout_total: float = 1.0, timeout_bus_recv: float = 1.0) → dict[str, int | float | str | NamedSignalValue] | Sequence[tuple[Message, Mapping[str, int | float | str | NamedSignalValue]] | tuple[Message, bytes] | tuple[int, bytes]] | None

Wait for a specified CAN message.

Parameters:
  • arbitration_id – id of the CAN message e.g., 0x480

  • dbc_file – optional DBC file used to decode the received message.

  • mux_value – optional multiplexer value that must match for the decoded message.

  • params – optional dictionary with signal names and required values, for example {"AcknowledgeFlag": "Received"}. Messages with mismatching values are ignored.

  • timeout_total – the time limit [s] for the whole waiting process.

  • timeout_bus_recv – the time limit [s] to receive one message.

Returns:

The waited message, which value will be replaced with a string of enums if it is defined in the dbc file.

wait_data_transfer_info_msg() → DataTransferInfoType | None

Wait for the messages containing the information of the data transfer.

Returns:

CAN message containing data transfer info (the current loop number).