Modifying Read Only ID of CAN message

1 view (last 30 days)
Maximilian Koch
Maximilian Koch on 16 Jul 2020
I'm using a network of multiple sensors that I want to configure over CAN. Each Sensor has an ID from 0-7.
I currently use a CAN-database to create the Config-message. The default config message identifier is 0x200. The identifier gets changed based on the sensor I want to configure like this:
message-ID = 0x200 + sensorID*0x10
So the config message for sensor 0 has ID 0x200, sensor 1 0x210, sensor 2 0x220 and so on. The same is true for all other messages that can be sent.
The easiest solution for me would be to modify the message-ID from the default message (ID 0x200) like I'm already doing it with the signals:
msgRadarCfg = canMessage(dbc,'RadarCfg');
msgRadarCfg.Signals.RadarCfg_SensorID = sensorID;
Message.ID however is read-only, so this doesn't work:
msgRadarCfg.ID = msgRadarCfg.ID + sensorID*16;
Is there another way to change the message ID without me either modifying the dbc-file to include all messages for all sensor-IDs or building the messages "by hand"?

Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!