DLT logging file parsing

3.2k Views Asked by At

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.

  1. I want to know the format of DLT Log.

I searched the internet but I could not get any clue about its structure.

  1. 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

There are 1 best solutions below

0
On

1. Basic structure of a DLT log format: header + payload

Autosar std 20-11 terminology:

Log and trace message:
A log and trace message contains all data and options to describe a log
and trace event in a software. A log and trace message consists of a
header and payload.

Header:

+Pattern: DLT0x01
+Broken time (ISO C)
+Microsecond of broken time
+Epoch of system/Timestamp
+Msg counter
+ECU ID
+APP ID
+Info of msg type and length
+Verbose status
+Number of arguments

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)