How can I parse A2L file Function Section ?
    10 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
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.
0 comentarios
Respuestas (2)
  Shivam Sardana
    
 el 25 de Sept. de 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 comentarios
  ganesh dutt
 el 8 de Mzo. de 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.
Ver también
Categorías
				Más información sobre String Parsing en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!