Skip to content

Migrate To New CAN Specification#390

Draft
dchansen06 wants to merge 91 commits intomainfrom
GrandCanMigration
Draft

Migrate To New CAN Specification#390
dchansen06 wants to merge 91 commits intomainfrom
GrandCanMigration

Conversation

@dchansen06
Copy link
Copy Markdown
Contributor

@dchansen06 dchansen06 commented Apr 2, 2026

Initial CAN Specification Migration

Problem and Scope

Migrate away from old CAN specification to new (auto-generated) one

Transitioning from GR_OLD_CAN_MESSAGES to CANfigurator interface link library

Description

Each group will work on migrating their own board on this PR to avoid merge conflicts (separate from other boards), this can be done by having a VS Code Live Share on this branch and only fixing code in their scope and syncing often

Gotchas and Limitations

Subject to change, this is first pass

Testing

  • HOOTL testing
  • HITL testing
  • Human tested

Testing Details

Compilation and groups checking their projects

Larger Impact

Migrating fully to URCA and new CAN implementation

Additional Context and Ticket

Resolves #261

coderask and others added 30 commits March 21, 2026 20:51
Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
@SlowThomas SlowThomas mentioned this pull request Apr 3, 2026
3 tasks
@horizon-ab
Copy link
Copy Markdown
Contributor

Dash Panel good to go

dwilson765 and others added 4 commits April 2, 2026 23:21
Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
# ECU CAN Migration

## Problem and Scope
Part of the Grand CAN Migration

## Description
CAN Migration

## Gotchas and Limitations


## Testing

- [x] HOOTL testing
- [ ] HITL testing
- [ ] Human tested

### Testing Details
ctest

## Larger Impact
Must-do.

## Additional Context and Ticket
#390

---------

Co-authored-by: kzwicker <kzwicker@users.noreply.github.com>
Co-authored-by: khoulihan27 <khoulihan27@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
@SlowThomas SlowThomas marked this pull request as ready for review April 3, 2026 20:59
Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
Comment on lines 422 to 425
if (getRTT(CCU) != PINGTIMEOUT_VALUE) {
// halt if CCU is connected
return 1;
}
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.

Under no scenario can the ECU just throw up it's hands and declare failure, this should be a very clearly logged event (debug message and logomatic) but not a half. (Also, this is not a valid halt, see Error_Handler() which is).

The CCU will never (electrically / mechanically) be connected to the car, this is a footgun waiting to happen if some node accidentally uses the 0x02 identifier or a message ID gets corrupted into it

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.

Also, you no longer send to this node anymore so this check does nothing

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.

Comment on lines +10 to +12
#define PING_LIST(OP) \
OP(GR_BCU, 0) \
OP(GR_DASH_PANEL, 1) \
OP(GR_CCU, 2)
OP(BCU, 0) \
OP(Dash_Panel, 1)
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.

This list is not up to date with the current specification

  1. BCU Node Status
  2. GR Inverter Status
  3. Fan Controller 1 Status
  4. Fan Controller 2 Status
  5. Fan Controller 3 Status
  6. Dash Panel Status
  7. TCM Node Status
  8. Reserved
  9. (Another byte likely added later for sensors when those are available, but for now do not worry about them)

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.

Comment on lines 44 to 45
ECU_CAN_Send(GRCAN_BUS_PRIMARY, IDsToBePinged[i], MSG_PING, &(GRCAN_PING_MSG){timestamp}, 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.

Please implement something to not send CAN messages to 8-16 nodes at once, your buffer is only 10 messages

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.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.

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.

Comment on lines +107 to +108
GRCAN_MSG_ID msg_id = GETBITS(ID, 12, 12);
GRCAN_NODE_ID node_id = GETBITS(ID, 4, 8);
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.

Comment on lines 70 to 97
void BMSLights(ECU_StateData *stateLump)
{
bool light = 0;
light |= stateLump->max_cell_temp_c > CRITICAL_MAX_CELL_TEMP_C;
light |= stateLump->ts_voltage > CRITICAL_TS_VOLTAGE;
light |= bmsFailure(stateLump);
// TODO: interrupted/missing BMS vals
GR_OLD_DASH_CONFIG_MSG message = {.led_bits = light};
ECU_CAN_Send(GR_OLD_BUS_PRIMARY, GR_DASH_PANEL, MSG_DASH_CONFIG, &message, sizeof(message));
GRCAN_DASH_CONFIG_MSG message = {.led_bits = light};
ECU_CAN_Send(GRCAN_BUS_PRIMARY, GRCAN_Dash_Panel, MSG_DASH_CONFIG, &message, sizeof(message));
}

void IMDLights(ECU_StateData *stateLump)
{
uint8_t light = 0;
// TODO: isolation failure?
light |= imdFailure(stateLump);
GR_OLD_DASH_CONFIG_MSG message = {.led_bits = (light << 1)};
ECU_CAN_Send(GR_OLD_BUS_PRIMARY, GR_DASH_PANEL, MSG_DASH_CONFIG, &message, sizeof(message));
GRCAN_DASH_CONFIG_MSG message = {.led_bits = (light << 1)};
ECU_CAN_Send(GRCAN_BUS_PRIMARY, GRCAN_Dash_Panel, MSG_DASH_CONFIG, &message, sizeof(message));
}

void BSPDLights(ECU_StateData *stateLump)
{
uint8_t light = 0;
// TODO: isolation failure?
light |= bspdFailure(stateLump);
GR_OLD_DASH_CONFIG_MSG message = {.led_bits = (light << 2)};
ECU_CAN_Send(GR_OLD_BUS_PRIMARY, GR_DASH_PANEL, MSG_DASH_CONFIG, &message, sizeof(message));
GRCAN_DASH_CONFIG_MSG message = {.led_bits = (light << 2)};
ECU_CAN_Send(GRCAN_BUS_PRIMARY, GRCAN_Dash_Panel, MSG_DASH_CONFIG, &message, sizeof(message));
}
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.

Please use SetBitInByte from the BitManipulations library as it will correctly handle LSB/MSB transitions and such

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.

Signed-off-by: Daniel Hansen <dchansen06@gmail.com>
break;
}
respondToPing(sender_id, ((GR_OLD_PING_MSG *)data)->timestamp);
respondToPing(sender_id, ((GRCAN_PING_MSG *)data)->timestamp);
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.

Please note that the debugger may attempt to ping you and will want a valid response (so you would need to respond to the ping as a client or server depending on the node ID)

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.

@dchansen06 dchansen06 marked this pull request as draft April 3, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 URGENT Urgent issue that needs a quick action and resolution Big Fry Something that is complex and/or large Boards Related to or involving any physical boards CMake Anything related to or dealing with CMake Documentation Improvements or additions to documentation Enhancement New feature or request Help | Review Extra attention is needed Peripheral Related to or involving a peripheral including abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Boards To URCA CAN Header Files