reword functions in CAN communication

This commit is contained in:
lenvm 2024-12-24 21:42:21 +01:00
parent e5b0481903
commit 0b096010c1
88 changed files with 701 additions and 685 deletions

View file

@ -1149,7 +1149,7 @@ void update_values_battery() { //This function maps all the values fetched via
#endif //DEBUG_LOG
}
void receive_can_battery(CAN_frame rx_frame) {
void map_can_frame_to_variable_battery(CAN_frame rx_frame) {
static uint8_t mux = 0;
static uint16_t temp = 0;
@ -1808,7 +1808,7 @@ void receive_can_battery(CAN_frame rx_frame) {
#ifdef DOUBLE_BATTERY //Need to update battery2
void receive_can_battery2(CAN_frame rx_frame) {
void map_can_frame_to_variable_battery2(CAN_frame rx_frame) {
static uint8_t mux = 0;
static uint16_t temp = 0;
@ -2621,7 +2621,7 @@ int index_1CF = 0;
int index_118 = 0;
#endif //defined(TESLA_MODEL_SX_BATTERY) || defined(EXP_TESLA_BMS_DIGITAL_HVIL)
void send_can_battery() {
void transmit_can_battery() {
/*From bielec: My fist 221 message, to close the contactors is 0x41, 0x11, 0x01, 0x00, 0x00, 0x00, 0x20, 0x96 and then,
to cause "hv_up_for_drive" I send an additional 221 message 0x61, 0x15, 0x01, 0x00, 0x00, 0x00, 0x20, 0xBA so
two 221 messages are being continuously transmitted. When I want to shut down, I stop the second message and only send
@ -2632,10 +2632,10 @@ the first, for a few cycles, then stop all messages which causes the contactor
#if defined(TESLA_MODEL_SX_BATTERY) || defined(EXP_TESLA_BMS_DIGITAL_HVIL)
if ((datalayer.system.status.inverter_allows_contactor_closing) && (datalayer.battery.status.bms_status != FAULT)) {
if (currentMillis - lastSend1CF >= 10) {
transmit_can(&can_msg_1CF[index_1CF], can_config.battery);
transmit_can_frame(&can_msg_1CF[index_1CF], can_config.battery);
#ifdef DOUBLE_BATTERY
transmit_can(&can_msg_1CF[index_1CF], can_config.battery_double);
transmit_can_frame(&can_msg_1CF[index_1CF], can_config.battery_double);
#endif // DOUBLE_BATTERY
index_1CF = (index_1CF + 1) % 8;
@ -2643,9 +2643,9 @@ the first, for a few cycles, then stop all messages which causes the contactor
}
if (currentMillis - lastSend118 >= 10) {
transmit_can(&can_msg_118[index_118], can_config.battery);
transmit_can_frame(&can_msg_118[index_118], can_config.battery);
#ifdef DOUBLE_BATTERY
transmit_can(&can_msg_1CF[index_1CF], can_config.battery_double);
transmit_can_frame(&can_msg_1CF[index_1CF], can_config.battery_double);
#endif //DOUBLE_BATTERY
index_118 = (index_118 + 1) % 16;
@ -2670,21 +2670,21 @@ the first, for a few cycles, then stop all messages which causes the contactor
if ((datalayer.system.status.inverter_allows_contactor_closing == true) &&
(datalayer.battery.status.bms_status != FAULT)) {
sendContactorClosingMessagesStill = 300;
transmit_can(&TESLA_221_1, can_config.battery);
transmit_can(&TESLA_221_2, can_config.battery);
transmit_can_frame(&TESLA_221_1, can_config.battery);
transmit_can_frame(&TESLA_221_2, can_config.battery);
#ifdef DOUBLE_BATTERY
if (datalayer.system.status.battery2_allows_contactor_closing) {
transmit_can(&TESLA_221_1, can_config.battery_double);
transmit_can(&TESLA_221_2, can_config.battery_double);
transmit_can_frame(&TESLA_221_1, can_config.battery_double);
transmit_can_frame(&TESLA_221_2, can_config.battery_double);
}
#endif //DOUBLE_BATTERY
} else { // Faulted state, or inverter blocks contactor closing
if (sendContactorClosingMessagesStill > 0) {
transmit_can(&TESLA_221_1, can_config.battery);
transmit_can_frame(&TESLA_221_1, can_config.battery);
sendContactorClosingMessagesStill--;
#ifdef DOUBLE_BATTERY
transmit_can(&TESLA_221_1, can_config.battery_double);
transmit_can_frame(&TESLA_221_1, can_config.battery_double);
#endif //DOUBLE_BATTERY
}
}