How can I parse A2L file Function Section ?

7 ビュー (過去 30 日間)
ilker ozturk
ilker ozturk 2019 年 9 月 22 日
編集済み: Seigan 2022 年 12 月 8 日
Dear Users,
I would like to parse a2l file function interaction. But I could not be succussful.
I have no experience on string processing side of Matlab. Could you help me how can I get function infromations from a2l file?
Example A2L Function Section:
/begin FUNCTION
Vehicle
"0.0.1 Function Name"
/begin DEF_CHARACTERISTIC
Label_1 Label_2 Label_3 Label_4
/end DEF_CHARACTERISTIC
/begin IN_MEASUREMENT
Label_5
/end IN_MEASUREMENT
/begin OUT_MEASUREMENT
Label_7 Label_8 Label_9
/end OUT_MEASUREMENT
/begin LOC_MEASUREMENT
Mp_1 Mp_2 Mp_3 Mp_4 Mp_5
/end LOC_MEASUREMENT
FUNCTION_VERSION "0.0.1"
/end FUNCTION
My Code to READ A2L FUNCTION NAME AND FUNCTION DESCRIPTION
index_number=zeros(k,1);
index_number_a=zeros(k,1);
mm=0;
nn=0;
for i=1:1:k
if (a(i)=="/begin FUNCTION")
nn=i;
index_number_a(i)=nn;
end
end
for kk=1:1:k
if (a(kk)=="/begin DEF_CHARACTERISTIC")
mm=kk;
index_number(kk)=mm;
end
end
index_number_anew=find(index_number_a);
index_number_new=find(index_number);
num=length(index_number_anew);
for pp=1:1:num
t=index_number_anew(pp);
r=index_number_new(pp);
temp=r-t;
for counter=(t+1):1:(r-1)
temp1=strfind(a(counter),'"');
temp2=strcmp(a(counter),"");
if (~isempty(a(counter)) && isempty(temp1)&&(temp2==0))
FunctionNaming(counter)=a(counter);
end
if (~isempty(a(counter)) && ~isempty(temp1)&&(temp2==0))
FunctionDescription1(counter)=a(counter);
end
end
end
Could you offer a suggestion to read a2l file on matlab I will be appreciate to you.

回答 (2 件)

Shivam Sardana
Shivam Sardana 2019 年 9 月 25 日
You can use xcpA2L function to read A2L file. You can refer to the link for the documentation of A2L File Management: https://www.mathworks.com/help/vnt/a2l-file-management.html
  2 件のコメント
ganesh dutt
ganesh dutt 2022 年 3 月 8 日
Hello Shivam, I am trying to Parse the A2l file in Matlab using xcpA2L function but I am getting error like " Reference to non-existent field 'ROOT'". Please answer my query so that I can move forward with my work.
Seigan
Seigan 2022 年 12 月 8 日
編集済み: Seigan 2022 年 12 月 8 日
Hi, I have the same issue as ganesh. xcpA2L fails and returns " Reference to non-existent field 'ROOT' ".
I'm using MATLAB 2020b.
Any guidance please?
EDIT : it works fine on 2022b ! 🎉

サインインしてコメントする。


ilker ozturk
ilker ozturk 2019 年 9 月 27 日
Hi Shivam,
Actually I have checked xcpA2L function on Matlab, Unfortunately, this function does not provide the function relationships. I have to read which function have which charactesristics. If you know how can I get this info from xcpA2L function, please write me becauce I could not get any clue according to my problem.
Have a good weekend.
Ilker

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by