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

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.

답변 (1개)

Qiang Sun
Qiang Sun 2022년 10월 9일
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'));

카테고리

도움말 센터File Exchange에서 Vehicle Network Toolbox에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2022년 6월 2일

답변:

2022년 10월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by