3

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();
      }
  }
}
Om Choudhary
  • 492
  • 1
  • 7
  • 27
Hamid Gul
  • 31
  • 1
  • 1
  • 4
  • Please add your script code to the question. [ask] – Tim Hutchison Jun 09 '17 at 12:36
  • 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](https://stackoverflow.com/questions/35626632/transmitting-data-over-iso-tp-transport-protocol-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 Jul 07 '17 at 06:39
  • I m using CDD protocol using Canoe. Database is available. – Hamid Gul Jul 10 '17 at 11:00
  • And i am using UDS protocol. – Hamid Gul Jul 10 '17 at 11:06
  • handle = CanTpCreateConnection(0); // 0 = Normal mode Not supported in my Script – Hamid Gul Jul 11 '17 at 16:13
  • I would suggest to base your implementation on diagRequest and diagResponse objects. Usefull information: https://kb.vector.com/entry/914/ (configuration of diagnostic protocol) https://kb.vector.com/entry/1192/ (creating request manually) Help of CANoe (when you type diagRequest and diagResponse) you will see list of all available methods for each object. – Maciek Nov 29 '19 at 14:15

3 Answers3

1
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

MSpiller
  • 3,500
  • 2
  • 12
  • 24
0

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.

BruceWayne
  • 116
  • 5
0

on message UPA_to_DTOOL

This is working with the UPA_to_DTOOL message. So, the keyword "this" reflects on the message, not the diagnostic response.

Instead, you can use: on diagResponse <service_name>

in that event-based function, you can use "this" and it will reflect as needed correctly on the diagnostic data received.

you can read more about it here: https://support.vector.com/sys_attachment.do?sys_id=cd0b5d3adb0264904896115e6896191a