Midnight Sun Firmware
|
Class that handles message scheduling over a SocketCAN interface. More...
#include <can_scheduler.h>
Public Member Functions | |
CanScheduler () | |
Constructs a CanScheduler object. More... | |
void | startCanScheduler () |
Starts the CAN scheduler and sets all messages to 0. Must only be called once. More... | |
void | update_battery_status_fault (uint16_t fault_value) |
Update the CAN value for battery_status fault. More... | |
void | update_battery_status_fault_val (uint16_t fault_val_value) |
Update the CAN value for battery_status fault_val. More... | |
void | update_battery_status_aux_batt_v (uint16_t aux_batt_v_value) |
Update the CAN value for battery_status aux_batt_v. More... | |
void | update_battery_status_afe_status (uint8_t afe_status_value) |
Update the CAN value for battery_status afe_status. More... | |
void | update_battery_vt_voltage (uint16_t voltage_value) |
Update the CAN value for battery_vt voltage. More... | |
void | update_battery_vt_current (uint16_t current_value) |
Update the CAN value for battery_vt current. More... | |
void | update_battery_vt_temperature (uint16_t temperature_value) |
Update the CAN value for battery_vt temperature. More... | |
void | update_battery_vt_batt_perc (uint16_t batt_perc_value) |
Update the CAN value for battery_vt batt_perc. More... | |
void | update_battery_info_fan1 (uint8_t fan1_value) |
Update the CAN value for battery_info fan1. More... | |
void | update_battery_info_fan2 (uint8_t fan2_value) |
Update the CAN value for battery_info fan2. More... | |
void | update_battery_info_max_cell_v (uint16_t max_cell_v_value) |
Update the CAN value for battery_info max_cell_v. More... | |
void | update_battery_info_min_cell_v (uint16_t min_cell_v_value) |
Update the CAN value for battery_info min_cell_v. More... | |
void | update_afe1_status_id (uint8_t id_value) |
Update the CAN value for afe1_status id. More... | |
void | update_afe1_status_temp (uint8_t temp_value) |
Update the CAN value for afe1_status temp. More... | |
void | update_afe1_status_v1 (uint16_t v1_value) |
Update the CAN value for afe1_status v1. More... | |
void | update_afe1_status_v2 (uint16_t v2_value) |
Update the CAN value for afe1_status v2. More... | |
void | update_afe1_status_v3 (uint16_t v3_value) |
Update the CAN value for afe1_status v3. More... | |
void | update_afe2_status_id (uint8_t id_value) |
Update the CAN value for afe2_status id. More... | |
void | update_afe2_status_temp (uint8_t temp_value) |
Update the CAN value for afe2_status temp. More... | |
void | update_afe2_status_v1 (uint16_t v1_value) |
Update the CAN value for afe2_status v1. More... | |
void | update_afe2_status_v2 (uint16_t v2_value) |
Update the CAN value for afe2_status v2. More... | |
void | update_afe2_status_v3 (uint16_t v3_value) |
Update the CAN value for afe2_status v3. More... | |
void | update_afe3_status_id (uint8_t id_value) |
Update the CAN value for afe3_status id. More... | |
void | update_afe3_status_temp (uint8_t temp_value) |
Update the CAN value for afe3_status temp. More... | |
void | update_afe3_status_v1 (uint16_t v1_value) |
Update the CAN value for afe3_status v1. More... | |
void | update_afe3_status_v2 (uint16_t v2_value) |
Update the CAN value for afe3_status v2. More... | |
void | update_afe3_status_v3 (uint16_t v3_value) |
Update the CAN value for afe3_status v3. More... | |
void | update_fast_one_shot_msg_sig1 (uint16_t sig1_value) |
Update the CAN value for fast_one_shot_msg sig1. More... | |
void | update_fast_one_shot_msg_sig2 (uint16_t sig2_value) |
Update the CAN value for fast_one_shot_msg sig2. More... | |
void | update_medium_one_shot_msg_sig1 (uint16_t sig1_value) |
Update the CAN value for medium_one_shot_msg sig1. More... | |
void | update_medium_one_shot_msg_sig2 (uint16_t sig2_value) |
Update the CAN value for medium_one_shot_msg sig2. More... | |
void | update_slow_one_shot_msg_sig1 (uint16_t sig1_value) |
Update the CAN value for slow_one_shot_msg sig1. More... | |
void | update_slow_one_shot_msg_sig2 (uint16_t sig2_value) |
Update the CAN value for slow_one_shot_msg sig2. More... | |
void | update_cc_pedal_throttle_output (uint32_t throttle_output_value) |
Update the CAN value for cc_pedal throttle_output. More... | |
void | update_cc_pedal_brake_output (uint8_t brake_output_value) |
Update the CAN value for cc_pedal brake_output. More... | |
void | update_cc_info_target_velocity (uint32_t target_velocity_value) |
Update the CAN value for cc_info target_velocity. More... | |
void | update_cc_info_drive_state (uint8_t drive_state_value) |
Update the CAN value for cc_info drive_state. More... | |
void | update_cc_info_cruise_control (uint8_t cruise_control_value) |
Update the CAN value for cc_info cruise_control. More... | |
void | update_cc_info_regen_braking (uint8_t regen_braking_value) |
Update the CAN value for cc_info regen_braking. More... | |
void | update_cc_info_hazard_enabled (uint8_t hazard_enabled_value) |
Update the CAN value for cc_info hazard_enabled. More... | |
void | update_cc_steering_input_cc (uint8_t input_cc_value) |
Update the CAN value for cc_steering input_cc. More... | |
void | update_cc_steering_input_lights (uint8_t input_lights_value) |
Update the CAN value for cc_steering input_lights. More... | |
void | update_cc_regen_percentage_percent (uint32_t percent_value) |
Update the CAN value for cc_regen_percentage percent. More... | |
Private Member Functions | |
void | scheduleCanMessages () |
Schedules all CAN data by updating the Broacast Manager socket. More... | |
Private Attributes | |
const std::string | CAN_INTERFACE_NAME = "vcan0" |
struct { | |
struct bcm_msg_head msg_head | |
struct can_frame frame [NUM_FAST_CYCLE_MESSAGES] | |
} | canFastCycleBCM |
Fast cycle Broadcast Manager message for the Linux Kernel. | |
struct { | |
struct bcm_msg_head msg_head | |
struct can_frame frame [NUM_MEDIUM_CYCLE_MESSAGES] | |
} | canMediumCycleBCM |
Medium cycle Broadcast Manager message for the Linux Kernel. | |
struct { | |
struct bcm_msg_head msg_head | |
struct can_frame frame [NUM_SLOW_CYCLE_MESSAGES] | |
} | canSlowCycleBCM |
Slow cycle Broadcast Manager message for the Linux Kernel. | |
int | m_bcmCanSocket |
std::atomic< bool > | m_isConnected |
Static Private Attributes | |
static const constexpr unsigned int | FAST_CYCLE_SPEED_MS = 1U |
static const constexpr unsigned int | MEDIUM_CYCLE_SPEED_MS = 100U |
static const constexpr unsigned int | SLOW_CYCLE_SPEED_MS = 1000U |
static const constexpr unsigned int | SLOW_CYCLE_BCM_ID = 0U |
static const constexpr unsigned int | MEDIUM_CYCLE_BCM_ID = 1U |
static const constexpr unsigned int | FAST_CYCLE_BCM_ID = 2U |
static const constexpr unsigned int | NUM_FAST_CYCLE_MESSAGES = 3U |
static const constexpr unsigned int | NUM_MEDIUM_CYCLE_MESSAGES = 5U |
static const constexpr unsigned int | NUM_SLOW_CYCLE_MESSAGES = 5U |
static const constexpr unsigned int | NUM_TOTAL_MESSAGES = 13U |
static const constexpr unsigned int | MAX_MESSAGE_LENGTH = 8U |
static const constexpr unsigned int | FAST_BMS_CARRIER_BATTERY_VT_FRAME_INDEX = 0U |
static const constexpr unsigned int | FAST_CAN_COMMUNICATION_FAST_ONE_SHOT_MSG_FRAME_INDEX = 1U |
static const constexpr unsigned int | FAST_CENTRE_CONSOLE_CC_PEDAL_FRAME_INDEX = 2U |
static const constexpr unsigned int | MEDIUM_BMS_CARRIER_BATTERY_STATUS_FRAME_INDEX = 0U |
static const constexpr unsigned int | MEDIUM_CAN_COMMUNICATION_MEDIUM_ONE_SHOT_MSG_FRAME_INDEX = 1U |
static const constexpr unsigned int | MEDIUM_CENTRE_CONSOLE_CC_INFO_FRAME_INDEX = 2U |
static const constexpr unsigned int | MEDIUM_CENTRE_CONSOLE_CC_STEERING_FRAME_INDEX = 3U |
static const constexpr unsigned int | MEDIUM_CENTRE_CONSOLE_CC_REGEN_PERCENTAGE_FRAME_INDEX = 4U |
static const constexpr unsigned int | SLOW_BMS_CARRIER_BATTERY_INFO_FRAME_INDEX = 0U |
static const constexpr unsigned int | SLOW_BMS_CARRIER_AFE1_STATUS_FRAME_INDEX = 1U |
static const constexpr unsigned int | SLOW_BMS_CARRIER_AFE2_STATUS_FRAME_INDEX = 2U |
static const constexpr unsigned int | SLOW_BMS_CARRIER_AFE3_STATUS_FRAME_INDEX = 3U |
static const constexpr unsigned int | SLOW_CAN_COMMUNICATION_SLOW_ONE_SHOT_MSG_FRAME_INDEX = 4U |
Class that handles message scheduling over a SocketCAN interface.
This class is responsible scheduling CAN messages based on their cycle speed Only 3 cycle speeds are supported, Fast (1kHz), medium (10Hz) and slow (1Hz) The class shall support message updating during run-time for further bus simulation
CanScheduler | ( | ) |
Constructs a CanScheduler object.
Initializes the CanScheduler. The constructor sets up internal variables
|
private |
Schedules all CAN data by updating the Broacast Manager socket.
This function is called by startCanScheduler This function shall initialize all CAN message values to 0
void startCanScheduler | ( | ) |
Starts the CAN scheduler and sets all messages to 0. Must only be called once.
This function will connect to the Linux Broadcast Manager This function must only be called once, and it will set all messages to 0
void update_afe1_status_id | ( | uint8_t | id_value | ) |
Update the CAN value for afe1_status id.
id_value | New value for the signal |
void update_afe1_status_temp | ( | uint8_t | temp_value | ) |
Update the CAN value for afe1_status temp.
temp_value | New value for the signal |
void update_afe1_status_v1 | ( | uint16_t | v1_value | ) |
Update the CAN value for afe1_status v1.
v1_value | New value for the signal |
void update_afe1_status_v2 | ( | uint16_t | v2_value | ) |
Update the CAN value for afe1_status v2.
v2_value | New value for the signal |
void update_afe1_status_v3 | ( | uint16_t | v3_value | ) |
Update the CAN value for afe1_status v3.
v3_value | New value for the signal |
void update_afe2_status_id | ( | uint8_t | id_value | ) |
Update the CAN value for afe2_status id.
id_value | New value for the signal |
void update_afe2_status_temp | ( | uint8_t | temp_value | ) |
Update the CAN value for afe2_status temp.
temp_value | New value for the signal |
void update_afe2_status_v1 | ( | uint16_t | v1_value | ) |
Update the CAN value for afe2_status v1.
v1_value | New value for the signal |
void update_afe2_status_v2 | ( | uint16_t | v2_value | ) |
Update the CAN value for afe2_status v2.
v2_value | New value for the signal |
void update_afe2_status_v3 | ( | uint16_t | v3_value | ) |
Update the CAN value for afe2_status v3.
v3_value | New value for the signal |
void update_afe3_status_id | ( | uint8_t | id_value | ) |
Update the CAN value for afe3_status id.
id_value | New value for the signal |
void update_afe3_status_temp | ( | uint8_t | temp_value | ) |
Update the CAN value for afe3_status temp.
temp_value | New value for the signal |
void update_afe3_status_v1 | ( | uint16_t | v1_value | ) |
Update the CAN value for afe3_status v1.
v1_value | New value for the signal |
void update_afe3_status_v2 | ( | uint16_t | v2_value | ) |
Update the CAN value for afe3_status v2.
v2_value | New value for the signal |
void update_afe3_status_v3 | ( | uint16_t | v3_value | ) |
Update the CAN value for afe3_status v3.
v3_value | New value for the signal |
void update_battery_info_fan1 | ( | uint8_t | fan1_value | ) |
Update the CAN value for battery_info fan1.
fan1_value | New value for the signal |
void update_battery_info_fan2 | ( | uint8_t | fan2_value | ) |
Update the CAN value for battery_info fan2.
fan2_value | New value for the signal |
void update_battery_info_max_cell_v | ( | uint16_t | max_cell_v_value | ) |
Update the CAN value for battery_info max_cell_v.
max_cell_v_value | New value for the signal |
void update_battery_info_min_cell_v | ( | uint16_t | min_cell_v_value | ) |
Update the CAN value for battery_info min_cell_v.
min_cell_v_value | New value for the signal |
void update_battery_status_afe_status | ( | uint8_t | afe_status_value | ) |
Update the CAN value for battery_status afe_status.
afe_status_value | New value for the signal |
void update_battery_status_aux_batt_v | ( | uint16_t | aux_batt_v_value | ) |
Update the CAN value for battery_status aux_batt_v.
aux_batt_v_value | New value for the signal |
void update_battery_status_fault | ( | uint16_t | fault_value | ) |
Update the CAN value for battery_status fault.
fault_value | New value for the signal |
void update_battery_status_fault_val | ( | uint16_t | fault_val_value | ) |
Update the CAN value for battery_status fault_val.
fault_val_value | New value for the signal |
void update_battery_vt_batt_perc | ( | uint16_t | batt_perc_value | ) |
Update the CAN value for battery_vt batt_perc.
batt_perc_value | New value for the signal |
void update_battery_vt_current | ( | uint16_t | current_value | ) |
Update the CAN value for battery_vt current.
current_value | New value for the signal |
void update_battery_vt_temperature | ( | uint16_t | temperature_value | ) |
Update the CAN value for battery_vt temperature.
temperature_value | New value for the signal |
void update_battery_vt_voltage | ( | uint16_t | voltage_value | ) |
Update the CAN value for battery_vt voltage.
voltage_value | New value for the signal |
void update_cc_info_cruise_control | ( | uint8_t | cruise_control_value | ) |
Update the CAN value for cc_info cruise_control.
cruise_control_value | New value for the signal |
void update_cc_info_drive_state | ( | uint8_t | drive_state_value | ) |
Update the CAN value for cc_info drive_state.
drive_state_value | New value for the signal |
void update_cc_info_hazard_enabled | ( | uint8_t | hazard_enabled_value | ) |
Update the CAN value for cc_info hazard_enabled.
hazard_enabled_value | New value for the signal |
void update_cc_info_regen_braking | ( | uint8_t | regen_braking_value | ) |
Update the CAN value for cc_info regen_braking.
regen_braking_value | New value for the signal |
void update_cc_info_target_velocity | ( | uint32_t | target_velocity_value | ) |
Update the CAN value for cc_info target_velocity.
target_velocity_value | New value for the signal |
void update_cc_pedal_brake_output | ( | uint8_t | brake_output_value | ) |
Update the CAN value for cc_pedal brake_output.
brake_output_value | New value for the signal |
void update_cc_pedal_throttle_output | ( | uint32_t | throttle_output_value | ) |
Update the CAN value for cc_pedal throttle_output.
throttle_output_value | New value for the signal |
void update_cc_regen_percentage_percent | ( | uint32_t | percent_value | ) |
Update the CAN value for cc_regen_percentage percent.
percent_value | New value for the signal |
void update_cc_steering_input_cc | ( | uint8_t | input_cc_value | ) |
Update the CAN value for cc_steering input_cc.
input_cc_value | New value for the signal |
void update_cc_steering_input_lights | ( | uint8_t | input_lights_value | ) |
Update the CAN value for cc_steering input_lights.
input_lights_value | New value for the signal |
void update_fast_one_shot_msg_sig1 | ( | uint16_t | sig1_value | ) |
Update the CAN value for fast_one_shot_msg sig1.
sig1_value | New value for the signal |
void update_fast_one_shot_msg_sig2 | ( | uint16_t | sig2_value | ) |
Update the CAN value for fast_one_shot_msg sig2.
sig2_value | New value for the signal |
void update_medium_one_shot_msg_sig1 | ( | uint16_t | sig1_value | ) |
Update the CAN value for medium_one_shot_msg sig1.
sig1_value | New value for the signal |
void update_medium_one_shot_msg_sig2 | ( | uint16_t | sig2_value | ) |
Update the CAN value for medium_one_shot_msg sig2.
sig2_value | New value for the signal |
void update_slow_one_shot_msg_sig1 | ( | uint16_t | sig1_value | ) |
Update the CAN value for slow_one_shot_msg sig1.
sig1_value | New value for the signal |
void update_slow_one_shot_msg_sig2 | ( | uint16_t | sig2_value | ) |
Update the CAN value for slow_one_shot_msg sig2.
sig2_value | New value for the signal |
|
private |
SocketCAN interface name
|
staticconstexprprivate |
Broadcast Manager battery_vt to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager fast_one_shot_msg to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager cc_pedal to Frame index mapping
|
staticconstexprprivate |
Linux Broadcast Manager Id for tracking slow cycle messages
|
staticconstexprprivate |
CAN fast cycle period in milliseconds
struct can_frame frame[NUM_SLOW_CYCLE_MESSAGES] |
CAN message frames that shall be scheduled for fast cycle
CAN message frames that shall be scheduled for medium cycle
CAN message frames that shall be scheduled for slow cycle
|
private |
The CAN schedulers Broadcast Manager socket FD
|
private |
Boolean flag to track the CAN schedulers connection status
|
staticconstexprprivate |
Max message length in bytes
|
staticconstexprprivate |
Broadcast Manager battery_status to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager medium_one_shot_msg to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager cc_info to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager cc_regen_percentage to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager cc_steering to Frame index mapping
|
staticconstexprprivate |
Linux Broadcast Manager Id for tracking medium cycle messages
|
staticconstexprprivate |
CAN medium cycle period in milliseconds
struct bcm_msg_head msg_head |
Broadcast Manager message head containing metadata
|
staticconstexprprivate |
Number of fast cycle messages
|
staticconstexprprivate |
Number of medium cycle messages
|
staticconstexprprivate |
Number of slow cycle messages
|
staticconstexprprivate |
Total number of messages
|
staticconstexprprivate |
Broadcast Manager afe1_status to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager afe2_status to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager afe3_status to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager battery_info to Frame index mapping
|
staticconstexprprivate |
Broadcast Manager slow_one_shot_msg to Frame index mapping
|
staticconstexprprivate |
Linux Broadcast Manager Id for tracking fast cycle messages
|
staticconstexprprivate |
CAN slow cycle period in milliseconds