From 118169a952237e2cd4b8a26862d17650a717a7e7 Mon Sep 17 00:00:00 2001 From: Advait Vedant Date: Thu, 30 Oct 2025 18:14:57 -0700 Subject: [PATCH 1/7] replaced magic numbers from charging request can message with enum. --- lib/interfaces/include/CCUInterface.h | 6 +++++- lib/interfaces/src/CCUInterface.cpp | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/interfaces/include/CCUInterface.h b/lib/interfaces/include/CCUInterface.h index 357b155d..be9f0afa 100644 --- a/lib/interfaces/include/CCUInterface.h +++ b/lib/interfaces/include/CCUInterface.h @@ -16,7 +16,11 @@ constexpr const size_t NUM_CELLS = 126; constexpr const size_t NUM_CELLTEMPS = 48; constexpr const size_t NUM_CHIPS = 12; - +enum ChargingCommand_e +{ + CHARGE = 2, + DISCHARGE = 1 +}; struct CCUCANInterfaceData_s { unsigned long last_time_charging_requested; diff --git a/lib/interfaces/src/CCUInterface.cpp b/lib/interfaces/src/CCUInterface.cpp index 5d809ee9..c415c8f0 100644 --- a/lib/interfaces/src/CCUInterface.cpp +++ b/lib/interfaces/src/CCUInterface.cpp @@ -16,9 +16,9 @@ void CCUInterface::receive_CCU_status_message(const CAN_message_t& msg, unsigned void CCUInterface::handle_enqueue_acu_status_CAN_message() { BMS_STATUS_t msg = {}; if (_curr_data.charging_requested) { - msg.state = 2; // charging + msg.state = ChargingCommand_e::CHARGE; } else { - msg.state = 1; // discharging + msg.state = ChargingCommand_e::DISCHARGE; } CAN_util::enqueue_msg(&msg, &Pack_BMS_STATUS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); From 1e0d8e21c25274bf782efbb51114ee66adcd7ecd Mon Sep 17 00:00:00 2001 From: Advait Vedant Date: Thu, 30 Oct 2025 23:05:26 -0700 Subject: [PATCH 2/7] changed handshake names to be more accurate and removed extra value --- lib/interfaces/include/CCUInterface.h | 35 ++++++++------ lib/interfaces/src/CCUInterface.cpp | 70 +++++++++++++-------------- platformio.ini | 2 +- 3 files changed, 55 insertions(+), 52 deletions(-) diff --git a/lib/interfaces/include/CCUInterface.h b/lib/interfaces/include/CCUInterface.h index be9f0afa..9dd1ec5e 100644 --- a/lib/interfaces/include/CCUInterface.h +++ b/lib/interfaces/include/CCUInterface.h @@ -16,10 +16,13 @@ constexpr const size_t NUM_CELLS = 126; constexpr const size_t NUM_CELLTEMPS = 48; constexpr const size_t NUM_CHIPS = 12; +constexpr const size_t CELLS_PER_GROUP = 3; +constexpr const size_t GROUPS_PER_IC_EVEN = 4; +constexpr const size_t GROUPS_PER_IC_ODD = 3; enum ChargingCommand_e { - CHARGE = 2, - DISCHARGE = 1 + CHARGE = 0, + IDLE = 1, }; struct CCUCANInterfaceData_s { @@ -27,13 +30,13 @@ struct CCUCANInterfaceData_s unsigned long prev_ccu_msg_recv_ms; bool charging_requested; bool is_connected_to_CCU; - size_t detailed_voltages_ic_id; - size_t detailed_voltages_group_id; - size_t detailed_voltages_cell_id; - size_t detailed_temps_ic_id; - size_t detailed_temps_group_id; - size_t detailed_temps_cell_id; - size_t detailed_temps_board_id; + size_t current_voltage_group_chip_id; + size_t current_voltage_cell_group_id; + size_t current_voltage_cell_id; + size_t current_temp_group_chip_id; + size_t current_temp_group_id; + size_t current_temp_cell_id; + size_t current_temp_board_id; }; class CCUInterface @@ -47,13 +50,13 @@ class CCUInterface _curr_data.prev_ccu_msg_recv_ms = 0; _curr_data.charging_requested = false; _curr_data.is_connected_to_CCU = false; - _curr_data.detailed_voltages_group_id = 0; - _curr_data.detailed_voltages_ic_id = 0; - _curr_data.detailed_voltages_cell_id = 0; - _curr_data.detailed_temps_group_id = 0; - _curr_data.detailed_temps_ic_id = 0; - _curr_data.detailed_temps_cell_id = 0; - _curr_data.detailed_temps_board_id = 0; + _curr_data.current_voltage_cell_group_id = 0; + _curr_data.current_voltage_group_chip_id = 0; + _curr_data.current_voltage_cell_id = 0; + _curr_data.current_temp_group_id = 0; + _curr_data.current_temp_group_chip_id = 0; + _curr_data.current_temp_cell_id = 0; + _curr_data.current_temp_board_id = 0; }; bool is_charging_requested() { return _curr_data.charging_requested; } diff --git a/lib/interfaces/src/CCUInterface.cpp b/lib/interfaces/src/CCUInterface.cpp index c415c8f0..8cb2d1f0 100644 --- a/lib/interfaces/src/CCUInterface.cpp +++ b/lib/interfaces/src/CCUInterface.cpp @@ -16,9 +16,9 @@ void CCUInterface::receive_CCU_status_message(const CAN_message_t& msg, unsigned void CCUInterface::handle_enqueue_acu_status_CAN_message() { BMS_STATUS_t msg = {}; if (_curr_data.charging_requested) { - msg.state = ChargingCommand_e::CHARGE; + msg.charging_state = ChargingCommand_e::CHARGE; } else { - msg.state = ChargingCommand_e::DISCHARGE; + msg.charging_state = ChargingCommand_e::IDLE; } CAN_util::enqueue_msg(&msg, &Pack_BMS_STATUS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); @@ -26,60 +26,60 @@ void CCUInterface::handle_enqueue_acu_status_CAN_message() { void CCUInterface::handle_enqueue_acu_core_voltages_CAN_message() { BMS_VOLTAGES_t msg = {}; - msg.high_voltage_ro = HYTECH_high_voltage_ro_toS(_acu_core_data.max_cell_voltage); - msg.low_voltage_ro = HYTECH_low_voltage_ro_toS(_acu_core_data.min_cell_voltage); + msg.max_cell_voltage_ro = HYTECH_max_cell_voltage_ro_toS(_acu_core_data.max_cell_voltage); + msg.min_cell_voltage_ro = HYTECH_min_cell_voltage_ro_toS(_acu_core_data.min_cell_voltage); msg.total_voltage_ro = HYTECH_total_voltage_ro_toS(_acu_core_data.pack_voltage); msg.average_voltage_ro = HYTECH_average_voltage_ro_toS(_acu_core_data.avg_cell_voltage); CAN_util::enqueue_msg(&msg, &Pack_BMS_VOLTAGES_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); } void CCUInterface::handle_enqueue_acu_voltages_CAN_message() { - BMS_DETAILED_VOLTAGES_t detailed_msg = {}; - detailed_msg.ic_id = static_cast(_curr_data.detailed_voltages_ic_id); - detailed_msg.group_id = static_cast(_curr_data.detailed_voltages_group_id); - detailed_msg.voltage_0_ro = HYTECH_voltage_0_ro_toS(_acu_all_data.cell_voltages[_curr_data.detailed_voltages_cell_id]); - detailed_msg.voltage_1_ro = HYTECH_voltage_1_ro_toS(_acu_all_data.cell_voltages[_curr_data.detailed_voltages_cell_id+1]); - detailed_msg.voltage_2_ro = HYTECH_voltage_2_ro_toS(_acu_all_data.cell_voltages[_curr_data.detailed_voltages_cell_id+2]); + BMS_CELL_VOLTAGES_t msg = {}; + msg.chip_id = static_cast(_curr_data.current_voltage_group_chip_id); + msg.cell_group_id = static_cast(_curr_data.current_voltage_cell_group_id); + msg.cell_group_voltage_0_ro = HYTECH_cell_group_voltage_0_ro_toS(_acu_all_data.cell_voltages[_curr_data.current_voltage_cell_id]); + msg.cell_group_voltage_1_ro = HYTECH_cell_group_voltage_1_ro_toS(_acu_all_data.cell_voltages[_curr_data.current_voltage_cell_id+1]); + msg.cell_group_voltage_2_ro = HYTECH_cell_group_voltage_2_ro_toS(_acu_all_data.cell_voltages[_curr_data.current_voltage_cell_id+2]); - if (_curr_data.detailed_voltages_ic_id % 2 == 0) { - _curr_data.detailed_voltages_group_id = (_curr_data.detailed_voltages_group_id == 3) ? 0 : _curr_data.detailed_voltages_group_id+1; + if (_curr_data.current_voltage_group_chip_id % 2 == 0) { + _curr_data.current_voltage_cell_group_id = (_curr_data.current_voltage_cell_group_id == GROUPS_PER_IC_EVEN - 1) ? 0 : _curr_data.current_voltage_cell_group_id+1; } else { - _curr_data.detailed_voltages_group_id = (_curr_data.detailed_voltages_group_id == 2) ? 0 : _curr_data.detailed_voltages_group_id+1; + _curr_data.current_voltage_cell_group_id = (_curr_data.current_voltage_cell_group_id == GROUPS_PER_IC_ODD - 1) ? 0 : _curr_data.current_voltage_cell_group_id+1; } - if (_curr_data.detailed_voltages_group_id == 0) { - _curr_data.detailed_voltages_ic_id = (_curr_data.detailed_voltages_ic_id == (NUM_CHIPS - 1)) ? 0 : _curr_data.detailed_voltages_ic_id+1; + if (_curr_data.current_voltage_cell_group_id == 0) { + _curr_data.current_voltage_group_chip_id = (_curr_data.current_voltage_group_chip_id == (NUM_CHIPS - 1)) ? 0 : _curr_data.current_voltage_group_chip_id+1; } - _curr_data.detailed_voltages_cell_id = (_curr_data.detailed_voltages_cell_id == NUM_CELLS - 3) ? 0 : _curr_data.detailed_voltages_cell_id+3; + _curr_data.current_voltage_cell_id= (_curr_data.current_voltage_cell_id == NUM_CELLS - CELLS_PER_GROUP) ? 0 : _curr_data.current_voltage_cell_id+CELLS_PER_GROUP; - CAN_util::enqueue_msg(&detailed_msg, &Pack_BMS_DETAILED_VOLTAGES_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); + CAN_util::enqueue_msg(&msg, &Pack_BMS_CELL_VOLTAGES_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); } void CCUInterface::handle_enqueue_acu_temps_CAN_message() { - BMS_DETAILED_TEMPS_t detailed_msg = {}; - detailed_msg.ic_id = static_cast(_curr_data.detailed_temps_ic_id); - detailed_msg.group_id = static_cast(_curr_data.detailed_temps_group_id); - detailed_msg.thermistor_id_0_ro = HYTECH_thermistor_id_0_ro_toS(_acu_all_data.cell_temps[_curr_data.detailed_temps_cell_id]); - detailed_msg.thermistor_id_1_ro = HYTECH_thermistor_id_1_ro_toS(_acu_all_data.cell_temps[_curr_data.detailed_temps_cell_id+1]); - detailed_msg.thermistor_id_2_ro = HYTECH_thermistor_id_2_ro_toS(_acu_all_data.cell_temps[_curr_data.detailed_temps_cell_id+2]); + BMS_CHIP_TEMPS_t chip_temps_msg = {}; + chip_temps_msg.chip_id = static_cast(_curr_data.current_temp_group_chip_id); + chip_temps_msg.thermistor_group_id = static_cast(_curr_data.current_temp_group_id); + chip_temps_msg.thermistor_group_temp_0_ro = HYTECH_thermistor_group_temp_0_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id]); + chip_temps_msg.thermistor_group_temp_1_ro = HYTECH_thermistor_group_temp_1_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id+1]); + chip_temps_msg.thermistor_group_temp_2_ro = HYTECH_thermistor_group_temp_2_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id+2]); - _curr_data.detailed_temps_group_id = (_curr_data.detailed_temps_group_id == 1) ? 0 : _curr_data.detailed_temps_group_id+1; - if (_curr_data.detailed_temps_group_id == 0) { - _curr_data.detailed_temps_ic_id = (_curr_data.detailed_temps_ic_id == (NUM_CHIPS - 1)) ? 0 : _curr_data.detailed_temps_ic_id+1; + _curr_data.current_temp_group_id = (_curr_data.current_temp_group_id == 1) ? 0 : _curr_data.current_temp_group_id+1; + if (_curr_data.current_temp_group_id == 0) { + _curr_data.current_temp_group_chip_id = (_curr_data.current_temp_group_chip_id == (NUM_CHIPS - 1)) ? 0 : _curr_data.current_temp_group_chip_id+1; } - _curr_data.detailed_temps_cell_id = (_curr_data.detailed_temps_cell_id == (NUM_CELLTEMPS - 3)) ? 0 : _curr_data.detailed_temps_cell_id+3; - CAN_util::enqueue_msg(&detailed_msg, &Pack_BMS_DETAILED_TEMPS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); + _curr_data.current_temp_cell_id = (_curr_data.current_temp_cell_id == (NUM_CELLTEMPS - CELLS_PER_GROUP)) ? 0 : _curr_data.current_temp_cell_id+CELLS_PER_GROUP; + CAN_util::enqueue_msg(&chip_temps_msg, &Pack_BMS_CHIP_TEMPS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); BMS_ONBOARD_TEMPS_t board_temp_msg = {}; board_temp_msg.max_board_temp_ro = HYTECH_max_board_temp_ro_toS(_acu_all_data.core_data.max_board_temp); - board_temp_msg.high_cell_temp_ro = HYTECH_high_cell_temp_ro_toS(_acu_all_data.core_data.max_cell_temp); - board_temp_msg.low_cell_temp_ro = HYTECH_low_cell_temp_ro_toS(_acu_all_data.core_data.min_cell_temp); + board_temp_msg.max_cell_temp_ro = HYTECH_max_cell_temp_ro_toS(_acu_all_data.core_data.max_cell_temp); + board_temp_msg.min_cell_temp_ro = HYTECH_min_cell_temp_ro_toS(_acu_all_data.core_data.min_cell_temp); CAN_util::enqueue_msg(&board_temp_msg, &Pack_BMS_ONBOARD_TEMPS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); - BMS_ONBOARD_DETAILED_TEMPS_t detailed_board_temp_msg = {}; - detailed_board_temp_msg.ic_id = _curr_data.detailed_temps_board_id; - detailed_board_temp_msg.temp_0_ro = HYTECH_temp_0_ro_toS(_acu_all_data.board_temps[_curr_data.detailed_temps_board_id]); - _curr_data.detailed_temps_board_id = (_curr_data.detailed_temps_board_id == (NUM_CHIPS - 1)) ? 0 : _curr_data.detailed_temps_board_id+1; - CAN_util::enqueue_msg(&detailed_board_temp_msg, &Pack_BMS_ONBOARD_DETAILED_TEMPS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); + BMS_ONBOARD_CURRENT_TEMP_t current_board_temp_msg = {}; + current_board_temp_msg.chip_id = _curr_data.current_temp_board_id; + current_board_temp_msg.temp_0_ro = HYTECH_temp_0_ro_toS(_acu_all_data.board_temps[_curr_data.current_temp_board_id]); + _curr_data.current_temp_board_id = (_curr_data.current_temp_board_id == (NUM_CHIPS - 1)) ? 0 : _curr_data.current_temp_board_id+1; + CAN_util::enqueue_msg(¤t_board_temp_msg, &Pack_BMS_ONBOARD_CURRENT_TEMP_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); } void CCUInterface::set_system_latch_state(unsigned long curr_millis, bool is_latched) { diff --git a/platformio.ini b/platformio.ini index 9fda7486..ad54cd80 100644 --- a/platformio.ini +++ b/platformio.ini @@ -73,7 +73,7 @@ test_ignore = lib_deps= ${common.lib_deps_shared} https://github.com/ssilverman/QNEthernet#v0.26.0 - https://github.com/hytech-racing/HT_CAN/releases/download/192/can_lib.tar.gz + https://github.com/hytech-racing/HT_CAN/releases/download/204/can_lib.tar.gz https://github.com/hytech-racing/HT_SCHED.git https://github.com/hytech-racing/HT_proto/releases/download/2025-08-27T15_34_50/hytech_msgs_pb_lib.tar.gz https://github.com/hytech-racing/shared_firmware_interfaces.git From d921c70c01702691cb8266d37843fd5c670c8554 Mon Sep 17 00:00:00 2001 From: Advait Vedant Date: Sun, 9 Nov 2025 16:17:12 -0800 Subject: [PATCH 3/7] updated ccu can to latest version with best naming practices --- lib/interfaces/include/CCUInterface.h | 3 ++- lib/interfaces/src/CCUInterface.cpp | 11 +++++------ platformio.ini | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/interfaces/include/CCUInterface.h b/lib/interfaces/include/CCUInterface.h index 9dd1ec5e..92905c72 100644 --- a/lib/interfaces/include/CCUInterface.h +++ b/lib/interfaces/include/CCUInterface.h @@ -16,7 +16,8 @@ constexpr const size_t NUM_CELLS = 126; constexpr const size_t NUM_CELLTEMPS = 48; constexpr const size_t NUM_CHIPS = 12; -constexpr const size_t CELLS_PER_GROUP = 3; +constexpr const size_t VOLTAGE_CELLS_PER_GROUP = 3; +constexpr const size_t TEMP_CELLS_PER_GROUP = 2; constexpr const size_t GROUPS_PER_IC_EVEN = 4; constexpr const size_t GROUPS_PER_IC_ODD = 3; enum ChargingCommand_e diff --git a/lib/interfaces/src/CCUInterface.cpp b/lib/interfaces/src/CCUInterface.cpp index 8cb2d1f0..50e16357 100644 --- a/lib/interfaces/src/CCUInterface.cpp +++ b/lib/interfaces/src/CCUInterface.cpp @@ -49,7 +49,7 @@ void CCUInterface::handle_enqueue_acu_voltages_CAN_message() { if (_curr_data.current_voltage_cell_group_id == 0) { _curr_data.current_voltage_group_chip_id = (_curr_data.current_voltage_group_chip_id == (NUM_CHIPS - 1)) ? 0 : _curr_data.current_voltage_group_chip_id+1; } - _curr_data.current_voltage_cell_id= (_curr_data.current_voltage_cell_id == NUM_CELLS - CELLS_PER_GROUP) ? 0 : _curr_data.current_voltage_cell_id+CELLS_PER_GROUP; + _curr_data.current_voltage_cell_id= (_curr_data.current_voltage_cell_id == NUM_CELLS - VOLTAGE_CELLS_PER_GROUP) ? 0 : _curr_data.current_voltage_cell_id+VOLTAGE_CELLS_PER_GROUP; CAN_util::enqueue_msg(&msg, &Pack_BMS_CELL_VOLTAGES_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); } @@ -58,15 +58,14 @@ void CCUInterface::handle_enqueue_acu_temps_CAN_message() { BMS_CHIP_TEMPS_t chip_temps_msg = {}; chip_temps_msg.chip_id = static_cast(_curr_data.current_temp_group_chip_id); chip_temps_msg.thermistor_group_id = static_cast(_curr_data.current_temp_group_id); - chip_temps_msg.thermistor_group_temp_0_ro = HYTECH_thermistor_group_temp_0_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id]); - chip_temps_msg.thermistor_group_temp_1_ro = HYTECH_thermistor_group_temp_1_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id+1]); - chip_temps_msg.thermistor_group_temp_2_ro = HYTECH_thermistor_group_temp_2_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id+2]); - + chip_temps_msg.thermistor_cell_group_temp_0_ro = HYTECH_thermistor_cell_group_temp_0_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id]); + chip_temps_msg.thermistor_cell_group_temp_1_ro = HYTECH_thermistor_cell_group_temp_1_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id+1]); + _curr_data.current_temp_group_id = (_curr_data.current_temp_group_id == 1) ? 0 : _curr_data.current_temp_group_id+1; if (_curr_data.current_temp_group_id == 0) { _curr_data.current_temp_group_chip_id = (_curr_data.current_temp_group_chip_id == (NUM_CHIPS - 1)) ? 0 : _curr_data.current_temp_group_chip_id+1; } - _curr_data.current_temp_cell_id = (_curr_data.current_temp_cell_id == (NUM_CELLTEMPS - CELLS_PER_GROUP)) ? 0 : _curr_data.current_temp_cell_id+CELLS_PER_GROUP; + _curr_data.current_temp_cell_id = (_curr_data.current_temp_cell_id == (NUM_CELLTEMPS - TEMP_CELLS_PER_GROUP)) ? 0 : _curr_data.current_temp_cell_id+TEMP_CELLS_PER_GROUP; CAN_util::enqueue_msg(&chip_temps_msg, &Pack_BMS_CHIP_TEMPS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); BMS_ONBOARD_TEMPS_t board_temp_msg = {}; diff --git a/platformio.ini b/platformio.ini index ad54cd80..2ef4eeb0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -73,10 +73,10 @@ test_ignore = lib_deps= ${common.lib_deps_shared} https://github.com/ssilverman/QNEthernet#v0.26.0 - https://github.com/hytech-racing/HT_CAN/releases/download/204/can_lib.tar.gz + https://github.com/hytech-racing/HT_CAN/releases/download/209/can_lib.tar.gz https://github.com/hytech-racing/HT_SCHED.git https://github.com/hytech-racing/HT_proto/releases/download/2025-08-27T15_34_50/hytech_msgs_pb_lib.tar.gz - https://github.com/hytech-racing/shared_firmware_interfaces.git + https://github.com/hytech-racing/shared_firmware_interfaces.git#5baf17a0f6d83d0a9d571d6bf56f409d2c8ad98a https://github.com/KSU-MS/pio-git-hash-gen#7998b5b3f8a2464209b0e73338717998bcf511ee Nanopb arkhipenko/TaskScheduler@^3.8.5 @@ -111,10 +111,10 @@ test_ignore = lib_deps= ${common.lib_deps_shared} https://github.com/ssilverman/QNEthernet#v0.26.0 - https://github.com/hytech-racing/HT_CAN/releases/download/192/can_lib.tar.gz + https://github.com/hytech-racing/HT_CAN/releases/download/209/can_lib.tar.gz https://github.com/hytech-racing/HT_SCHED.git https://github.com/hytech-racing/HT_proto/releases/download/2025-08-27T15_34_50/hytech_msgs_pb_lib.tar.gz - https://github.com/hytech-racing/shared_firmware_interfaces.git + https://github.com/hytech-racing/shared_firmware_interfaces.git#5baf17a0f6d83d0a9d571d6bf56f409d2c8ad98a https://github.com/KSU-MS/pio-git-hash-gen#7998b5b3f8a2464209b0e73338717998bcf511ee Nanopb arkhipenko/TaskScheduler@^3.8.5 From 8602978cae06e61d8057dbafce7ba4b1d355429c Mon Sep 17 00:00:00 2001 From: Advait Vedant Date: Sun, 23 Nov 2025 07:59:04 -0800 Subject: [PATCH 4/7] fixed typo --- lib/interfaces/src/CCUInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/interfaces/src/CCUInterface.cpp b/lib/interfaces/src/CCUInterface.cpp index 1c68db25..6391f123 100644 --- a/lib/interfaces/src/CCUInterface.cpp +++ b/lib/interfaces/src/CCUInterface.cpp @@ -14,7 +14,7 @@ void CCUInterface::receive_CCU_status_message(const CAN_message_t& msg, unsigned } void CCUInterface::handle_enqueue_acu_status_CAN_message() { - BMS_STATUS_t msg = {};s + BMS_STATUS_t msg = {}; if (_curr_data.charging_requested) { msg.charging_state = ChargingCommand_e::CHARGE; } else { From 461dba63a86881d5b6b315ae6fd531385f9eb855 Mon Sep 17 00:00:00 2001 From: Advait Vedant Date: Sun, 23 Nov 2025 08:01:10 -0800 Subject: [PATCH 5/7] removed current prefix --- lib/interfaces/include/CCUInterface.h | 28 ++++++++--------- lib/interfaces/src/CCUInterface.cpp | 44 +++++++++++++-------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/interfaces/include/CCUInterface.h b/lib/interfaces/include/CCUInterface.h index 8655b79f..acbbfde8 100644 --- a/lib/interfaces/include/CCUInterface.h +++ b/lib/interfaces/include/CCUInterface.h @@ -36,13 +36,13 @@ struct CCUCANInterfaceData_s unsigned long prev_ccu_msg_recv_ms; bool charging_requested; bool is_connected_to_CCU; - size_t current_voltage_group_chip_id; - size_t current_voltage_cell_group_id; - size_t current_voltage_cell_id; - size_t current_temp_group_chip_id; - size_t current_temp_group_id; - size_t current_temp_cell_id; - size_t current_temp_board_id; + size_t voltage_group_chip_id; + size_t voltage_cell_group_id; + size_t voltage_cell_id; + size_t temp_group_chip_id; + size_t temp_group_id; + size_t temp_cell_id; + size_t temp_board_id; }; struct CCUInterfaceParams_s { @@ -78,13 +78,13 @@ class CCUInterface _curr_data.prev_ccu_msg_recv_ms = 0; _curr_data.charging_requested = false; _curr_data.is_connected_to_CCU = false; - _curr_data.current_voltage_cell_group_id = 0; - _curr_data.current_voltage_group_chip_id = 0; - _curr_data.current_voltage_cell_id = 0; - _curr_data.current_temp_group_id = 0; - _curr_data.current_temp_group_chip_id = 0; - _curr_data.current_temp_cell_id = 0; - _curr_data.current_temp_board_id = 0; + _curr_data.voltage_cell_group_id = 0; + _curr_data.voltage_group_chip_id = 0; + _curr_data.voltage_cell_id = 0; + _curr_data.temp_group_id = 0; + _curr_data.temp_group_chip_id = 0; + _curr_data.temp_cell_id = 0; + _curr_data.temp_board_id = 0; }; bool is_charging_requested() { return _curr_data.charging_requested; } diff --git a/lib/interfaces/src/CCUInterface.cpp b/lib/interfaces/src/CCUInterface.cpp index 6391f123..d4496f6b 100644 --- a/lib/interfaces/src/CCUInterface.cpp +++ b/lib/interfaces/src/CCUInterface.cpp @@ -35,37 +35,37 @@ void CCUInterface::handle_enqueue_acu_core_voltages_CAN_message() { void CCUInterface::handle_enqueue_acu_voltages_CAN_message() { BMS_CELL_VOLTAGES_t msg = {}; - msg.chip_id = static_cast(_curr_data.current_voltage_group_chip_id); - msg.cell_group_id = static_cast(_curr_data.current_voltage_cell_group_id); - msg.cell_group_voltage_0_ro = HYTECH_cell_group_voltage_0_ro_toS(_acu_all_data.cell_voltages[_curr_data.current_voltage_cell_id]); - msg.cell_group_voltage_1_ro = HYTECH_cell_group_voltage_1_ro_toS(_acu_all_data.cell_voltages[_curr_data.current_voltage_cell_id+1]); - msg.cell_group_voltage_2_ro = HYTECH_cell_group_voltage_2_ro_toS(_acu_all_data.cell_voltages[_curr_data.current_voltage_cell_id+2]); + msg.chip_id = static_cast(_curr_data.voltage_group_chip_id); + msg.cell_group_id = static_cast(_curr_data.voltage_cell_group_id); + msg.cell_group_voltage_0_ro = HYTECH_cell_group_voltage_0_ro_toS(_acu_all_data.cell_voltages[_curr_data.voltage_cell_id]); + msg.cell_group_voltage_1_ro = HYTECH_cell_group_voltage_1_ro_toS(_acu_all_data.cell_voltages[_curr_data.voltage_cell_id+1]); + msg.cell_group_voltage_2_ro = HYTECH_cell_group_voltage_2_ro_toS(_acu_all_data.cell_voltages[_curr_data.voltage_cell_id+2]); - if (_curr_data.current_voltage_group_chip_id % 2 == 0) { - _curr_data.current_voltage_cell_group_id = (_curr_data.current_voltage_cell_group_id == _ccu_params.groups_per_ic_even - 1) ? 0 : _curr_data.current_voltage_cell_group_id+1; + if (_curr_data.voltage_group_chip_id % 2 == 0) { + _curr_data.voltage_cell_group_id = (_curr_data.voltage_cell_group_id == _ccu_params.groups_per_ic_even - 1) ? 0 : _curr_data.voltage_cell_group_id+1; } else { - _curr_data.current_voltage_cell_group_id = (_curr_data.current_voltage_cell_group_id == _ccu_params.groups_per_ic_odd - 1) ? 0 : _curr_data.current_voltage_cell_group_id+1; + _curr_data.voltage_cell_group_id = (_curr_data.voltage_cell_group_id == _ccu_params.groups_per_ic_odd - 1) ? 0 : _curr_data.voltage_cell_group_id+1; } - if (_curr_data.current_voltage_cell_group_id == 0) { - _curr_data.current_voltage_group_chip_id = (_curr_data.current_voltage_group_chip_id == (_ccu_params.num_chips - 1)) ? 0 : _curr_data.current_voltage_group_chip_id+1; + if (_curr_data.voltage_cell_group_id == 0) { + _curr_data.voltage_group_chip_id = (_curr_data.voltage_group_chip_id == (_ccu_params.num_chips - 1)) ? 0 : _curr_data.voltage_group_chip_id+1; } - _curr_data.current_voltage_cell_id= (_curr_data.current_voltage_cell_id == _ccu_params.num_cells - _ccu_params.voltage_cells_per_group) ? 0 : _curr_data.current_voltage_cell_id+_ccu_params.voltage_cells_per_group; + _curr_data.voltage_cell_id= (_curr_data.voltage_cell_id == _ccu_params.num_cells - _ccu_params.voltage_cells_per_group) ? 0 : _curr_data.voltage_cell_id+_ccu_params.voltage_cells_per_group; CAN_util::enqueue_msg(&msg, &Pack_BMS_CELL_VOLTAGES_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); } void CCUInterface::handle_enqueue_acu_temps_CAN_message() { BMS_CHIP_TEMPS_t chip_temps_msg = {}; - chip_temps_msg.chip_id = static_cast(_curr_data.current_temp_group_chip_id); - chip_temps_msg.thermistor_group_id = static_cast(_curr_data.current_temp_group_id); - chip_temps_msg.thermistor_cell_group_temp_0_ro = HYTECH_thermistor_cell_group_temp_0_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id]); - chip_temps_msg.thermistor_cell_group_temp_1_ro = HYTECH_thermistor_cell_group_temp_1_ro_toS(_acu_all_data.cell_temps[_curr_data.current_temp_cell_id+1]); + chip_temps_msg.chip_id = static_cast(_curr_data.temp_group_chip_id); + chip_temps_msg.thermistor_group_id = static_cast(_curr_data.temp_group_id); + chip_temps_msg.thermistor_cell_group_temp_0_ro = HYTECH_thermistor_cell_group_temp_0_ro_toS(_acu_all_data.cell_temps[_curr_data.temp_cell_id]); + chip_temps_msg.thermistor_cell_group_temp_1_ro = HYTECH_thermistor_cell_group_temp_1_ro_toS(_acu_all_data.cell_temps[_curr_data.temp_cell_id+1]); - _curr_data.current_temp_group_id = (_curr_data.current_temp_group_id == 1) ? 0 : _curr_data.current_temp_group_id+1; - if (_curr_data.current_temp_group_id == 0) { - _curr_data.current_temp_group_chip_id = (_curr_data.current_temp_group_chip_id == (_ccu_params.num_chips - 1)) ? 0 : _curr_data.current_temp_group_chip_id+1; + _curr_data.temp_group_id = (_curr_data.temp_group_id == 1) ? 0 : _curr_data.temp_group_id+1; + if (_curr_data.temp_group_id == 0) { + _curr_data.temp_group_chip_id = (_curr_data.temp_group_chip_id == (_ccu_params.num_chips - 1)) ? 0 : _curr_data.temp_group_chip_id+1; } - _curr_data.current_temp_cell_id = (_curr_data.current_temp_cell_id == (_ccu_params.num_celltemps - _ccu_params.temp_cells_per_group)) ? 0 : _curr_data.current_temp_cell_id+_ccu_params.temp_cells_per_group; + _curr_data.temp_cell_id = (_curr_data.temp_cell_id == (_ccu_params.num_celltemps - _ccu_params.temp_cells_per_group)) ? 0 : _curr_data.temp_cell_id+_ccu_params.temp_cells_per_group; CAN_util::enqueue_msg(&chip_temps_msg, &Pack_BMS_CHIP_TEMPS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); BMS_ONBOARD_TEMPS_t board_temp_msg = {}; @@ -75,9 +75,9 @@ void CCUInterface::handle_enqueue_acu_temps_CAN_message() { CAN_util::enqueue_msg(&board_temp_msg, &Pack_BMS_ONBOARD_TEMPS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); BMS_ONBOARD_CURRENT_TEMP_t current_board_temp_msg = {}; - current_board_temp_msg.chip_id = _curr_data.current_temp_board_id; - current_board_temp_msg.temp_0_ro = HYTECH_temp_0_ro_toS(_acu_all_data.board_temps[_curr_data.current_temp_board_id]); - _curr_data.current_temp_board_id = (_curr_data.current_temp_board_id == (_ccu_params.num_chips - 1)) ? 0 : _curr_data.current_temp_board_id+1; + current_board_temp_msg.chip_id = _curr_data.temp_board_id; + current_board_temp_msg.temp_0_ro = HYTECH_temp_0_ro_toS(_acu_all_data.board_temps[_curr_data.temp_board_id]); + _curr_data.temp_board_id = (_curr_data.temp_board_id == (_ccu_params.num_chips - 1)) ? 0 : _curr_data.temp_board_id+1; CAN_util::enqueue_msg(¤t_board_temp_msg, &Pack_BMS_ONBOARD_CURRENT_TEMP_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); } From 103464dc1999c270acf3ead6ccf4ff3731a9edf0 Mon Sep 17 00:00:00 2001 From: Advait Vedant Date: Sun, 30 Nov 2025 18:39:04 -0500 Subject: [PATCH 6/7] temp testing fix --- lib/interfaces/include/CCUInterface.h | 5 ---- lib/interfaces/src/CCUInterface.cpp | 4 +-- src/ACU_InterfaceTasks.cpp | 40 +++++++++++++-------------- src/main.cpp | 2 +- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/lib/interfaces/include/CCUInterface.h b/lib/interfaces/include/CCUInterface.h index acbbfde8..ad83d970 100644 --- a/lib/interfaces/include/CCUInterface.h +++ b/lib/interfaces/include/CCUInterface.h @@ -14,11 +14,6 @@ #include "shared_types.h" -enum ChargingCommand_e -{ - CHARGE = 0, - IDLE = 1, -}; namespace ccu_interface_defaults{ constexpr const uint16_t MIN_CHARGING_ENABLE_THRESHOLD_MS = 1000; constexpr const size_t NUM_CELLS = 126; diff --git a/lib/interfaces/src/CCUInterface.cpp b/lib/interfaces/src/CCUInterface.cpp index d4496f6b..0c166656 100644 --- a/lib/interfaces/src/CCUInterface.cpp +++ b/lib/interfaces/src/CCUInterface.cpp @@ -16,9 +16,9 @@ void CCUInterface::receive_CCU_status_message(const CAN_message_t& msg, unsigned void CCUInterface::handle_enqueue_acu_status_CAN_message() { BMS_STATUS_t msg = {}; if (_curr_data.charging_requested) { - msg.charging_state = ChargingCommand_e::CHARGE; + msg.charging_state = true; } else { - msg.charging_state = ChargingCommand_e::IDLE; + msg.charging_state = false; } CAN_util::enqueue_msg(&msg, &Pack_BMS_STATUS_hytech, ACUCANInterfaceImpl::ccu_can_tx_buffer); diff --git a/src/ACU_InterfaceTasks.cpp b/src/ACU_InterfaceTasks.cpp index 136580cc..b8455766 100644 --- a/src/ACU_InterfaceTasks.cpp +++ b/src/ACU_InterfaceTasks.cpp @@ -359,26 +359,26 @@ HT_TASK::TaskResponse debug_print(const unsigned long &sysMicros, const HT_TASK: Serial.print("Number of Global Faults: "); Serial.println(BMSFaultDataManager_t::instance().get_fault_data().max_consecutive_invalid_packet_count); - // Serial.println("Number of Consecutive Faults Per Chip: "); - // for (size_t c = 0; c < ACUConstants::NUM_CHIPS; c++) { - // Serial.print("CHIP "); - // Serial.print(c); - // Serial.print(": "); - // Serial.print(ACUFaultDataInstance::instance().consecutive_invalid_packet_counts[c]); - // Serial.print("\t"); - // Serial.print(ACUFaultDataInstance::instance().chip_invalid_cmd_counts[c].invalid_cell_1_to_3_count); - // Serial.print(" "); - // Serial.print(ACUFaultDataInstance::instance().chip_invalid_cmd_counts[c].invalid_cell_4_to_6_count); - // Serial.print(" "); - // Serial.print(ACUFaultDataInstance::instance().chip_invalid_cmd_counts[c].invalid_cell_7_to_9_count); - // Serial.print(" "); - // Serial.print(ACUFaultDataInstance::instance().chip_invalid_cmd_counts[c].invalid_cell_10_to_12_count); - // Serial.print(" "); - // Serial.print(ACUFaultDataInstance::instance().chip_invalid_cmd_counts[c].invalid_gpio_1_to_3_count); - // Serial.print(" "); - // Serial.print(ACUFaultDataInstance::instance().chip_invalid_cmd_counts[c].invalid_gpio_4_to_6_count); - // Serial.print(" "); - // } + Serial.println("Number of Consecutive Faults Per Chip: "); + for (size_t c = 0; c < ACUConstants::NUM_CHIPS; c++) { + Serial.print("CHIP "); + Serial.print(c); + Serial.print(": "); + Serial.print(BMSFaultDataManager_t::instance().get_fault_data().consecutive_invalid_packet_counts[c]); + Serial.print("\t"); + Serial.print(BMSFaultDataManager_t::instance().get_fault_data().chip_invalid_cmd_counts[c].invalid_cell_1_to_3_count); + Serial.print(" "); + Serial.print(BMSFaultDataManager_t::instance().get_fault_data().chip_invalid_cmd_counts[c].invalid_cell_4_to_6_count); + Serial.print(" "); + Serial.print(BMSFaultDataManager_t::instance().get_fault_data().chip_invalid_cmd_counts[c].invalid_cell_7_to_9_count); + Serial.print(" "); + Serial.print(BMSFaultDataManager_t::instance().get_fault_data().chip_invalid_cmd_counts[c].invalid_cell_10_to_12_count); + Serial.print(" "); + Serial.print(BMSFaultDataManager_t::instance().get_fault_data().chip_invalid_cmd_counts[c].invalid_gpio_1_to_3_count); + Serial.print(" "); + Serial.print(BMSFaultDataManager_t::instance().get_fault_data().chip_invalid_cmd_counts[c].invalid_gpio_4_to_6_count); + Serial.print(" "); + } // Serial.println(); return HT_TASK::TaskResponse::YIELD; diff --git a/src/main.cpp b/src/main.cpp index 48754f87..8afebe79 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -65,7 +65,7 @@ void setup() scheduler.schedule(sample_CAN_task); scheduler.schedule(idle_sample_task); - //scheduler.schedule(debug_prints_task); + scheduler.schedule(debug_prints_task); handle_CAN_setup(ACUCANInterfaceImpl::CCU_CAN, ACUConstants::Veh_CAN_baudrate, &ACUCANInterfaceImpl::on_ccu_can_receive); handle_CAN_setup(ACUCANInterfaceImpl::EM_CAN, ACUConstants::EM_CAN_baudrate, &ACUCANInterfaceImpl::on_em_can_receive); From c9139785c9bb71876246aee0328c4f981914cfed Mon Sep 17 00:00:00 2001 From: Advait Vedant Date: Sun, 30 Nov 2025 18:49:56 -0500 Subject: [PATCH 7/7] fixed issue in last commit with enum being too large to send over CAN --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8afebe79..49c97bdc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -65,7 +65,7 @@ void setup() scheduler.schedule(sample_CAN_task); scheduler.schedule(idle_sample_task); - scheduler.schedule(debug_prints_task); + // scheduler.schedule(debug_prints_task); handle_CAN_setup(ACUCANInterfaceImpl::CCU_CAN, ACUConstants::Veh_CAN_baudrate, &ACUCANInterfaceImpl::on_ccu_can_receive); handle_CAN_setup(ACUCANInterfaceImpl::EM_CAN, ACUConstants::EM_CAN_baudrate, &ACUCANInterfaceImpl::on_em_can_receive);