3#include "HytechCANInterface.h"
4#include "InverterInterface.h"
6FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16>
TEST_CAN1;
7FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16>
TEST_CAN2;
56 msg.id = random(0x1, 0x7FE);
57 for (uint8_t i = 0; i < 8; i++)
62 Serial.println(
"======= TEST 1 =======");
63 Serial.println(
"can1 rx buffer size: (should be 1)");
65 Serial.println(
"======= TEST 2 =======");
67 Serial.println(
"can1 received message equal to sent msg");
71 CAN_message_t recvd_msg;
72 uint8_t buf[
sizeof(CAN_message_t)];
74 memmove(&recvd_msg, buf,
sizeof(recvd_msg));
76 Serial.println(
"\tid = prev: (should be 1)");
78 Serial.println(recvd_msg.id ==
msg.id);
81 Serial.println(
"======= TEST 3 =======");
92 Serial.println(
"can2 tx buffer size: (should be 1)");
97 Serial.println(
"can2 tx buffer size: (should be 0)");
100 Serial.println(
"sent on can2");
102 Serial.println(
"can1 rx buffer size: (should be 1) ");
107 Serial.println(
"sent on can2");
108 Serial.println(
"can1 rx buffer size: (should be 0) ");
111 Serial.println(
"======= TEST 4 =======");
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)
123 MC_setpoints_command
msg;
124 msg.load(recvd_msg.buf);
125 if (
msg.get_remove_error())
128 Serial.println(
"GOOD received correct inverter reset");
132 Serial.println(
"ERROR didnt receive correct id");
133 Serial.println(recvd_msg.id);
134 Serial.println(ID_MC3_SETPOINTS_COMMAND);
Circular_Buffer< uint8_t,(uint32_t) 128, sizeof(CAN_message_t)> CANBufferType
void on_can2_receive(const CAN_message_t &msg)
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
void on_can1_receive(const CAN_message_t &msg)
CANBufferType CAN2_txBuffer
CANBufferType CircularBufferType
InverterInterfaceType fl_inv
InverterInterface< CircularBufferType > InverterInterfaceType
void init_can_interface()
FlexCAN_T4< CAN2, RX_SIZE_256, TX_SIZE_16 > TEST_CAN2
CANInterfaces< CircularBufferType > CAN_interfaces
InverterInterfaceType rl_inv
FlexCAN_T4< CAN1, RX_SIZE_256, TX_SIZE_16 > TEST_CAN1
InverterInterfaceType fr_inv
InverterInterfaceType rr_inv