Skip to content
Draft
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
516b74a
fixed deleting nodes and added strict modification logic
coderask Mar 22, 2026
2ce4c86
Automatic Web Format: Standardized formatting automatically
github-actions[bot] Mar 22, 2026
b52e647
does not use header files anymore, everything is parsed from CANDO file
coderask Mar 24, 2026
cf2d7c2
Automatic Web Format: Standardized formatting automatically
github-actions[bot] Mar 24, 2026
6f20c55
Merge branch 'main' into GRCANDO_editor_refinement
dchansen06 Mar 25, 2026
2f8bce4
fix lots of duplicate files
coderask Mar 26, 2026
cb757ad
fix custom msg descriptions + UI cleanup + code cleanup
coderask Mar 27, 2026
ffb8ab9
Automatic Web Format: Standardized formatting automatically
github-actions[bot] Mar 27, 2026
64c73b3
updated GRCAN.CANdo file
coderask Mar 27, 2026
692f245
message expanded by default
coderask Mar 27, 2026
28a9bbd
Merge branch 'main' into GRCANDO_editor_refinement
dchansen06 Mar 28, 2026
db955ab
partial update + beta graph view
coderask Mar 29, 2026
5d7fd96
partial update + beta graph view
coderask Mar 29, 2026
f8cf3fc
Automatic Web Format: Standardized formatting automatically
github-actions[bot] Mar 29, 2026
b2fc7f3
Merge branch 'main' into GRCANDO_editor_refinement
dchansen06 Mar 30, 2026
24ff97a
CROSS CHECK - Setup ECU state as bit instead of number
dchansen06 Mar 30, 2026
c021bfb
Fix numbers for bit start
dchansen06 Mar 30, 2026
e03e9b9
CROSS CHECK - Setup new ECU ping block map and cascade changes
dchansen06 Mar 30, 2026
31fd169
CROSS CHECK - No longer have ECU pinging itself
dchansen06 Mar 30, 2026
4b15f5e
CROSS CHECK - Remove extraneous can id override
dchansen06 Mar 30, 2026
4697fbc
fix minor stuff
coderask Mar 31, 2026
5c44a21
Automatic Web Format: Standardized formatting automatically
github-actions[bot] Mar 31, 2026
e92a054
Automatic Web Format: Standardized formatting automatically
github-actions[bot] Mar 31, 2026
bd477b9
add ECU perofmrance message
coderask Mar 31, 2026
fec5910
Ecu thing
coderask Mar 31, 2026
20bd25c
Merge branch 'main' into GRCANDO_editor_refinement
dchansen06 Mar 31, 2026
a48cc43
fix things for merge
coderask Mar 31, 2026
38af778
Automatic Web Format: Standardized formatting automatically
github-actions[bot] Mar 31, 2026
90ef335
fix cando
coderask Mar 31, 2026
7f83575
fix cando with tabbed comments
coderask Mar 31, 2026
0813840
good tabs
coderask Mar 31, 2026
ff0f549
fix github actions
coderask Mar 31, 2026
c21bb6c
Caroline com (#387)
CrolineCrois Mar 31, 2026
35e207e
fixed STRUCTparser
coderask Mar 31, 2026
5cd6c04
Automatic Perl Tidy: Standardized formatting automatically
github-actions[bot] Mar 31, 2026
185dbc7
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Mar 31, 2026
57b59db
fix linter errors
coderask Mar 31, 2026
2eb7aeb
Merge branch 'main' into GRCANDO_editor_refinement
dchansen06 Mar 31, 2026
09afdab
added state messages and modified STRUCTparser
krai19 Apr 1, 2026
5eb46cb
Merge branch 'GRCANDO_editor_refinement' of https://github.com/Gaucho…
krai19 Apr 1, 2026
2e2db73
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Apr 1, 2026
e4ffde2
Automatic Perl Tidy: Standardized formatting automatically
github-actions[bot] Apr 1, 2026
4ee18e6
Cross-check -- Made using website
dchansen06 Apr 2, 2026
75b0db4
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Apr 2, 2026
db01374
Change `GR_OLD` to `GRCAN` for struct parser
dchansen06 Apr 2, 2026
aa3e61f
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Apr 2, 2026
47c37b0
Fix bus file naming convention
dchansen06 Apr 3, 2026
11427ee
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Apr 3, 2026
e01a39e
Fix easy renames
dchansen06 Apr 3, 2026
faf1f26
Turn off autogen
dchansen06 Apr 3, 2026
9e5a741
Autogen CI/CD comment
dchansen06 Apr 3, 2026
9483a7c
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
675576a
Final few touchups
dchansen06 Apr 3, 2026
dc685f1
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
7e7b908
Add ECU node ID to GRCAN_NODE_ID enum
dchansen06 Apr 3, 2026
6d38258
Delete leftovers.txt
dchansen06 Apr 3, 2026
6fc6927
Delete GRCAN_DC_DC_STATUS_MSG structure
dchansen06 Apr 3, 2026
4e51ae2
Break old CAN implementation
dchansen06 Apr 2, 2026
0650f82
Remove unused link libraries from CCU
dchansen06 Apr 2, 2026
dfb58a2
Missed a few holdovers of the `GR_OLD_CAN_MESSAGES` linked library
dchansen06 Apr 2, 2026
1f003c4
Merge branch 'main' into GrandCanMigration
dchansen06 Apr 3, 2026
83babff
Rename state_messages to ecu_state
dchansen06 Apr 3, 2026
7521211
Changed GR_OLD to GRCAN, did some debugging on discovered errors in m…
anthony9975 Apr 3, 2026
6ddcb59
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
bc428db
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
d5b5262
CAN changes are done, all bugs fixed (for now)
anthony9975 Apr 3, 2026
f53a6ba
Merge branch 'GrandCanMigration' of github.com:Gaucho-Racing/Firmware…
anthony9975 Apr 3, 2026
5be9a28
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
76398af
updated gitignore to not ignore header files
coderask Apr 3, 2026
3ffaa61
intial naming correction
captainwerty Apr 3, 2026
e14c266
More changes to Dash Status main.c and CANdler.c
anthony9975 Apr 3, 2026
70e8f33
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
3498436
Merge branch 'GrandCanMigration' of https://github.com/Gaucho-Racing/…
captainwerty Apr 3, 2026
f78f63a
updated read can and send precharge
captainwerty Apr 3, 2026
7c33f4c
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
9845b83
fix minor bugs in SendPrecharge
captainwerty Apr 3, 2026
ca6a9e5
fix minor bug in ReadCAN
captainwerty Apr 3, 2026
8053076
Fixed SendPrecharge CAN msg
captainwerty Apr 3, 2026
0284a7e
Added timer stuff for CAN
anthony9975 Apr 3, 2026
f033113
Merge branch 'GrandCanMigration' of github.com:Gaucho-Racing/Firmware…
anthony9975 Apr 3, 2026
e59541e
Ecu performance
coderask Apr 3, 2026
13e72f4
hal timer not working :(
horizon-ab Apr 3, 2026
e896058
systick interrupt works; CAN triggers every 100ms
horizon-ab Apr 3, 2026
38a6625
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
e15a4be
Changed DataLength to FDCAN_DLC_BYTES_1
dwilson765 Apr 3, 2026
05182bf
Rename pedals data to analog data
dchansen06 Apr 3, 2026
e2361db
comment out unused variables in `main.c` of DashPanel
SlowThomas Apr 3, 2026
e5c2274
ECU CAN Migration (#392)
SlowThomas Apr 3, 2026
bb7deff
Change node IDs back to be `GRCAN_*`
dchansen06 Apr 3, 2026
d230c4d
Match syntax of message IDs as node IDs and such since names are unique
dchansen06 Apr 3, 2026
01b91e0
Fix remaining message names I missed during change over
dchansen06 Apr 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Autogen/CAN/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ inc/
!inc/output.dbc

# CANfigurator
Inc/*.h
Doc/*.dbc
15 changes: 13 additions & 2 deletions Autogen/CAN/Doc/GRCAN.CANdo
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ routing:
- msg: Debug FD
- msg: Ping
TCM:
- msg: ECU Pedals Data
- msg: ECU Analog Data
- msg: ECU Performance
Energy Meter:
CAN3:
BCU:
Expand Down Expand Up @@ -3903,7 +3904,7 @@ Message ID:
comment: Literal copy of ECU Status's status bit map
data type: b[24]
units: Bool map
ECU Pedals Data:
ECU Analog Data:
MSG ID: 0x02E
MSG LENGTH: 16
BSPD Signal:
Expand Down Expand Up @@ -4051,6 +4052,16 @@ Message ID:
comment: W
data type: i16
map equation: "x/100"
ECU Performance:
MSG ID: 0x123
MSG LENGTH: 4
Elapsed Cycles:
bit_start: 0
comment:
Represents the total number of clock cycles elapsed for 10 iterations of the main loop
data type: u32
units: Clock Cycles
data type: u8

Custom CAN ID:
DTI Control 1:
Expand Down
13 changes: 11 additions & 2 deletions Autogen/CAN/Inc/GRCAN_MSG_DATA.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ See diagram in StateMachine.h
5: TS Discharge ECU State
6-7: Reserved
See diagram in StateMachine.h (Byte 0) */
uint8_t state_messages;
uint8_t ecu_state;
/** [Byte 1 / Bits 8-15]
8: BCU Node Status (1: OK, 0: Timeout)
9: GR Inverter Status (1: OK, 0: Timeout)
Expand Down Expand Up @@ -405,7 +405,7 @@ typedef struct {
uint16_t steering_angle_signal;
/** 4-20 mA signal (Byte 14) */
uint16_t aux_signal;
} GRCAN_ECU_PEDALS_DATA_MSG;
} GRCAN_ECU_ANALOG_DATA_MSG;

/** GPS LAT */
typedef struct {
Expand Down Expand Up @@ -465,4 +465,13 @@ typedef struct {
uint16_t dgps_w;
} GRCAN_UVW_DGPS_MSG;

/** ECU Performance */
typedef struct {
/**
* Represents the total number of clock cycles elapsed for 10 iterations of the main loop
* data type: u32
* units: Clock Cycles (Byte 0) */
uint32_t elapsed_cycles;
} GRCAN_ECU_PERFORMANCE_MSG;

#endif
3 changes: 2 additions & 1 deletion Autogen/CAN/Inc/GRCAN_MSG_ID.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ typedef enum {
MSG_TCM_STATUS = 0x029,
MSG_TCM_RESOURCE_UTILIZATION = 0x02A,
MSG_DASH_WARNING_FLAGS = 0x02B,
MSG_ECU_PEDALS_DATA = 0x02E,
MSG_ECU_ANALOG_DATA = 0x02E,
MSG_GPS_LAT = 0x031,
MSG_GPS_LON = 0x032,
MSG_GPS_ALT = 0x033,
MSG_GPS_PX = 0x034,
MSG_GPS_QY = 0x035,
MSG_GPS_RZ = 0x036,
MSG_UVW_DGPS = 0x030,
MSG_ECU_PERFORMANCE = 0x123,
} GRCAN_MSG_ID;

#endif // CAN_MSG_IDS_H
2 changes: 1 addition & 1 deletion CCU/Application/Inc/CCUStateData.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct {
// bool BCU_S2_PRECHARGE_ERROR;

// State
// uint8_t BCU_S2_PRECHARGE_BITS;
uint8_t BCU_S2_PRECHARGE_BITS;
// bool BCU_S2_PRECHARGE_STATE;
// bool BCU_S2_IR_STATE;
bool BCU_S2_SOFTWARE_LATCH;
Expand Down
47 changes: 26 additions & 21 deletions CCU/Application/Src/CANDler.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include "CANDler.h"

#include "CCUStateData.h"
#include "GR_OLD_BUS_ID.h"
#include "GR_OLD_MSG_DAT.h"
#include "GR_OLD_MSG_ID.h"
#include "GR_OLD_NODE_ID.h"
#include "GRCAN_BUS_ID.h"
#include "GRCAN_MSG_DATA.h"
#include "GRCAN_MSG_ID.h"
#include "GRCAN_NODE_ID.h"
#include "Logomatic.h"
#include "Unused.h"
#include "bitManipulations.h"
Expand All @@ -19,16 +19,13 @@ CANHandle *primary_can = {0};
void Read_CAN(uint32_t ID, void *data, uint32_t size)
{

GR_OLD_MSG_ID messageId = (0x000FFF00 & ID) >> 8;
GR_OLD_NODE_ID nodeId = (0xFF00000 & ID) >> 20;

UNUSED(nodeId); // TODO Determine if calculating this value is actually needed
GRCAN_MSG_ID messageId = (0x000FFF00 & ID) >> 8;

switch (messageId) {
case MSG_BCU_STATUS_2:
// FIXME: if bad message do a thing

if (size != sizeof(GR_OLD_BCU_STATUS_2_MSG)) {
if (size != sizeof(GRCAN_BCU_STATUS_2_MSG)) {
LOGOMATIC("Bad CCU CAN Rx length! ID: %lu, Size %lu\n", ID, size);
break;
}
Expand All @@ -41,19 +38,22 @@ void Read_CAN(uint32_t ID, void *data, uint32_t size)

// What the rewrite would look like: STATUS 2

GR_OLD_BCU_STATUS_2_MSG *bcu_status_2 = (GR_OLD_BCU_STATUS_2_MSG *)data;
state_data.BCU_S2_MIN_CELL_Volt = bcu_status_2->voltage_min_cell;
GRCAN_BCU_STATUS_2_MSG *bcu_status_2 = (GRCAN_BCU_STATUS_2_MSG *)data;
state_data.BCU_S2_20Volt = bcu_status_2->_20v_voltage;
state_data.BCU_S2_12Volt = bcu_status_2->_12v_voltage;
state_data.BCU_S2_SDC_Volt = bcu_status_2->sdc_voltage;
state_data.BCU_S2_MIN_CELL_Volt = bcu_status_2->min_cell_voltage;
state_data.BCU_S2_MAX_CELL_TEMP = bcu_status_2->max_cell_temp;

state_data.BCU_S2_OVERTEMP_ERROR = GETBIT(bcu_status_2->error_bits, 0);
state_data.BCU_S2_OVERVOLT_ERROR = GETBIT(bcu_status_2->error_bits, 1);
state_data.BCU_S2_UNDERVOLT_ERROR = GETBIT(bcu_status_2->error_bits, 2);
state_data.BCU_S2_OVERCURR_ERROR = GETBIT(bcu_status_2->error_bits, 3);
state_data.BCU_S2_OVERCURR_ERROR = GETBIT(bcu_status_2->error_bits, 4);
state_data.BCU_S2_OVERTEMP_ERROR = GETBIT(bcu_status_2->status_flags, 0);
state_data.BCU_S2_OVERVOLT_ERROR = GETBIT(bcu_status_2->status_flags, 1);
state_data.BCU_S2_UNDERVOLT_ERROR = GETBIT(bcu_status_2->status_flags, 2);
state_data.BCU_S2_OVERCURR_ERROR = GETBIT(bcu_status_2->status_flags, 3);
state_data.BCU_S2_UNDERCURR_ERROR = GETBIT(bcu_status_2->status_flags, 4);

state_data.BCU_S2_UNDER20v_WARNING = GETBIT(bcu_status_2->error_bits, 5);
state_data.BCU_S2_UNDER12v_WARNING = GETBIT(bcu_status_2->error_bits, 6);
state_data.BCU_S2_UNDERVOLTSDC_WARNING = GETBIT(bcu_status_2->error_bits, 7);
state_data.BCU_S2_UNDER20v_WARNING = GETBIT(bcu_status_2->status_flags, 5);
state_data.BCU_S2_UNDER12v_WARNING = GETBIT(bcu_status_2->status_flags, 6);
state_data.BCU_S2_UNDERVOLTSDC_WARNING = GETBIT(bcu_status_2->status_flags, 7);

break;

Expand Down Expand Up @@ -159,17 +159,22 @@ void CAN_Configure(void)

void SendPrechargeStatus(CCU_StateData *state_data)
{

FDCANTxMessage msg;
msg.tx_header.Identifier = ((0xFF & LOCAL_GR_ID) << 20) | ((0xFFF & MSG_BCU_PRECHARGE) << 8) | (0xFF & GR_BCU);
msg.tx_header.Identifier = ((0xFF & LOCAL_GR_ID) << 20) | ((0xFFF & MSG_BCU_PRECHARGE) << 8) | (0xFF & BCU);
msg.tx_header.IdType = FDCAN_EXTENDED_ID;
msg.tx_header.TxFrameType = FDCAN_DATA_FRAME;
msg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
msg.tx_header.DataLength = 1;
msg.tx_header.DataLength = FDCAN_DLC_BYTES_1;
msg.tx_header.BitRateSwitch = FDCAN_BRS_OFF;
msg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
msg.tx_header.MessageMarker = 0;

msg.data[0] = (state_data->BCU_PRECHARGE_SET_TS_ACTIVE);

if (sizeof(msg) != sizeof(GRCAN_BCU_PRECHARGE_MSG)) {
LOGOMATIC("Bad CCU CAN Tx length!, Size %u\n", sizeof(msg));
}
LOGOMATIC("PRECHARGE SET: %d\n", state_data->BCU_PRECHARGE_SET_TS_ACTIVE);

can_send(primary_can, &msg);
Expand Down
5 changes: 1 addition & 4 deletions CCU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest")
CCUStateTicksTests
PRIVATE
GLOBALSHARE_LIB
#GR_OLD_CAN_MESSAGES
LOGOMATIC_LIB
#GR_ADC
#PERIPHERAL_CAN_LIB
BitManipulations_Lib
)
add_test(CCUStateTicksTests CCUStateTicksTests)
Expand Down Expand Up @@ -78,7 +75,7 @@ target_sources(
target_link_libraries(
${GR_PROJECT_NAME}_USER_CODE
INTERFACE
GR_OLD_CAN_MESSAGES
CANfigurator
BitManipulations_Lib
PERIPHERAL_CAN_LIB
VCP_LIB
Expand Down
4 changes: 2 additions & 2 deletions CCU/Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern "C" {

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "GR_OLD_NODE_ID.h"
#include "GRCAN_NODE_ID.h"
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
Expand Down Expand Up @@ -108,7 +108,7 @@ void Error_Handler(void);
#define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB

/* USER CODE BEGIN Private defines */
#define LOCAL_GR_ID GR_CCU
#define LOCAL_GR_ID CCU
/* USER CODE END Private defines */

#ifdef __cplusplus
Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(lib_path "Lib")
set(platform_path "${lib_path}/Platform")

# FIXME Temporary holdover for CAN messages until URCA is ready for merge
include("${lib_path}/FancyLayers-RENAME/GRCAN/TemporaryHoldover/temp.cmake")

# Vendor
include("${lib_path}/Vendor/CMSIS_5/cmsis_5.cmake")
include("${lib_path}/Vendor/STM32_HAL_LL/cube.cmake")
Expand Down
13 changes: 6 additions & 7 deletions DashPanel/Application/Inc/CANdler.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#ifndef CANDLER_H
#define CANDLER_H
#include "GR_OLD_MSG_DAT.h"
#include "GR_OLD_MSG_ID.h"
#include "GR_OLD_NODE_ID.h"
#include "GRCAN_MSG_DATA.h"
#include "GRCAN_MSG_ID.h"
#include "GRCAN_NODE_ID.h"
#include "can.h"

typedef struct {
uint8_t ECUState;
uint8_t TSActiveButton;
uint8_t RTDButton;
uint8_t button_flags;
uint8_t led_bits;
} DashStatus;

Expand All @@ -17,8 +16,8 @@ extern CANHandle *can_handler;
extern bool canReadyToSend;

void CANInitialize();
void CAN_sendPing(GR_OLD_NODE_ID to, uint32_t data);
void CAN_sendPing(GRCAN_NODE_ID to, uint32_t data);
void CAN_callback(uint32_t ID, void *data, uint32_t size);
void CAN_sendECU(CANHandle *c, GR_OLD_DASH_STATUS_MSG *msg, GR_OLD_NODE_ID to);
void CAN_sendECU(CANHandle *c, GRCAN_DASH_STATUS_MSG *msg, GRCAN_NODE_ID to);

#endif
45 changes: 26 additions & 19 deletions DashPanel/Application/Src/CANdler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

#include <string.h>

#include "GR_OLD_MSG_DAT.h"
#include "GR_OLD_MSG_ID.h"
#include "GR_OLD_NODE_ID.h"
#include "GRCAN_MSG_DATA.h"
#include "GRCAN_MSG_ID.h"
#include "GRCAN_NODE_ID.h"
#include "Logomatic.h"
#include "Unused.h"
#include "bitManipulations.h"
#include "can.h"
#include "dashutils.h"
#include "main.h"
#include "stm32g4xx_hal_fdcan.h"

#define ECU_ID GR_ECU
#define ECU_ID ECU
#define PING_ID MSG_PING

CANHandle *can_handler;
Expand Down Expand Up @@ -64,33 +65,33 @@ void CANInitialize()
can_start(can_handler);
}

void CAN_sendPing(GR_OLD_NODE_ID to, uint32_t data)
void CAN_sendPing(GRCAN_NODE_ID to, uint32_t data)
{
FDCANTxMessage pingMsg;
pingMsg.tx_header.Identifier = (GR_DASH_PANEL << 20) | (MSG_PING << 8) | to;
pingMsg.tx_header.Identifier = (Dash_Panel << 20) | (MSG_PING << 8) | to;
pingMsg.tx_header.IdType = FDCAN_EXTENDED_ID;
pingMsg.tx_header.TxFrameType = FDCAN_DATA_FRAME;
pingMsg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
pingMsg.tx_header.DataLength = sizeof(GR_OLD_PING_MSG);
pingMsg.tx_header.DataLength = sizeof(GRCAN_PING_MSG);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pingMsg.tx_header.BitRateSwitch = FDCAN_BRS_OFF;
pingMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
pingMsg.tx_header.MessageMarker = 0;

GR_OLD_PING_MSG msg = {.timestamp = data};
GRCAN_PING_MSG msg = {.timestamp = data};
memcpy(pingMsg.data, &msg, sizeof(msg));

can_send(can_handler, &pingMsg);
}

void CAN_sendECU(CANHandle *c, GR_OLD_DASH_STATUS_MSG *msg, GR_OLD_NODE_ID to)
void CAN_sendECU(CANHandle *c, GRCAN_DASH_STATUS_MSG *msg, GRCAN_NODE_ID to)
{

FDCANTxMessage sendECUMsg;
sendECUMsg.tx_header.Identifier = (GR_DASH_PANEL << 20) | (MSG_DASH_STATUS << 8) | to;
sendECUMsg.tx_header.Identifier = (Dash_Panel << 20) | (MSG_DASH_STATUS << 8) | to;
sendECUMsg.tx_header.IdType = FDCAN_EXTENDED_ID;
sendECUMsg.tx_header.TxFrameType = FDCAN_DATA_FRAME;
sendECUMsg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
sendECUMsg.tx_header.DataLength = sizeof(GR_OLD_DASH_STATUS_MSG);
sendECUMsg.tx_header.DataLength = sizeof(GRCAN_DASH_STATUS_MSG);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendECUMsg.tx_header.BitRateSwitch = FDCAN_BRS_OFF;
sendECUMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
sendECUMsg.tx_header.MessageMarker = 0;
Expand All @@ -103,18 +104,24 @@ void CAN_sendECU(CANHandle *c, GR_OLD_DASH_STATUS_MSG *msg, GR_OLD_NODE_ID to)
void CAN_callback(uint32_t ID, void *data, uint32_t size)
{

GR_OLD_MSG_ID msg_id = (0x000FFF00 & ID) >> 8;
GR_OLD_NODE_ID node_id = (0x0FF00000 & ID) >> 20;
GRCAN_MSG_ID msg_id = GETBITS(ID, 12, 12);
GRCAN_NODE_ID node_id = GETBITS(ID, 4, 8);
Comment on lines +107 to +108
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GETBITS and related is only intended for CAN message bit flags (eg button and LED bit flags) and can be changed to follow MSB/LSB ordering. These bits are fixed and you should use manual bit manipulations to extract the values.

Suggested change
GRCAN_MSG_ID msg_id = GETBITS(ID, 12, 12);
GRCAN_NODE_ID node_id = GETBITS(ID, 4, 8);
GRCAN_MSG_ID msg_id = (0x000FFF00 & ID) >> 8;
GRCAN_NODE_ID node_id = (0x0FF00000 & ID) >> 20;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Process data
if (msg_id == MSG_ECU_STATUS_1 && size == sizeof(GR_OLD_ECU_STATUS_1_MSG)) {
GR_OLD_ECU_STATUS_1_MSG *ecu_data = (GR_OLD_ECU_STATUS_1_MSG *)data;
dashStatus.ECUState = ecu_data->ecu_status; // Get ECU Status
} else if (msg_id == MSG_DASH_CONFIG && size == sizeof(GR_OLD_DASH_CONFIG_MSG)) {
GR_OLD_DASH_CONFIG_MSG *dash_data = (GR_OLD_DASH_CONFIG_MSG *)data;
// ECU Status
if (msg_id == MSG_ECU_STATUS_1 && size == sizeof(GRCAN_ECU_STATUS_1_MSG)) {
GRCAN_ECU_STATUS_1_MSG *ecu_data = (GRCAN_ECU_STATUS_1_MSG *)data;
dashStatus.ECUState = ecu_data->ecu_state; // Get ECU Status

// Dash Config
} else if (msg_id == MSG_DASH_CONFIG && size == sizeof(GRCAN_DASH_CONFIG_MSG)) {
GRCAN_DASH_CONFIG_MSG *dash_data = (GRCAN_DASH_CONFIG_MSG *)data;
dashStatus.led_bits = dash_data->led_bits; // Get LED bits
} else if (msg_id == PING_ID && size == sizeof(GR_OLD_PING_MSG)) {

// Ping
} else if (msg_id == MSG_PING && size == sizeof(GRCAN_PING_MSG)) {
CAN_sendPing(node_id, *(uint32_t *)data);

} else {
// Check that you are sending the correct sizes if you get this message
LOGOMATIC("Unrecognized CAN message.\n");
Expand Down
2 changes: 1 addition & 1 deletion DashPanel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ target_sources(
target_link_libraries(
${GR_PROJECT_NAME}_USER_CODE
INTERFACE
GR_OLD_CAN_MESSAGES
CANfigurator
PERIPHERAL_CAN_LIB
CircularBuffer_Lib
GR_NEOPIXEL
Expand Down
2 changes: 2 additions & 0 deletions DashPanel/Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ extern "C" {

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
void timer_inc(void);

/* USER CODE BEGIN EFP */

Expand Down Expand Up @@ -95,6 +96,7 @@ void Error_Handler(void);
#endif

/* USER CODE BEGIN Private defines */
extern uint32_t timer;

/* USER CODE END Private defines */

Expand Down
Loading
Loading