Skip to content
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

Can #65

Merged
merged 5 commits into from
Jan 5, 2024
Merged

Can #65

merged 5 commits into from
Jan 5, 2024

Conversation

dyldonahue
Copy link
Contributor

@dyldonahue dyldonahue commented Dec 16, 2023

creates a can interface based on new driver and implements this interface across our app. We do not yet haver CAN ids worked out, but to give an example, i mocked the receive handling for the charger message telling us if connected.

Todo still:

  • update inbound can hanlder with all inbound mesdsages & correct IDs

  • update outbound can messages with correct IDs

  • address Charge Safety relay. I believe this is going to be on charger and will require an outbound can message to charger (either to set or get this pin) but i dont yet know if needed

@dyldonahue dyldonahue requested a review from nwdepatie December 16, 2023 14:50
Copy link
Contributor

@nwdepatie nwdepatie left a comment

Choose a reason for hiding this comment

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

Some changes im lookin for

Core/Inc/can_handler.h Show resolved Hide resolved
@@ -14,6 +14,8 @@
#define MC_BAUD 1000000U
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: idk if I'd call the CAN bus speed a "baud", I feel like that's reserved for serial

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was from last year but i can change lol

}

new_msg.len = rx_header.DLC;
new_msg.id = rx_header.StdId;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: weird tab

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gonna run trhough autoformmater once all changes made

CAN_RxHeaderTypeDef rx_header;
can_msg_t new_msg;
/* Read in CAN message */
if (HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &rx_header, new_msg.data) != HAL_OK) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Again this should work but only if you are sending both CAN bus queues to the same FIFO buffer

Copy link
Contributor

Choose a reason for hiding this comment

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

Also do we not have a wrapper function for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Jk I guess we don't have a wrapper for this

uint8_t get_can_msg(can_msg_t* msg)
{
/* no messages to read */
if (ringbuffer_is_empty(&can_receive_queue)) return -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

The return type is unsigned, this will result in a high value rather than negative. Prob wanna change to int8_t

Copy link
Contributor

Choose a reason for hiding this comment

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

Also you could just return the can_msg and if it is empty you return null or somethin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

idk i was gonna handle this by doing (if !get message then do this), seems a little neater than if (can msg != NULL) and then have to make sure i reset the local message to NULL each loop. But yeah i do need to do int8 or just return 1


new_msg.len = rx_header.DLC;
new_msg.id = rx_header.StdId;
if (hcan == &hcan1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This prob should be tested but looks good if it works as intended

Copy link
Contributor

@nwdepatie nwdepatie left a comment

Choose a reason for hiding this comment

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

lgtm merge that bad boy

@dyldonahue dyldonahue merged commit d81faa1 into main Jan 5, 2024
0 of 2 checks passed
@dyldonahue dyldonahue deleted the can branch January 5, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants