Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 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
d0cc442
TCM Status is sentr to DEubgger on data bus
coderask 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
dd48bb8
tcm status?
coderask Apr 3, 2026
b5ae459
please fix tcm status
coderask 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
2575127
comment notes for pedal data to TCM
khoulihan27 Apr 5, 2026
01a6921
BCU Status now sent to CCU on CAN 3
coderask Apr 5, 2026
aafa94d
Update DashPanel/Application/Src/CANdler.c
horizon-ab Apr 5, 2026
9adc038
changed sizeof to macros
horizon-ab Apr 6, 2026
2c86230
checks for the physical existence of a node
coderask Apr 6, 2026
0e90588
fixed macro values
horizon-ab Apr 7, 2026
5508897
Changed GETBIT in CANdler to manual bit manipulation
anthony9975 Apr 7, 2026
544fd69
Merge branch 'GrandCanMigration' of github.com:Gaucho-Racing/Firmware…
anthony9975 Apr 7, 2026
86c7981
correct dash panel message bit manipulation logic
SlowThomas Apr 7, 2026
68a55df
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 7, 2026
6357215
Merge branch 'GrandCanMigration' into Viewer_Fixes
coderask Apr 7, 2026
5ad288c
update ping list
SlowThomas Apr 7, 2026
87f8d31
Merge branch 'GrandCanMigration' into Viewer_Fixes
coderask Apr 7, 2026
98a1985
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 7, 2026
494f13c
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 7, 2026
a863d85
Automatic Web Format: Standardized formatting automatically
github-actions[bot] Apr 7, 2026
8b09acb
increase CAN buffer size for ECU
SlowThomas Apr 7, 2026
7ee4080
bit block mismatches fixed from most recent branch (#394)
kodingwizard Apr 7, 2026
01e2a3a
implement ping-back with debugger as client
SlowThomas Apr 7, 2026
c930d85
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 7, 2026
791203c
Merge branch 'main' into GrandCanMigration
dchansen06 Apr 7, 2026
16c412c
Merge branch 'GrandCanMigration' into Viewer_Fixes
dchansen06 Apr 7, 2026
ea24cdb
remove CCU pinging
SlowThomas Apr 7, 2026
aa7748b
correct CAN buffer size config
SlowThomas Apr 7, 2026
513a6b6
Updated STRUCTparser.pl logic (#399)
krai19 Apr 7, 2026
80ee91f
Merge branch 'GrandCanMigration' into Viewer_Fixes
coderask Apr 7, 2026
e6d46e9
Automatic Perl Tidy: Standardized formatting automatically
github-actions[bot] Apr 7, 2026
9287efe
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 7, 2026
00d2a0a
Merge branch 'main' into Viewer_Fixes
coderask Apr 7, 2026
b4952ad
Merge branch 'main' into Viewer_Fixes
dchansen06 Apr 7, 2026
bb17977
Merge branch 'main' into Viewer_Fixes
dchansen06 Apr 10, 2026
5d9b079
abssolutely horrific merge conflict resolutoin
coderask Apr 10, 2026
d928c61
Automatic Perl Tidy: Standardized formatting automatically
github-actions[bot] Apr 10, 2026
4eae052
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 10, 2026
c671387
fiasdfx GRCAN_
coderask Apr 10, 2026
05c5040
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 10, 2026
ec5934b
rewrote a small part of Candler.c becuase DEBUG2.0 no longer generated
coderask Apr 10, 2026
149c6cf
linter
coderask Apr 10, 2026
f0ace7e
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 10, 2026
e0c7ead
Add URL Parsing Support For Web CANdo Viewer (#405)
dchansen06 Apr 10, 2026
36491e0
Merge branch 'main' into Viewer_Fixes
dchansen06 Apr 10, 2026
7e8a5c9
standardized comments that have reserved padding for Dash Config and TCM
krai19 Apr 12, 2026
4dc8871
Merge branch 'main' into Viewer_Fixes
dchansen06 Apr 13, 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
438 changes: 34 additions & 404 deletions Autogen/CAN/Doc/GRCAN.CANdo

Large diffs are not rendered by default.

51 changes: 30 additions & 21 deletions Autogen/CAN/Doc/GRCAN.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ BO_ 2147682562 BCU_BCU_Status_3_to_ECU: 8 BCU
SG_ HV_Input_Current : 32|16@1+ (0.001,0) [0|65.535] "Amps" ECU
SG_ HV_Output_Current : 48|16@1+ (0.001,0) [0|65.535] "Amps" ECU

BO_ 2147684866 BCU_DC_DC_Status_to_ECU: 7 BCU
SG_ Input_Voltage : 0|16@1+ (0.001,0) [0|65.535] "Volts" ECU
SG_ Output_Voltage : 16|16@1+ (0.001,0) [0|65.535] "Volts" ECU
SG_ Input_Current : 32|8@1+ (0.1,0) [0|25.5] "Amps" ECU
SG_ Output_Current : 40|8@1+ (0.1,0) [0|25.5] "Amps" ECU
SG_ DC_DC_Temp : 48|8@1+ (1,0) [0|255] "Celsius" ECU

BO_ 2147680513 BCU_Debug_FD_to_Debugger: 64 BCU
SG_ Debug : 0|64@1- (1,0) [0|0] "" Debugger

Expand Down Expand Up @@ -388,6 +381,28 @@ BO_ 2550588916 BCU_Charger_Control_to_Charger: 5 BCU
SG_ Set_Current : 16|8@1+ (1,0) [0|0] "" Charger
SG_ Charge_Enable : 17|8@1+ (1,0) [0|0] "" Charger

BO_ 2147682050 BCU_BCU_Status_1_to_CCU: 8 BCU
SG_ Accumulator_Voltage : 0|16@1+ (0.01,0) [0|655.35] "Volts" CCU
SG_ TS_Voltage : 16|16@1+ (0.01,0) [0|655.35] "Volts" CCU
SG_ Accumulator_Current : 32|16@1- (0.01,0) [-327.68|327.67] "Amps" CCU
SG_ Accumulator_SOC : 48|8@1+ (0.392157,0) [0|100] "%" CCU
SG_ GLV_SOC : 56|8@1+ (0.392157,0) [0|100] "%" CCU

BO_ 2147682306 BCU_BCU_Status_2_to_CCU: 7 BCU
SG_ 20v_Voltage : 0|8@1+ (1,0) [0|0] "" CCU
SG_ 12v_Voltage : 8|8@1+ (1,0) [0|0] "" CCU
SG_ SDC_Voltage : 16|8@1+ (1,0) [0|0] "" CCU
SG_ Min_Cell_Voltage : 24|8@1+ (1,0) [0|0] "" CCU
SG_ Max_Cell_Temp : 32|8@1+ (1,0) [0|0] "" CCU
SG_ status_flags : 40|1@1+ (1,0) [0|0] "" CCU
SG_ precharge_latch_flags : 48|1@1+ (1,0) [0|0] "" CCU

BO_ 2147682562 BCU_BCU_Status_3_to_CCU: 8 BCU
SG_ HV_Input_Voltage : 0|16@1+ (0.01,0) [0|655.35] "Volts" CCU
SG_ HV_Output_Voltage : 16|16@1+ (0.01,0) [0|655.35] "Volts" CCU
SG_ HV_Input_Current : 32|16@1+ (0.001,0) [0|65.535] "Amps" CCU
SG_ HV_Output_Current : 48|16@1+ (0.001,0) [0|65.535] "Amps" CCU

BO_ 2566869221 Charger_Charger_Data_to_BCU: 8 Charger
SG_ Output_Voltage : 0|8@1+ (1,0) [0|0] "" BCU
SG_ Output_Current : 16|8@1+ (1,0) [0|0] "" BCU
Expand Down Expand Up @@ -618,15 +633,13 @@ BO_ 2147615247 ECU_Ping_to_Fan_Controller_3: 4 ECU
SG_ Timestamp : 0|32@1+ (1,0) [0|4,294,967,296] "ms" Fan_Controller_3

BO_ 2147621637 ECU_Dash_Config_to_Dash_Panel: 1 ECU
SG_ BMS_LED : 0|1@1+ (1,0) [0|0] "Bool" Dash_Panel
SG_ IMD_LED : 1|1@1+ (1,0) [0|0] "Bool" Dash_Panel
SG_ BSPD_LED : 2|1@1+ (1,0) [0|0] "Bool" Dash_Panel
SG_ led_bits : 0|8@1+ (1,0) [0|0] "" Dash_Panel

BO_ 2147615237 ECU_Ping_to_Dash_Panel: 4 ECU
SG_ Timestamp : 0|32@1+ (1,0) [0|4,294,967,296] "ms" Dash_Panel

BO_ 2147615743 ECU_ECU_Status_1_to_ALL: 8 ECU
SG_ state_messages : 0|1@1+ (1,0) [0|0] "Bool" ALL
SG_ ecu_state : 0|1@1+ (1,0) [0|0] "Bool" ALL
SG_ status_flags : 8|1@1+ (1,0) [0|0] "" ALL
SG_ Power_Level : 16|4@1+ (1,0) [0|0] "" ALL
SG_ Torque_Map : 20|4@1+ (1,0) [0|0] "" ALL
Expand All @@ -653,7 +666,7 @@ BO_ 2147614977 ECU_Debug_FD_to_Debugger: 64 ECU
BO_ 2147615233 ECU_Ping_to_Debugger: 4 ECU
SG_ Timestamp : 0|32@1+ (1,0) [0|4,294,967,296] "ms" Debugger

BO_ 2147626500 ECU_ECU_Pedals_Data_to_TCM: 16 ECU
BO_ 2147626500 ECU_ECU_Analog_Data_to_TCM: 16 ECU
SG_ BSPD_Signal : 0|16@1+ (0.0015259,0) [0|100] "%" TCM
SG_ BSE_Signal : 16|16@1+ (0.0015259,0) [0|100] "%" TCM
SG_ APPS_1_Signal : 32|16@1+ (0.0015259,0) [0|100] "%" TCM
Expand All @@ -663,6 +676,9 @@ BO_ 2147626500 ECU_ECU_Pedals_Data_to_TCM: 16 ECU
SG_ Steering_Angle_Signal : 96|16@1+ (0.0015259,0) [0|100] "%" TCM
SG_ AUX_Signal : 112|16@1+ (0.0015259,0) [0|100] "%" TCM

BO_ 2147689220 ECU_ECU_Performance_to_TCM: 4 ECU
SG_ Elapsed_Cycles : 0|32@1+ (1,0) [0|0] "Clock Cycles" TCM

BO_ 269 Energy_Meter_EM_Measurement_to_BCU: 8 Energy_Meter
SG_ Current : 0|8@1+ (1,0) [0|0] "" BCU
SG_ Voltage : 32|8@1+ (1,0) [0|0] "" BCU
Expand Down Expand Up @@ -752,16 +768,9 @@ BO_ 2148013058 GR_Inverter_Inverter_Status_2_to_ECU: 6 GR_Inverter
SG_ V_MOSFET_temperature : 16|8@1+ (1,-40) [-40|215] "Celsius" ECU
SG_ W_MOSFET_temperature : 32|8@1+ (1,-40) [-40|215] "Celsius" ECU

BO_ 2148013314 GR_Inverter_Inverter_Status_3_to_ECU: 2 GR_Inverter
BO_ 2148013314 GR_Inverter_Inverter_Status_3_to_ECU: 3 GR_Inverter
SG_ Motor_temperature : 0|8@1+ (1,-40) [-40|215] "Celsius" ECU
SG_ Over_voltage_faults : 16|1@1+ (1,0) [0|0] "Bool" ECU
SG_ Under_voltage_fault : 17|1@1+ (1,0) [0|0] "Bool" ECU
SG_ Inv_overtemp_fault : 18|1@1+ (1,0) [0|0] "Bool" ECU
SG_ Motor_overtemp_fault : 19|1@1+ (1,0) [0|0] "Bool" ECU
SG_ Transistor_fault : 20|1@1+ (1,0) [0|0] "Bool" ECU
SG_ Encoder_fault : 21|1@1+ (1,0) [0|0] "Bool" ECU
SG_ CAN_fault : 22|1@1+ (1,0) [0|0] "Bool" ECU
SG_ Future_use : 23|1@1+ (1,0) [0|0] "Bool" ECU
SG_ fault_bits : 16|8@1+ (1,0) [0|0] "" ECU

BO_ 35 IMD_IMD_response_to_BCU: 0 IMD

Expand Down
28 changes: 4 additions & 24 deletions Autogen/CAN/Inc/GRCAN_MSG_DATA.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@

#include <stdint.h>

/** Debug 2.0 */
typedef struct {
/** Essentially a print statement up to 8 bytes long that whichever targeted can parse (Byte 0) */
uint8_t debug[8];
} GRCAN_DEBUG_2_0_MSG;

/** Debug FD */
typedef struct {
/** Essentially a print statement up to 64 bytes long that whichever targeted can parse (Byte 0) */
uint8_t debug[64];
} GRCAN_DEBUG_FD_MSG;

/** Ping */
typedef struct {
/** Time in millis (Byte 0) */
Expand Down Expand Up @@ -310,18 +298,13 @@ typedef struct {

/** Dash Config */
typedef struct {
/** BMS = bit 0 of this byte, IMD = bit 1, BSPD = bit 2, bits 37 reserved (Byte 1) */
/** BMS LED command = bit 0, IMD LED command = bit 1, BSPD LED command = bit 2, bits 3-7 reserved (Byte 0) */
uint8_t led_bits;
} GRCAN_DASH_CONFIG_MSG;

/** TCM Status */
typedef struct {
/**
* Connection Status - 1: OK, 0: Timeout (bit 0)
* MQTT Status - 1: OK, 0: Timeout (bit 1)
* Epic Shelter Status - 1: In Progress, 0: Idle (bit 2)
* Camera Status - 1: Recording, 0: Idle (bit 3)
*/
/** "Connection Status = bit 0, MQTT Status = bit 1, Epic Shelter Status = bit 2, Camera Status = bit 3, bits 4-7 reserved" (Byte 0) */
uint8_t status_bits;
/** Mapache ping (upload) (Byte 1) */
uint16_t mapache_ping;
Expand Down Expand Up @@ -387,7 +370,7 @@ typedef struct {
uint16_t power_draw;
} GRCAN_TCM_RESOURCE_UTILIZATION_MSG;

/** ECU Pedals Data */
/** ECU Analog Data */
typedef struct {
/** 4-20 mA signal (Byte 0) */
uint16_t bspd_signal;
Expand Down Expand Up @@ -467,10 +450,7 @@ typedef struct {

/** 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) */
/** Represents the total number of clock cycles elapsed for 10 iterations of the main loop (Byte 0) */
uint32_t elapsed_cycles;
} GRCAN_ECU_PERFORMANCE_MSG;

Expand Down
1 change: 0 additions & 1 deletion Autogen/CAN/Inc/GRCAN_MSG_ID.h
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please order off of hex value and not alphabetic

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ typedef enum {
GRCAN_DASH_CONFIG = 0x01B,
GRCAN_TCM_STATUS = 0x029,
GRCAN_TCM_RESOURCE_UTILIZATION = 0x02A,
GRCAN_DASH_WARNING_FLAGS = 0x02B,
GRCAN_ECU_ANALOG_DATA = 0x02E,
GRCAN_GPS_LAT = 0x031,
GRCAN_GPS_LON = 0x032,
Expand Down
5 changes: 4 additions & 1 deletion Autogen/CAN/Inc/GRCAN_NODE_ID.h
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please order off of hex value and not alphabetic

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
typedef enum {
GRCAN_ALL = 0xFF,
GRCAN_BCU = 0x03,
GRCAN_ECU = 0x02,
GRCAN_CCU = 0x02,
GRCAN_Charger = 0x00,
GRCAN_Charging_SDC = 0x0C,
GRCAN_DGPS = 0x30,
GRCAN_DTI_Inverter = 0x00,
GRCAN_Dash_Panel = 0x05,
GRCAN_Debugger = 0x01,
GRCAN_ECU = 0x02,
GRCAN_Energy_Meter = 0x00,
GRCAN_Fan_Controller_1 = 0x0D,
GRCAN_Fan_Controller_2 = 0x0E,
GRCAN_Fan_Controller_3 = 0x0F,
GRCAN_GR_Inverter = 0x08,
GRCAN_IMD = 0x00,
GRCAN_TCM = 0x04,
} GRCAN_NODE_ID;

Expand Down
12 changes: 3 additions & 9 deletions Autogen/CAN/Src/GRparser.pl
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,27 @@ sub generate_gr_header_content {
push @header_lines, "#define GR_IDS_H\n\n";
push @header_lines, "typedef enum {\n";

# --- TRACKERS FOR ISSUE #373 ---
# Track emitted names to avoid exact duplicate enum symbols.
my %seen_names;
my %seen_values;

my @sorted = sort { $a->{name} cmp $b->{name} } @{$ids_ref};

for my $item (@sorted) {
my $const_name = $item->{name};
my $const_name = 'GRCAN_' . $item->{name};
$const_name =~ s/[[:^alnum:]]/_/gsmx;
my $val = $item->{id};

# --- FIX FOR #373: Skip if name or ID value is already in the list ---
# Skip only duplicate enum names.
if ( $seen_names{$const_name} ) {
warn "Skipping duplicate Node Name: $const_name\n";
next;
}
if ( defined $val && $seen_values{$val} ) {
warn "Issue #373: Skipping duplicate Node ID value: $val ($const_name)\n";
next;
}

if ( defined $val && $val ne q{} ) {
push @header_lines, sprintf " %s = %s,\n", $const_name, $val;

# Mark as processed
$seen_names{$const_name} = 1;
$seen_values{$val} = 1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Autogen/CAN/Src/MSGparser.pl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ sub find_id_in_lines {
${$idx_ref} = $j;

my $id = $1;
my $enum_name = 'MSG_' . uc $msg_name;
my $enum_name = 'GRCAN_' . uc $msg_name;
$enum_name =~ s/\W+/_/gsmx;
$enum_name =~ s/_+/_/gsmx;
$enum_name =~ s/^_|_$//gsmx;
Expand Down
92 changes: 71 additions & 21 deletions Autogen/CAN/Src/STRUCTparser.pl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ sub generate_header {
if ($current_msg) {
push @output, process_message( $current_msg, \@fields, $d_map, $prefix );
}
$current_msg = $msg_name;

# Debug payload structs are intentionally excluded.
$current_msg = ( $msg_name =~ /^Debug(?:\s+(?:2[.]0|FD))?$/ismx ) ? $EMPTY_STR : $msg_name;
@fields = ();
}

Expand Down Expand Up @@ -233,6 +235,7 @@ sub clean_field_name {

sub process_message {
my ( $name, $f_ref, $d_map, $prefix ) = @_;

my @buf;
my $tag = uc $name =~ s/[^[:alpha:][:digit:]]/_/grsmx =~ s/_+/_/grsmx =~ s/^_|_$//grsmx;

Expand All @@ -248,45 +251,72 @@ sub process_message {

push @buf, "/** $name */\ntypedef struct {\n";
my @sorted = sort { $a <=> $b } keys %byte_map;
my %used_field_names;

for my $i ( 0 .. $#sorted ) {
push @buf, process_byte_entry( $name, \@sorted, \%byte_map, \$i, $d_map );
my %byte_ctx = (
msg_name => $name,
sorted_ref => \@sorted,
map_ref => \%byte_map,
idx_ref => \$i,
d_map => $d_map,
seen_ref => \%used_field_names,
);
push @buf, process_byte_entry( \%byte_ctx );
}
push @buf, "} ${prefix}_${tag}_MSG;\n\n";
return join $EMPTY_STR, @buf;
}

sub process_byte_entry {
my ( $msg_name, $sorted_ref, $map_ref, $idx_ref, $d_map ) = @_;
my ($ctx_ref) = @_;
my $msg_name = $ctx_ref->{msg_name};
my $sorted_ref = $ctx_ref->{sorted_ref};
my $map_ref = $ctx_ref->{map_ref};
my $idx_ref = $ctx_ref->{idx_ref};
my $d_map = $ctx_ref->{d_map};
my $seen_ref = $ctx_ref->{seen_ref};
my @out;
my $b_idx = ${$sorted_ref}[ ${$idx_ref} ];
my $fields = ${$map_ref}{$b_idx};

if ( scalar @{$fields} > 2 && ${$fields}[0]->{name} =~ /reserved|ping|byte/ismx ) {
push @out, handle_multi_field_range( $sorted_ref, $map_ref, $idx_ref );
push @out, handle_multi_field_range( $sorted_ref, $map_ref, $idx_ref, $seen_ref );
}
else {
my $f_var =
( scalar @{$fields} == 1 )
? clean_field_name( ${$fields}[0]->{name} )
: join q{_}, map { clean_field_name( $_->{name} ) } @{$fields};
if ( $f_var =~ /^[[:digit:]]/smx ) {
$f_var = q{_} . $f_var;
# For dense semantic bytes, emit each explicit CANdo field separately.
if ( scalar @{$fields} > 2 ) {
for my $f ( @{$fields} ) {
my $f_var = assign_unique_field_name( clean_field_name( $f->{name} ), $seen_ref );
my $type =
( $f->{type} =~ /32/smx ) ? 'uint32_t'
: ( $f->{type} =~ /16/smx ) ? 'uint16_t'
: 'uint8_t';
my $desc = ${$d_map}{ $msg_name . q{::} . clean_field_name( $f->{name} ) } // "Byte $b_idx";
push @out, sprintf "\t/** %s (Byte %d) */\n\t%-10s %-30s\n", $desc, $b_idx, $type, $f_var . q{;};
}
}
else {
my $f_var =
( scalar @{$fields} == 1 )
? clean_field_name( ${$fields}[0]->{name} )
: join q{_}, map { clean_field_name( $_->{name} ) } @{$fields};
$f_var = assign_unique_field_name( $f_var, $seen_ref );

my $type =
( ${$fields}[0]->{type} =~ /32/smx ) ? 'uint32_t'
: ( ${$fields}[0]->{type} =~ /16/smx ) ? 'uint16_t'
: 'uint8_t';
my $desc = join $SPACE_STR, map { ${$d_map}{ $msg_name . q{::} . clean_field_name( $_->{name} ) } // () } @{$fields};

push @out, sprintf "\t/** %s (Byte %d) */\n\t%-10s %-30s\n", ( $desc || "Byte $b_idx" ), $b_idx, $type, $f_var . q{;};
}

my $type =
( ${$fields}[0]->{type} =~ /32/smx ) ? 'uint32_t'
: ( ${$fields}[0]->{type} =~ /16/smx ) ? 'uint16_t'
: 'uint8_t';
my $desc = join $SPACE_STR, map { ${$d_map}{ $msg_name . q{::} . clean_field_name( $_->{name} ) } // () } @{$fields};

push @out, sprintf "\t/** %s (Byte %d) */\n\t%-10s %-30s\n", ( $desc || "Byte $b_idx" ), $b_idx, $type, $f_var . q{;};
}
return join $EMPTY_STR, @out;
}

sub handle_multi_field_range {
my ( $bytes_ref, $map_ref, $idx_ref ) = @_;
my ( $bytes_ref, $map_ref, $idx_ref, $seen_ref ) = @_;
my $start_byte = ${$bytes_ref}[ ${$idx_ref} ];
my $has_error = grep { $_->{name} =~ /error|fault|violation/ismx } @{ ${$map_ref}{$start_byte} };

Expand All @@ -302,7 +332,27 @@ sub handle_multi_field_range {
}

my $len = ( ${$bytes_ref}[ ${$idx_ref} ] - $start_byte ) + 1;
my $v_name = $has_error ? 'error_fault_violation_bits' : 'ping_block';
my $suffix = ( $len > 1 ) ? "[$len]" : $EMPTY_STR;
my $v_name = $has_error ? 'error_fault_violation_bits' : 'ping_block';
$v_name = assign_unique_field_name( $v_name, $seen_ref );
my $suffix = ( $len > 1 ) ? "[$len]" : $EMPTY_STR;
return sprintf "\tuint8_t %s%s;\n", $v_name, $suffix;
}

sub assign_unique_field_name {
my ( $base_name, $seen_ref ) = @_;
my $name = $base_name // 'unknown_field';
if ( $name =~ /^[[:digit:]]/smx ) {
$name = q{_} . $name;
}
if ( !$seen_ref->{$name} ) {
$seen_ref->{$name} = 1;
return $name;
}
my $idx = 1;
while ( $seen_ref->{ $name . q{_} . $idx } ) {
$idx++;
}
my $unique = $name . q{_} . $idx;
$seen_ref->{$unique} = 1;
return $unique;
}
4 changes: 2 additions & 2 deletions ECU/Application/Src/CANdler.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ void ECU_CAN_MessageHandler(ECU_StateData *state_data, GRCAN_BUS_ID bus_id, GRCA
{
switch (msg_id) {
case GRCAN_DEBUG_2_0:
if (data_length > sizeof(GRCAN_DEBUG_2_0_MSG)) {
if (data_length > 8) {
ReportBadMessageLength(bus_id, msg_id, sender_id);
break;
}
LOGOMATIC("Received from %02X on bus %d: %.*s\n", sender_id, bus_id, (int)data_length, data);
break;

case GRCAN_DEBUG_FD:
if (data_length > sizeof(GRCAN_DEBUG_FD_MSG)) {
if (data_length > 64) {
ReportBadMessageLength(bus_id, msg_id, sender_id);
break;
}
Expand Down
Loading
Loading