50{
51
52
53
55 {
56 msg.id = random(0x1, 0x7FE);
57 for (uint8_t i = 0; i < 8; i++)
61 delay(10);
62 Serial.println("======= TEST 1 =======");
63 Serial.println("can1 rx buffer size: (should be 1)");
65 Serial.println("======= TEST 2 =======");
66
67 Serial.println("can1 received message equal to sent msg");
68 delay(10);
70 {
71 CAN_message_t recvd_msg;
72 uint8_t buf[sizeof(CAN_message_t)];
74 memmove(&recvd_msg, buf, sizeof(recvd_msg));
75
76 Serial.println("\tid = prev: (should be 1)");
77 Serial.print("\t");
78 Serial.println(recvd_msg.id ==
msg.id);
79 }
80
81 Serial.println("======= TEST 3 =======");
82
83
85
86
87
88
89
90
91
92 Serial.println("can2 tx buffer size: (should be 1)");
93
96
97 Serial.println("can2 tx buffer size: (should be 0)");
98
100 Serial.println("sent on can2");
101 delay(10);
102 Serial.println("can1 rx buffer size: (should be 1) ");
104 Serial.println();
106
107 Serial.println("sent on can2");
108 Serial.println("can1 rx buffer size: (should be 0) ");
110
111 Serial.println("======= TEST 4 =======");
112
115
116 delay(10);
117 CAN_message_t recvd_msg;
118 uint8_t buf[sizeof(CAN_message_t)];
120 memmove(&recvd_msg, buf, sizeof(recvd_msg));
121 if (recvd_msg.id == ID_MC3_SETPOINTS_COMMAND)
122 {
123 MC_setpoints_command
msg;
124 msg.load(recvd_msg.buf);
125 if (
msg.get_remove_error())
126 {
127
128 Serial.println("GOOD received correct inverter reset");
129 }
130 } else{
131
132 Serial.println("ERROR didnt receive correct id");
133 Serial.println(recvd_msg.id);
134 Serial.println(ID_MC3_SETPOINTS_COMMAND);
135 }
136 }
137}
void process_ring_buffer(BufferType &rx_buffer, const InterfaceType &interfaces, unsigned long curr_millis)
void send_all_CAN_msgs(bufferType &buffer, FlexCAN_T4_Base *can_interface)
Circular_Buffer< uint8_t,(uint32_t) 16, sizeof(CAN_message_t)> CAN1_rxBuffer
CANBufferType CAN2_txBuffer
CANInterfaces< CircularBufferType > CAN_interfaces
InverterInterfaceType rl_inv