Dtynin
Dtynin
DIIDevHeads IoT Integration Server
Created by Dtynin on 9/26/2024 in #middleware-and-os
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?
3 replies