Hi,
I am wondering why the CAN message IDs are defined as they are in https://github.com/vedderb/bldc/blob/master/datatypes.h :
// CAN commands
typedef enum {
CAN_PACKET_SET_DUTY = 0,
CAN_PACKET_SET_CURRENT,
CAN_PACKET_SET_CURRENT_BRAKE,
CAN_PACKET_SET_RPM,
CAN_PACKET_SET_POS,
CAN_PACKET_FILL_RX_BUFFER,
CAN_PACKET_FILL_RX_BUFFER_LONG,
CAN_PACKET_PROCESS_RX_BUFFER,
CAN_PACKET_PROCESS_SHORT_BUFFER,
CAN_PACKET_STATUS,
CAN_PACKET_SET_CURRENT_REL,
CAN_PACKET_SET_CURRENT_BRAKE_REL,
CAN_PACKET_SET_CURRENT_HANDBRAKE,
CAN_PACKET_SET_CURRENT_HANDBRAKE_REL
} CAN_PACKET_ID;
The lower IDs have greater priorities, so it would make sense to have the message types sorted by their real-time needs.
But as far as I currently understand the code, the BUFFER commands are rather used for communications that should be in the lowest priorities, like the communication with the PC tool. Instead they are in the middle of the range. Is there any explanation of why this is so?
The reason is quite simple actually - I have added commands to the end as I have made new commands. This way compatibility is not broken between different firmware versions.
Aha, so making it explicit: CAN ID priorities are not considered important for the working of VESC, and so they are disregarded in favor of backwards compatibility.
Thank you!