ndDiagnosticService
- Updated2025-10-07
- 2 minute(s) read
Purpose
Executes a generic diagnostic service. If a special service is not available through the KWP2000, UDS, or OBD service functions, you can build it using this function.
Format
long ndDiagnosticService(
TD1 *diagRef,
LVBoolean *requireResponse,
unsigned char dataIn[],
long len,
unsigned char dataOut[],
long *len2);
Input
diagRef
Specifies the diagnostic session handle, obtained from ndOpenDiagnosticOnCANFD and passed to subsequent diagnostic functions. Normally, it is not necessary to manually manipulate the elements of this struct.
requireResponse
Indicates whether a response to this service is required. If *requireResponse is FALSE, dataOut returns no values, and len2 returns 0. This parameter is passed by reference.
dataIn
Contains the request message byte sequence for the diagnostic service sent to the ECU.
len
Must contain the number of valid data bytes in dataIn. Output
dataOut
Contains the response message byte sequence of the diagnostic service returned from the ECU.
len2
On input, len2 must contain the number of bytes provided for the dataOut buffer. On output, it returns the number of valid data bytes in dataOut.
Return Value
The return value indicates the function call status as a signed 32-bit integer. Zero means the function executed successfully. A negative value specifies an error, which means the function did not perform the expected behavior. A positive value specifies a warning, which means the function performed as expected, but a condition arose that may require attention.
Use the ndStatusToString function to obtain a descriptive string for the return value.
DescriptionndDiagnosticService is a generic routine to execute any diagnostic service. The request and response messages are fed unmodified to the dataIn input and retrieved from the dataOut output, respectively. No interpretation of the contents is done, with one exception: The error number is retrieved from a negative response, if one occurs. In this case, an error is communicated through the return value.
All specialized diagnostic services call ndDiagnosticService internally.