当前位置:网站首页>The replay block of canoe still needs to be combined with CAPL script to make it clear

The replay block of canoe still needs to be combined with CAPL script to make it clear

2022-07-06 09:48:00 Ant soldier

Related articles

 Insert picture description here


Preface

  • Trace logging Documents are important data for us to analyze problems , I said that before ,CANoe There are many analysis tools , what data,graphics etc. , But the most convenient way to analyze problems in daily work is Trace.

  • But when playing back the match online , It is not possible to play back the selected file directly , You also need to filter the files as necessary

  • The whole network feels that this knowledge point is taking notes , There is no union CAPL And the actual project , But I think this is very necessary

  • Demonstrate hardware and software environment Win10 x64 ; CANoe 11 SP2 x64

  • This chapter demonstrates the source code download , Click the jump

 Please add a picture description

 Please add a picture description

First record a paragraph Trace spare

1️⃣ Create project first , And then create a logging block, Let's record a segment first logging file

  • Here, select the button to trigger to start recording
  • Recording file format selection blf Format , This format is better than ASC Format saves memory

 Insert picture description here


2️⃣ Press down ‘t ’ Start recording , Almost recorded 3 minute , Press again ‘t’ Stop recording

 Insert picture description here


offline mode load logging File analysis `trace( Fast mode )

1️⃣ We have recorded above logging , So let's see how to use this logging To analyze the problem

  • Method 1 : Directly press and hold the file and drag it Trace Inside , It will be loaded soon , The most convenient and fast , Recommended use

 Insert picture description here


2️⃣ By hitting offline mode, Then drag the file into the selection box , Then press Start Button , It will also be loaded soon , It takes so much time , And drag directly to Trace What's the difference between

  1. adopt offline mode Dialog box , You can select multiple files to play back at the same time
  2. See that step The button is not , There is also a time input box behind , What does that mean , Namely , If I don't want to read it all at once , I want to read first 5ms The data of , It's over , I press again step , It loads again 5s The data of . Get it. , According to the time you set , Every time you press step, Just load how much data
  3. The default unit of time frame ms , You can write h, m, s, To represent hours , minute , second , such as 1s, You can Write 1s

 Insert picture description here


Data playback (Replay Block)( Slow mode )

The default configuration ,Run 了 CANoe It triggers Replay Block

1️⃣ Here's the picture ,Replay Block It's a node , Here we shield all other nodes , Create a Replay Block node

 Insert picture description here


2️⃣ Here we choose directly logging file , Don't configure others

 Insert picture description here


3️⃣ direct Start , Let's take a look at Run 了 156s, Trace It stopped.

  • Why above 156s It stops , Because we record Trcae Just 156s , When you play back , The timestamp starts from zero .
  • And the default choice is logging The file is played back only once , You can choose loop playback

 Insert picture description here


 Insert picture description here


Manual trigger Replay Block

  • Start Option Don't check Start replay on measurement start

 Insert picture description here


  • Want to trigger Replay , Need to click Start Just press the key

 Insert picture description here


Key trigger Replay Block

 Insert picture description here


Repeat playback Replay

  • Repeat playback Replay

 Insert picture description here


Filter channel (Channel Mapping)

  • The following figure is based on reality ECU, double CAN A section of channel test Trace Screenshot , Playback select two channels

     Insert picture description here

  • The following figure is based on reality ECU, double CAN A section of channel test Trace Screenshot , Playback all options CAN1 passageway

 Insert picture description here


RX/TX Filter (CAN Option)

  • With CAN Bus as an example , Other bus references help file
  • No matter recording Trace when , At each node RX still TX; Playback of Trace All are TX
  • If you check the RX message , Only the data of the real node is played back , That is to say, recording Trace At the time of the TX Node data is filtered
  • If you check the TX message , The data of real nodes and simulation nodes will be played back , That is to say TX message Is to playback all the data

 Insert picture description here


CAPL Script triggers Replay

  • The following script is to control Replay Start , Stop several functions , In actual engineering projects , Basically all through CAPL Script control Replay To complete the test task
/*@!Encoding:936*/

variables
{
    
char replayName[32] = "ReplayBlock 1";
}

on key 'b'
{
    
replayStart( replayName);
writeReplayState( replayName);
}

on key 'e'
{
    
replayStop( replayName);
writeReplayState( replayName);
}

on key 's'
{
    
replaySuspend( replayName);
writeReplayState( replayName);
}

on key 'r'
{
    
replayResume( replayName);
writeReplayState( replayName);
}


void writeReplayState( char name[])
{
    
switch ( replayState( name))
{
    
case 0:
   write( "Replay Block %s is stopped", replayName);
   break;
case 1:
   write( "Replay Block %s is running", replayName);
   break;
case 2:
   write( "Replay Block %s is suspended", replayName);
   break;
default:
write( "Error: Replay Block %s has an unknown state!", replayName);
   break;
};
}

Node filtering during data playback

  • In actual projects , Whether it's the data from the vehicle test or not , Or bench test data , All need data cleaning to be used for playback and analysis , The functions described above are not enough , Even rarely used
  • The data from the vehicle test will definitely contain the target ECU Of , Playback process , We have to kick the target ECU The data of , There are roughly two common methods ,
  • One is if ASC Formatted data (blf It can also be changed to ASC), Yes, you can use scripts (Python /c++ etc. ) Clean the file , The specific project has realized
  • The other is when replaying messages , Record another message , Add filter nodes during recording , The following code demonstrates this method

1, Here's the picture , We created Logging Block And join in Event Filter

 Insert picture description here


2, Here's the picture , This Trace There are only two nodes in total (Light and Engine), Then we'll put Engine Node data is filtered

 Insert picture description here


3, Here's the picture , Let's configure logging Trigger mode , For the sake of unity Replay Block and Logging Block And stop at the same time , Let's write a little CAPL Timing under script control , In fact, this is also the general practice in actual engineering projects ( Simplify the code here , Tell the core logic )

 Insert picture description here


4, Here's the picture , By pressing the key ‘h’

/*@!Encoding:936*/

variables
{
    
  char replayName[32] = "ReplayBlock 1";
  char loggingName[32] = "Logging";
  msTimer ReplayState ;
}

on timer ReplayState
{
      
  if(replayState(replayName) == 0)//replay end 
  {
    
      stopLogging(loggingName);// stop it logging
  } 
  else
  {
    
      setTimer(ReplayState,100); //100ms
  }
}


on key 'h'
{
    
  replayStart( replayName);  // Start playback 
  setTimer(ReplayState,100); //100ms
  startLogging(loggingName); // Start recording 
}


5, Run After starting the project , Press the button ‘h’, And then wait Run complete , See the recorded logging -2022xxx file . Drag directly to Trace in , See we put Engine Node messages are filtered out , Then this message , Can be used for our Replay Block

 Insert picture description here


Logging File Type conversion

  • blf File format , It takes up a small amount of memory but cannot be used txt open , You can't use scripts to parse
  • asc File format , Large memory consumption , But you can use txt Open it directly , Then delete or change some node data of the file as required
  • CANoe You can directly logging File format conversion

 Insert picture description here

 Insert picture description here

 Insert picture description here

End

summary

23

 Please add a picture description

It needs to be used in the demonstration demo engineering , You can follow the official account online disk below to get it by yourself , Thank you for reading .

7

  • Have the most simple life , The furthest dream , Even if it's freezing tomorrow , Lu Yao's horse died !

  • Wechat partners can pay attention Langge on-board diagnosis , A small circle in the industry , In the group SkyDrive data , Source code , There are all kinds of gods Free time communication technology , Talk about job opportunities .

  • If this blog is helpful to you , please “ give the thumbs-up ” “ Comment on ”“ Collection ” One key, three links Oh ! It's not easy to code words , Everyone's support is my driving force to stick to it .
    18
原网站

版权声明
本文为[Ant soldier]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060903480590.html