5.3.1.3.2.2. cli.cmd_bootloader.bootloader.BootloaderInterface

class cli.cmd_bootloader.bootloader.BootloaderInterface

Bases: ABC

Abstract class of the bootloader communication interface.

abstractmethod get_bootloader_state() → tuple[str | None, str | None]

Get the bootloader’s current state.

Returns:

CanFsmState, BootFsmState.

abstractmethod get_bootloader_version_num() → tuple[int | None, int | None, int | None]

Get the bootloader’s version number.

Returns:

Current version number (MajorVersionNumber, MinorVersionNumber, PatchVersionNumber) of the bootloader.

abstractmethod get_current_num_of_loops() → int | None

Get the bootloader’s current transfer data loop number.

Returns:

Current number of data transfer loops.

abstractmethod get_foxbms_state() → str | None

Get the current state of foxBMS application if it is running.

Returns:

None if no application is running, otherwise the current bms state.

abstractmethod reset_bootloader(time_to_wait: float = 15.0, num_of_repeat: int = 5) → bool

Reset bootloader.

Parameters:
  • time_to_wait – time to wait for bootloader to reset itself.

  • num_of_repeat – number of retries while polling for bootloader state.

Returns:

True if the bootloader has been successfully reset, False otherwise.

abstractmethod run_app_on_bootloader() → bool

Run the application on bootloader.

Returns:

True if the application has been started successfully, False otherwise.

abstractmethod send_crc(crc_8_bytes: int, is_crc_of_vector_table: bool = False) → tuple[bool, bool]

Send crc signature to bootloader and get the feedback from bootloader.

Parameters:
  • crc_8_bytes – maximal 0xffffffffffffffff.

  • is_crc_of_vector_table – True if it is the crc of vector table.

Returns:

True, if a ACK message has been received. True, if the YesNoFlag is “Yes”.

abstractmethod send_data_to_bootloader(data_8_bytes: int) → None

Send data in 8 bytes to bootloader.

Parameters:

data_8_bytes – data in 8 bytes.

abstractmethod send_loop_number_to_bootloader(num_of_loop: int) → None

Send the current loop number of the to-be-transferred data to bootloader.

Parameters:

num_of_loop – the current loop number (starts from 1).

abstractmethod send_program_info(len_of_program_in_bytes: int, num_of_transfer_loops: int) → bool

Send program info to bootloader and check its states.

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

  • num_of_transfer_loops – the number of total transfer loops.

Returns:

True if bootloader has received info, False otherwise.

abstractmethod start_transfer() → bool

Inform bootloader to start the transfer program process.

Returns:

True if bootloader has successfully started the process, False otherwise.

abstractmethod 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 ACK 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 from bootloader