How can I parse A2L file Function Section ?

12 views (last 30 days)
ilker ozturk
ilker ozturk on 22 Sep 2019
Edited: Seigan on 8 Dec 2022
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.

Answers (2)

Shivam Sardana
Shivam Sardana on 25 Sep 2019
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 Comments
ganesh dutt
ganesh dutt on 8 Mar 2022
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 on 8 Dec 2022
Edited: Seigan on 8 Dec 2022
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 ! 🎉

Sign in to comment.


ilker ozturk
ilker ozturk on 27 Sep 2019
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

Categories

Find more on Characters and Strings 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!