After reading the DLT Log, I want to parse it and store it in the field I want. It is never a DLT VIEWER implementation. I simply want to read the log and then just save the log in my structure.
Outputting to the DLT LOG has already been implemented.
Currently I have implemented the following code to read the DLT Log.
FILE *pLogFile = NULL;
pLogFile = fopen(DLTfilename, "rb") ;
if ( pLogFile )
{
while ( fgets( buff, gBuffSize, pLogFile ) )
{
for ( int i=0; i < gBuffSize - 13 ; ++i )
{
// LF
if ( buff[i] == 0x0A )
{
break ;
}
//...............
//read and save
//...............
}
}
}
The above code scan each byte until it finds the desired string, but it is so slow! I'm looking for a way to optimize it.
I've tried several ways to read each line, but I could not read it as a separator like "\n
", and when I read it with a program like notepad, I noticed that the characters were mixed.
I have two questions.
- I want to know the format of DLT Log.
I searched the internet but I could not get any clue about its structure.
- If you are a developer who has read the DLT Log, I would like to know how to improve the above code.
It's enough to let me know what sites I can refer to.
1. Basic structure of a DLT log format: header + payload
Autosar std 20-11 terminology:
Header:
In header: Standard header + Extended header
For further information:
DLt plugin (javascript), also doing the same parsing work (50% progress)
DLT specification doc Autosar standard R20-11
Message format (5.1) in R20-11 Autosar protocolv1
2. For optimizing the code:
I suggest looking into some dlt_client implementations including their decoded mechanism (dlt-receive -a, dlt-viewer, dlt-convert -a, etc)