How can I use the blfread function with a database containing multiplexers?

23 vues (au cours des 30 derniers jours)
Marvin Haferkamp
Marvin Haferkamp le 2 Juin 2022
Hey everyone,
I am currently processing CAN traces including OBD2 messages, the "blfread" function from the Vehicle Network Toolbox has always worked quite well, but I now have a OBD2 database which contains multiplexers. When I use the function the signals are not decoded as desired and the result is the same as when I don't assign a database. Does anyone have an idea to solve the problem or know of another function that can handle this?
candb = canDatabase('OBD2_database.dbc'); % Load database containing multiplexer
data_obd = blfread('Trace_OBD.blf', "Database", candb); % load the trace file and decode with database
This shows the resulting table without multiplexer, in the struct in Column 6 are the Signals decoded.
This shows the resulting table with multiplexer, there is an empty struct in Column 6.
I can see a difference in "candb" after loading between the file with (upper) and without (lower) multiplexer. As you can see in the pictures, the Data Inspector shows that with the multiplexer there is an additional Struct layer, which apparently prevents decoding.

Réponses (1)

Qiang Sun
Qiang Sun le 9 Oct 2022
You can first try to read the blf file, and then find the ID and the corresponding multiplexer information (usually the first byte in the Data field),Based on this information, rename the ID to the mapped ID and save the file. Finally, use the dbc with the mapping ID to parse the new blf file.
Reference code:
blfData = blfread('old_blf',1,"CANStandardFilter",hex2dec('6B2'));% ID,0x6B2
uu=cell2mat(blfData.Data);
vv=uu(:,1);
ww=blfData.ID;
for i = 0:255
blfData. ID(find(vv == i & ww == hex2dec('6B2')))= i + hex2dec('700'); % Mapped ID=the first byte in the data field+0x700
end
blfwrite("new.blf",blfData,1,"CAN");
blfData = blfread('newfile.blf',1,"Database",canDatabase('database_with_mapped_ID'));

Catégories

En savoir plus sur Vehicle Network Toolbox dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by