CAPL Script for Diagnostic Services

12,314
on message UPA_to_DTOOL 

is reacting on the CAN message UPA_to_DTOOL, and this you can only access the 8 bytes of the CAN message.

If you want to react on diagnostic messages you should use

on diagResponse <serviceName>

inside of this handler you can then access the complete data of the diagnostic message

Share:
12,314
Admin
Author by

Admin

Updated on June 29, 2022

Comments

  • Admin
    Admin almost 2 years

    I am writing the CAPL script to Automise the Diagnostic services. I have read some DIDs which are bigger than 8 bytes in size. Till 8 bytes I can capture correctly the data in my CAPL script but when the data size exceeds the 8 bytes, then I get some garbage values 00 for remaining bytes.

    The complete read data I can see in CANoe Trace but I am not able to capture it in my CAPL script. If someone has any ideas or solution, please share with me.

    In Belo script, the issue is that I can capture value till this.byte(7) correctly. But for this.byte(8) and this.byte(9) I read 00 although the actual value in CANoe Trace is 0x54 and 0x66. So it means I cannot read more than 8 bytes in CAPL from CAN.

    My script looks like:

    variables
    {
      //Please insert your code below this comment
      byte test_num;
      message DTOOL_to_UPA msg_tester;
      mstimer readTimerDID_2001;
      mstimer defaultSession;
      byte readBuf2001[8];
    }
    
    // read request
    on key 'd'
    {
      test_num = 0; 
      msg_tester.dlc = 8;
      msg_tester.dir = tx;
      msg_tester.can = 1;
      settimer(defaultSession, 2000);  
    }
    
    on timer defaultSession         // Request DID: 10 01
    {
      msg_tester.byte(0) = 0x02;
      msg_tester.byte(1) = 0x10;
      msg_tester.byte(2) = 0x01;
      output(msg_tester);
      settimer(readTimerDID_2001, 100);
      canceltimer(defaultSession);
    }
    
    on timer readTimerDID_2001    // Read Request DID: 22 20 01
    {  
      msg_tester.byte(0) = 0x03;
      msg_tester.byte(1) = 0x22;
      msg_tester.byte(2) = 0x20;
      msg_tester.byte(3) = 0x01;
    
      output(msg_tester);
      canceltimer(readTimerDID_2001);
    }
    
    on message UPA_to_DTOOL 
    {
      if (this.DIR == RX)
      { 
        // Response Data for DID 2001 
        if (
            (this.byte(0)== 0x04)&&(this.byte(1)== 0x62)&&(this.byte(2)==0x20)&&
            (this.byte(3)== 0x01)&&(this.byte(4)== 0x23) &&(this.byte(5)== 0x00)&&
            (this.byte(6)== 0x44)&&(this.byte(7)== 0x22) &&(this.byte(8)==0x54)&&
            (this.byte(9)== 0x66)
          )
          {
            readDID2001();
          }
      }
    }