-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVCFCANInterfaceImpl.cpp
More file actions
94 lines (88 loc) · 3.31 KB
/
VCFCANInterfaceImpl.cpp
File metadata and controls
94 lines (88 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "VCFCANInterfaceImpl.h"
#include "BuzzerController.h"
namespace VCFCANInterfaceImpl {
void on_main_can_recv(const CAN_message_t &msg)
{
uint8_t buf[sizeof(CAN_message_t)];
memmove(buf, &msg, sizeof(msg)); // NOLINT (memory operations are fine)
VCFCANInterfaceInstance::instance().telem_can_rx_buffer.push_back(buf, sizeof(CAN_message_t));
}
void on_faux_can_recv(const CAN_message_t &msg)
{
// VCFCANInterfaceInstance::instance().TELEM_CAN.write(msg); //immediately forward onto telem can to view data
uint8_t buf[sizeof(CAN_message_t)];
memmove(buf, &msg, sizeof(msg)); // NOLINT (memory operations are fine)
VCFCANInterfaceInstance::instance().front_aux_can_rx_buffer.push_back(buf, sizeof(CAN_message_t));
}
void vcf_recv_switch(CANInterfaces &interfaces, const CAN_message_t &msg, unsigned long millis, CANInterfaceType_e interface_type)
{
switch (msg.id)
{
case DASHBOARD_BUZZER_CONTROL_CANID:
{
interfaces.vcr_interface.receive_dash_control_data(msg);
break;
}
case BMS_VOLTAGES_CANID:
{
interfaces.acu_interface.receive_ACU_voltages(msg);
break;
}
case ACU_OK_CANID:
{
interfaces.dash_interface.receive_ACU_OK(msg);
break;
}
case CAR_STATES_CANID:
{
interfaces.vcr_interface.receive_car_states_data(msg);
break;
}
case INV1_STATUS_CANID:
{
interfaces.vcr_interface.receive_inverter_status_1(msg);
break;
}
case INV2_STATUS_CANID:
{
interfaces.vcr_interface.receive_inverter_status_2(msg);
break;
}
case INV3_STATUS_CANID:
{
interfaces.vcr_interface.receive_inverter_status_3(msg);
break;
}
case INV4_STATUS_CANID:
{
interfaces.vcr_interface.receive_inverter_status_4(msg);
break;
}
case FL_BRAKE_ROTOR_SENSOR_TEMP_CANID:
case FL_BRAKE_ROTOR_TEMP_CH1_CH4_CANID:
case FL_BRAKE_ROTOR_TEMP_CH5_CH8_CANID:
case FL_BRAKE_ROTOR_TEMP_CH9_CH12_CANID:
case FL_BRAKE_ROTOR_TEMP_CH13_CH16_CANID:
case FR_BRAKE_ROTOR_SENSOR_TEMP_CANID:
case FR_BRAKE_ROTOR_TEMP_CH1_CH4_CANID:
case FR_BRAKE_ROTOR_TEMP_CH5_CH8_CANID:
case FR_BRAKE_ROTOR_TEMP_CH9_CH12_CANID:
case FR_BRAKE_ROTOR_TEMP_CH13_CH16_CANID:
interfaces.brake_rotor_temp_interface.receiveBrakeRotorTempData(msg);
break;
default:
break;
}
}
void send_all_CAN_msgs(CANTXBufferType &buffer, FlexCAN_T4_Base *can_interface)
{
CAN_message_t msg;
while (buffer.available()) {
CAN_message_t msg;
uint8_t buf[sizeof(CAN_message_t)];
buffer.pop_front(buf, sizeof(CAN_message_t));
memmove(&msg, buf, sizeof(msg)); // NOLINT (memory operations are fine)
can_interface->write(msg);
}
}
}