3
votes

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();
      }
  }
}
2
Please add your script code to the question. How to Ask - Tim Hutchison
Hi Hamid, you didn't mention if you have a diagnostic database (ODX, CDD, ...) or which Diagnostic protocol you use (KWP, GMLAN, UDS). The reason I ask is that diagnostic protocols are build on ISO-TP (for CAN). You could use ISO-TP in CAPL (see e. g. Transmitting data over ISO-TP ... in CANoe using CAPL) but when a diagnostic database is available that will be much easier. (When no diagnostic database is available check the documentation for Basic Diagnostics.) - Sonic78
I m using CDD protocol using Canoe. Database is available. - Hamid Gul
And i am using UDS protocol. - Hamid Gul
handle = CanTpCreateConnection(0); // 0 = Normal mode Not supported in my Script - Hamid Gul

2 Answers

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

0
votes

I had a similar problem accessing j1939 PGN with data length code (DLC) > 8 byte. These messages were transmitted as a j1939 Frame (DLC > 8 byte) instead of a CAN frame (DLC = 8 byte) in the trace window. I had to make use of the getThisMessage(pg pg_variable, int length) function in an on pg event like this.

on pg UPA_to_DTOOL {
  pg UPA_to_DTOOL UPA_to_DTOOL_pg;
  getThisMessage(UPA_to_DTOOL, UPA_to_DTOOL.dlc);
  write("byte 9 = %X", UPA_to_DTOOL.byte(9));
}

Because messages with DLC > 8 are transmitted in a special way, the getThisMessage had to be used in my case, which let me access all the message bytes. I am not sure this solution for j1939 PGNs helps you because I do not know whether you have a license for j1939 in your canoe installation.