How to Create diagRequest/diagResponse-Object by Using a String-Variable in CAPL

Question:
How can I create a diagRequest/diagResponse-object by using a String-Variable in CAPL?
Answer:

If the Service Qualifier for a diagnostic service is provided as string, it is possible to re-initialize an already existing diagRequest/diagResponse-object by using the CAPL-function diagInitialize.


Please take into consideration, that the ECU-qualifier is not submitted to this function which means that the target ECU has to be specified before.


This can be done either by using the function diagSetTarget or by specifying the ECU-qualifier at the initialization of the diagRequest/diagResponse-object:

diagSetTarget("Door");
diagRequest * req;
diagInitialize(req, “serviceQualifier”);

 

or (supported since CANoe 9.0 SP3)
 

diagRequest Door.* req;
diagInitialize(req, “serviceQualifier”);

 

Note:

Please find enclosed a zip-file:

  • The CANoe-Demo contains a test module for testing different diagnostic sessions. The diagnostic services within this module are reinitialized by diagInitialize. The test module`s test report will be stored in the directory Testreport.
  • The example can be used with CANoe 10.0 and higher. The corresponding Diagnostic Description (CDD) is provided in CANdelaStudio 8.5-Format.


Article ID: 1192
Last updated: 2020-05-07
Revision: 11
CANalyzer/CANoe -> Diagnostics -> CAPL -> How to Create diagRequest/diagResponse-Object by Using a String-Variable in CAPL
https://kb.vector.com/entry/1192/