Ensuring Message Prioritization on CAN Bus with AVR128DA48 and Zephyr OS for Industrial Monitoring

I’m trying to implement message prioritization on the CAN Bus for my Smart Industrial Monitoring System. High-priority messages (emergency alerts) should be transmitted before regular sensor data. I’m using the AVR128DA48 with Zephyr OS. This is how I’ve set up the message:
struct zcan_frame emergency_frame = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x100, // Higher priority
.dlc = 1,
.data = {0xFF},
};

struct zcan_frame regular_frame = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x300, // Lower priority
.dlc = 1,
.data = {0x01},
};
struct zcan_frame emergency_frame = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x100, // Higher priority
.dlc = 1,
.data = {0xFF},
};

struct zcan_frame regular_frame = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x300, // Lower priority
.dlc = 1,
.data = {0x01},
};
Both messages are being transmitted, but I’m noticing that the regular messages are sometimes sent before the emergency ones. What am I missing in terms of message prioritization on the CAN Bus, and how can I ensure that high-priority messages are always transmitted first?
2 Replies
ZacckOsiemo
ZacckOsiemo3mo ago
it would help it you understood how CAN arbitration works
Alien Queen
Alien Queen3mo ago
@Dtynin CAN Bus prioritization is based on the identifier of the message. The lower the identifier value, the higher the priority. If your high-priority messages are not being sent first, check your identifier values if they are correct, your message transmission queue and hardware/software configuration
Want results from more Discord servers?
Add your server