-
Notifications
You must be signed in to change notification settings - Fork 0
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
Can #65
Conversation
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.
Some changes im lookin for
Core/Inc/compute.h
Outdated
@@ -14,6 +14,8 @@ | |||
#define MC_BAUD 1000000U |
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.
Nit: idk if I'd call the CAN bus speed a "baud", I feel like that's reserved for serial
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 was from last year but i can change lol
Core/Src/can_handler.c
Outdated
} | ||
|
||
new_msg.len = rx_header.DLC; | ||
new_msg.id = rx_header.StdId; |
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.
Nit: weird tab
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.
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) { |
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.
Again this should work but only if you are sending both CAN bus queues to the same FIFO buffer
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.
Also do we not have a wrapper function for this?
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.
Jk I guess we don't have a wrapper for this
Core/Src/can_handler.c
Outdated
uint8_t get_can_msg(can_msg_t* msg) | ||
{ | ||
/* no messages to read */ | ||
if (ringbuffer_is_empty(&can_receive_queue)) return -1; |
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.
The return type is unsigned, this will result in a high value rather than negative. Prob wanna change to int8_t
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.
Also you could just return the can_msg and if it is empty you return null or somethin
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.
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) { |
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 prob should be tested but looks good if it works as intended
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.
lgtm merge that bad boy
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