Search code examples
capl

Logging DTCs for later analysis


I am new to CAPL and trying to read DTCs periodically using CAPL script and log them to .blf file so they can be analyzed later.

After some research I decided to store all read and identified DTCs to system variable (which I defined as integer array dtcArr with fixed size of 500) as a way to output read DTCs, since system variables are logged also when the logging is started and can be shown from the logs later. Simply using write command to output it to file doesn't help much since that can't be shown in CANalyzer/CANoe on analysis later if I got that right. Basically I'm filling up dtcArr with all read DTCs values in order I read them.

Seems that using associative arrays for system variables is not possible (e.g. using DTC name text as a key), is there a better way to do this?


Solution

  • Easy to achieve. You need a script in the output loop, which makes DTC read requests to the target module. It must also handles any continuation frames that need to be sent:

    variables
    {
      msTimer         can1_ms_timer;
      long            ms_interval = 1000; /* Request rate */
      message CAN1.*  can1_dtc_req_frame = {id=???, dir=tx, byte(0)=0x??, byte(1)=0x??, byte(2)=0x??, etc.};
    }
    
    on key ctrlF1
    {
      write("Starting Read DTC Information from module ???");
      setTimer(can1_ms_timer, ms_interval);
    }
    
    on timer can1_ms_timer
    {
      output(can1_dtc_req_frame);
      setTimer(can1_ms_timer, ms_interval);
    }
    
    on message CAN1.ResponseModule???
    {
      /* Handle sending continuation frame */
    
      output(this);
    }
    

    Now the modules responses shall be stored in the logging file, and you can processes them any way you choose. For my setup, I have a second CAPL script which converts trouble codes to my own custom CAN signals so I can plot their status values in the graph view.

    on message CAN1.ResponseModule???
    {
      /* Process trouble code response */
    }