-
-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate To New CAN Specification #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 88 commits
516b74a
2ce4c86
b52e647
cf2d7c2
6f20c55
2f8bce4
cb757ad
ffb8ab9
64c73b3
692f245
28a9bbd
db955ab
5d7fd96
f8cf3fc
b2fc7f3
24ff97a
c021bfb
e03e9b9
31fd169
4b15f5e
4697fbc
5c44a21
e92a054
bd477b9
fec5910
20bd25c
a48cc43
38af778
90ef335
7f83575
0813840
ff0f549
c21bb6c
35e207e
5cd6c04
185dbc7
57b59db
2eb7aeb
09afdab
5eb46cb
2e2db73
e4ffde2
4ee18e6
75b0db4
db01374
aa3e61f
47c37b0
11427ee
e01a39e
faf1f26
9e5a741
9483a7c
675576a
dc685f1
7e7b908
6d38258
6fc6927
4e51ae2
0650f82
dfb58a2
1f003c4
83babff
7521211
6ddcb59
bc428db
d5b5262
f53a6ba
5be9a28
76398af
3ffaa61
e14c266
70e8f33
3498436
f78f63a
7c33f4c
9845b83
ca6a9e5
8053076
0284a7e
f033113
e59541e
13e72f4
e896058
38a6625
e15a4be
05182bf
e2361db
e5c2274
bb7deff
d230c4d
01b91e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,4 @@ inc/ | |
| !inc/output.dbc | ||
|
|
||
| # CANfigurator | ||
| Inc/*.h | ||
| Doc/*.dbc | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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; | ||||||||||
|
|
@@ -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); | ||||||||||
| 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); | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not correct, see https://discord.com/channels/756738476887638107/1457989912069537906/1489483629427163216
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||||||||||
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"); | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct, see https://discord.com/channels/756738476887638107/1457989912069537906/1489483629427163216
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DavidUzunov @horizon-ab @anthony9975