Instruments Corporation. National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.
Page 4
These classes are known as Class A (for use in industrial-commercial locations only) or Class B (for use in residential or commercial locations). All National Instruments (NI) products are FCC Class A products. Depending on where it is operated, this Class A product could be subject to restrictions in the FCC rules. (In Canada, the Department of Communications (DOC), of Industry Canada, regulates wireless interference in much the same way.) Digital...
Page 6
Contents Visual C++ 6 ....................3-2 Other Programming Languages ..............3-2 Debugging an Application..................... 3-3 Chapter 4 Using the Automotive Diagnostic Command Set Structure of the Automotive Diagnostic Command Set ..........4-1 Automotive Diagnostic Command Set API Structure........... 4-2 General Programming Model ..................4-3 Available Diagnostic Services..................
Page 8
Contents Chapter 6 Automotive Diagnostic Command Set API for C Section Headings ......................6-1 Purpose......................6-1 Format ......................6-1 Input and Output ..................... 6-1 Description ...................... 6-1 List of Data Types ......................6-2 List of Functions......................6-3 General Functions......................6-12 ndCloseDiagnostic ..................
About This Manual Related Documentation The following documents contain information that you might find helpful as you read this manual: • ANSI/ISO Standard 11898-1993, Road Vehicles—Interchange of Digital Information—Controller Area Network (CAN) for High-Speed Communication • CAN Specification Version 2.0, 1991, Robert Bosch GmbH., Postfach 106050, D-70049 Stuttgart 1 •...
Chapter 1 Introduction Transport Protocol As KWP2000 uses messages of variable byte lengths, a transport protocol is necessary on layers with only a well defined (short) message length, such as CAN. The transport protocol splits a long KWP2000 message into pieces that can be transferred over the network and reassembles those pieces to recover the original message.
Chapter 1 Introduction Measurements Use the ReadDataByLocal/CommonIdentifier services to access ECU data in a way similar to a DAQ list. A Local/CommonIdentifier describes a list of ECU quantities that are then transferred from the ECU to the tester. The transfer can be either single value or periodic, with a slow, medium, or fast transfer rate.
Chapter 1 Introduction Some parameters to both the Request and Positive Response Messages are optional. Note Each service defines these parameters. Also, the standard does not define all parameters. The Negative Response Message is usually a three-byte message: it has the Negative Response ServiceId (0x7F) as first byte, an echo of the original ServiceId as second byte, and a ResponseCode as third byte.
LabVIEW Real-Time (RT) Configuration LabVIEW Real-Time (RT) combines easy-to-use LabVIEW programming with the power of real-time systems. When you use a National Instruments PXI controller as a LabVIEW RT system, you can install a PXI CAN card and use the NI-CAN APIs to develop real-time applications. As with any...
The Automotive Diagnostic Command Set software supports Microsoft Visual C/C++ 6. The header file and library for Visual C/C++ 6 are in the \ProgramFiles\National Instruments\Automotive folder. To use the Diagnostic Command Set\MS Visual C Automotive Diagnostic Command Set API, include the nidiagcs.h...
Chapter 4 Using the Automotive Diagnostic Command Set The Automotive Diagnostic Command Set is structured into three layers of functionality: • The top layer implements three sets of diagnostic services for the diagnostic protocols KWP2000, UDS (DiagOnCAN), and OBD (On-Board Diagnostics). •...
The standards on automotive diagnostic define many different services for many purposes. Unfortunately, most services leave a large amount of room for manufacturer-specific variants and extensions. National Instruments implemented the most used variants while trying not to overload them with optional parameters.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW List of VIs The following table is an alphabetical list of the Automotive Diagnostic Command Set VIs. Table 5-1. Automotive Diagnostic Command Set API VIs for LabVIEW Function Purpose ClearDiagnosticInformation.vi Executes the ClearDiagnosticInformation service and clears selected Diagnostic Trouble Codes (DTCs).
Page 30
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Table 5-1. Automotive Diagnostic Command Set API VIs for LabVIEW (Continued) Function Purpose OBD Request Powertrain Freeze Frame Data.vi Executes the OBD Request Powertrain Freeze Frame Data service. Reads a data record from the ECU that has been stored while a Diagnostic Trouble Code occurred.
Page 32
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Table 5-1. Automotive Diagnostic Command Set API VIs for LabVIEW (Continued) Function Purpose UDS ReadDataByIdentifier.vi Executes the UDS ReadDataByIdentifier service. Reads a data record from the ECU. UDS ReadMemoryByAddress.vi Executes the UDS ReadMemoryByAddress service.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW General Functions Close Diagnostic.vi Purpose Closes a diagnostic session. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Convert from Phys.vi Purpose Converts a physical data value into a binary representation using a type descriptor. Format Input type descriptor is a cluster that specifies the conversion of the physical value to its binary representation: Start Byte gives the start byte of the binary representation.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Convert to Phys.vi Purpose Converts a binary representation of a value into its physical value using a type descriptor. Format Input type descriptor is a cluster that specifies the conversion of the binary representation to its physical value: Start Byte gives the binary representation start byte in the data in record.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Create Extended CAN IDs.vi Purpose Creates diagnostic CAN IDs according to ISO 15765-2. Format Input addressing mode specifies whether the ECU is physically or functionally addressed. transport protocol specifies whether normal or mixed mode addressing is used.
Page 42
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Wait Frames to Send (N_WAIT) is the number of WAIT frames the master sends every time before a CTS frame is sent. If this value is set to a negative number (for example, 0xFFFFFFFF = –1), the master sends an OVERLOAD frame instead of a WAIT, and reception is aborted.
Page 44
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Wait Frames to Send (N_WAIT) is the number of WAIT frames the master sends every time before a CTS frame is sent. If this value is set to a negative number (for example, 0xFFFFFFFF = –1), the master sends an OVERLOAD frame instead of a WAIT, and reception is aborted.
Page 46
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. error code is the error code sent with a negative response message. In addition, the error cluster indicates an error and gives a more detailed description.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW OBD Open.vi Purpose Opens an OBD-II diagnostic session on a CAN port. Format Input CAN interface specifies the CAN interface on which the diagnostic communication should take place. The values are CAN0, CAN1, and so on. baudrate is the diagnostic communication baud rate.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Open Diagnostic.vi Purpose Opens a diagnostic session on a CAN port. Communication to the ECU is not yet started. Format Input CAN interface specifies the CAN interface on which the diagnostic communication should take place.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW VWTP Connect.vi Purpose Establishes a connection channel to an ECU using the VW TP 2.0. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW VWTP Connection Test.vi Purpose Maintains a connection channel to an ECU using the VW TP 2.0. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW VWTP Disconnect.vi Purpose Terminates a connection channel to an ECU using the VW TP 2.0. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW KWP2000 Services ClearDiagnosticInformation.vi Purpose Executes the ClearDiagnosticInformation service and clears selected Diagnostic Trouble Codes (DTCs). Format Input DTC descriptor is a cluster that describes the DTC records the ECU delivers: DTC Byte Length indicates the number of bytes the ECU sends for each DTC.
Page 60
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW code is the error code number identifying an error. A value of 0 means success. A negative value means error: the VI did not execute the intended operation. A positive value means warning: the VI executed intended operation, but an informational warning is returned.
Page 62
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW group of DTC specifies the group of Diagnostic Trouble Codes to be controlled. The following values have a special meaning, and you can specify them through a ring control: 0x0000 All powertrain DTCs 0x4000 All chassis DTCs 0x8000...
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW DisableNormalMessageTransmission.vi Purpose Executes the DisableNormalMessageTransmission service. The ECU no longer transmits its regular communication messages (usually CAN messages). Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW ECUReset.vi Purpose Executes the ECUReset service. Resets the ECU. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW EnableNormalMessageTransmission.vi Purpose Executes the EnableNormalMessageTransmission service. The ECU starts transmitting its regular communication messages (usually CAN messages). Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW InputOutputControlByLocalIdentifier.vi Purpose Executes the InputOutputControlByLocalIdentifier service. Modifies ECU I/O port behavior. Format Input data in defines application-specific data for this service. diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW ReadDataByLocalIdentifier.vi Purpose Executes the ReadDataByLocalIdentifier service. Reads a data record from the ECU. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW ReadDTCByStatus.vi Purpose Executes the ReadDiagnosticTroubleCodesByStatus service. Reads selected Diagnostic Trouble Codes (DTCs). Format Input DTC descriptor is a cluster that describes the DTC records the ECU delivers: DTC Byte Length indicates the number of bytes the ECU sends for each DTC.
Page 76
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Status is the DTC status. Usually, this is a bit field with the following meaning: Meaning testFailed testFailedThisMonitoringCycle pendingDTC confirmedDTC testNotCompletedSinceLastClear testFailedSinceLastClear testNotCompletedThisMonitoringCycle warningIndicatorRequested Add Data contains optional additional data for this DTC. Usually, this does not contain valid information (refer to DTC descriptor) success? indicates successful receipt of a positive response message for this diagnostic service.
Page 78
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions. If the error in cluster indicated an error, the error out cluster contains the same information. Otherwise, error out describes the error status of this VI.
Page 80
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. Data out returns the memory data from the ECU. success? indicates successful receipt of a positive response message for this diagnostic service.
Page 82
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW group of DTC specifies the group of Diagnostic Trouble Codes to be read. The following values have a special meaning, and you can specify them through a ring control: 0x0000 All powertrain DTCs 0x4000 All chassis DTCs 0x8000...
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW RequestRoutineResultsByLocalIdentifier.vi Purpose Executes the RequestRoutineResultsByLocalIdentifier service. Returns results from a routine on the ECU. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW RequestSeed.vi Purpose Executes the SecurityAccess service to retrieve a seed from the ECU. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW SendKey.vi Purpose Executes the SecurityAccess service to send a key to the ECU. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW StartDiagnosticSession.vi Purpose Executes the StartDiagnosticSession service. Sets up the ECU in a specific diagnostic mode. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW StartRoutineByLocalIdentifier.vi Purpose Executes the StartRoutineByLocalIdentifier service. Executes a routine on the ECU. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW StopDiagnosticSession.vi Purpose Executes the StopDiagnosticSession service. Returns the ECU to normal mode. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW StopRoutineByLocalIdentifier.vi Purpose Executes the StopRoutineByLocalIdentifier service. Stops a routine on the ECU. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW TesterPresent.vi Purpose Executes the TesterPresent service. Keeps the ECU in diagnostic mode. Format Input diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs. Normally, it is not necessary to manually manipulate the elements of this cluster.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW WriteDataByLocalIdentifier.vi Purpose Executes the WriteDataByLocalIdentifier service. Writes a data record to the ECU. Format Input data in defines the data record written to the ECU. If you know the record data description, you can use Convert from Phys.vi to generate this record.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW WriteMemoryByAddress.vi Purpose Executes the WriteMemoryByAddress service. Writes data to the ECU memory. Format Input data in defines the memory block to be written to the ECU. diag ref in specifies the diagnostic session handle, obtained from Open Diagnostic.vi and wired through subsequent diagnostic VIs.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW UDS (DiagOnCAN) Services UDS ClearDiagnosticInformation.vi Purpose Executes the UDS ClearDiagnosticInformation service. Clears selected Diagnostic Trouble Codes (DTCs). Format Input DTC descriptor is a cluster that describes the DTC records the ECU delivers: DTC Byte Length indicates the number of bytes the ECU sends for each DTC.
Page 106
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Description This VI clears the diagnostic information on the ECU memory. If the group of DTC parameter is present, the ECU is requested to clear all memory including the DTCs. For further details about this service, refer to the ISO 15765-3 standard. Automotive Diagnostic Command Set User Manual 5-80 ni.com...
Page 108
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW code is the error code number identifying an error. A value of 0 means success. A negative value means error: the VI did not execute the intended operation. A positive value means warning: the VI executed intended operation, but an informational warning is returned.
Page 110
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions.
Page 112
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions.
Page 114
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW source identifies the VI where the error occurred. Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. success? indicates successful receipt of a positive response message for this diagnostic service.
Page 116
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW code is the error code number identifying an error. A value of 0 means success. A negative value means error: the VI did not execute the intended operation. A positive value means warning: the VI executed intended operation, but an informational warning is returned.
Page 118
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. data out returns the data record from the ECU. If you know the record data description, you can use Convert to Phys.vi to interpret this record.
Page 120
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. data out returns the ECU memory data. success? indicates successful receipt of a positive response message for this diagnostic service.
Page 122
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW severity mask defines the status of DTCs to be read. The values are application specific. status defines the status of DTCs to be read. The values are application specific. error in is a cluster that describes error conditions occurring before the VI executes.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW UDS ReportDTCByStatusMask.vi Purpose Executes the ReportDTCByStatusMask subfunction of the UDS ReadDiagnosticTroubleCodeInformation service. Reads selected Diagnostic Trouble Codes (DTCs). Format Input DTC descriptor is a cluster that describes the DTC records the ECU delivers: DTC Byte Length indicates the number of bytes the ECU sends for each DTC.
Page 126
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions. If the error in cluster indicated an error, the error out cluster contains the same information. Otherwise, error out describes the error status of this VI.
Page 128
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW DTC mask record defines the status of DTCs to be read. The values are application specific. error in is a cluster that describes error conditions occurring before the VI executes. If an error has already occurred, the VI returns the value of the error in cluster to error out.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW UDS ReportSupportedDTCs.vi Purpose Executes the ReportSupportedDTCs subfunction of the UDS ReadDiagnosticTroubleCodeInformation service. Reads all supported Diagnostic Trouble Codes (DTCs). Format Input DTC descriptor is a cluster that describes the DTC records the ECU delivers: DTC Byte Length indicates the number of bytes the ECU sends for each DTC.
Page 132
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions. If the error in cluster indicated an error, the error out cluster contains the same information. Otherwise, error out describes the error status of this VI.
Page 134
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions. If the error in cluster indicated an error, the error out cluster contains the same information. Otherwise, error out describes the error status of this VI.
Page 136
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW code is the error code number identifying an error. A value of 0 means success. A negative value means error: the VI did not execute the intended operation. A positive value means warning: the VI executed intended operation, but an informational warning is returned.
Page 138
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions.
Page 140
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW error out describes error conditions. If the error in cluster indicated an error, the error out cluster contains the same information. Otherwise, error out describes the error status of this VI. status is TRUE if an error occurred.
Page 142
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions.
Page 144
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions.
Page 146
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. success? indicates successful receipt of a positive response message for this diagnostic service. error out describes error conditions.
Page 148
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. data out returns application-specific data for this service. success? indicates successful receipt of a positive response message for this diagnostic service.
Page 150
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. data out returns the ECU data record. If you know the record data description, you can use Convert from Phys.vi to interpret this record.
Page 152
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW status is TRUE if an error occurred. This VI is not executed when status is TRUE. code is the error code number identifying an error. A value of 0 means success. A negative value means error: the VI did not execute the intended operation.
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW OBD Request Emission Related DTCs During Current Drive Cycle.vi Purpose Executes the OBD Request Emission Related DTCs During Current Drive Cycle service. Reads the emission-related Diagnostic Trouble Codes (DTCs) that occurred during the current (or last completed) drive cycle.
Page 156
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW For OBD, this field usually does not contain valid information. Add Data contains optional additional data for this DTC. Usually, this does not contain valid information (refer to DTC descriptor). success? indicates successful receipt of a positive response message for this diagnostic service.
Page 158
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. data out returns the ECU data record. If you know the record data description, you can use Convert from Phys.vi to interpret this record.
Page 160
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. data out returns the ECU data record. If you know the record data description, you can use Convert from Phys.vi to interpret this record.
Page 162
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW error out describes error conditions. If the error in cluster indicated an error, the error out cluster contains the same information. Otherwise, error out describes the error status of this VI. status is TRUE if an error occurred.
Page 164
Chapter 5 Automotive Diagnostic Command Set API for LabVIEW Output diag ref out is a copy of diag ref in. You can wire it to subsequent diagnostic VIs. data out returns the vehicle information from the ECU. You can obtain the description from the SAE J1979 standard.
Chapter 6 Automotive Diagnostic Command Set API for C List of Data Types The following data types are used with the Automotive Diagnostic Command Set API for C functions. Table 6-1. Data Types for the Automotive Diagnostic Command Set for C Data Type Purpose 8-bit signed integer...
Page 168
Chapter 6 Automotive Diagnostic Command Set API for C Table 6-2. Functions for the Automotive Diagnostic Command Set for C (Continued) Function Purpose Executes the ndDisableNormalMessageTransmission DisableNormalMessage Transmission service. The ECU no longer transmits its regular communication messages (usually CAN messages).
Page 170
Chapter 6 Automotive Diagnostic Command Set API for C Table 6-2. Functions for the Automotive Diagnostic Command Set for C (Continued) Function Purpose Executes the OBD ndOBDRequestPowertrainFreezeFrameData Request Powertrain Freeze Frame Data service. Reads an ECU data record stored while a diagnostic trouble code occurred.
Page 172
Chapter 6 Automotive Diagnostic Command Set API for C Table 6-2. Functions for the Automotive Diagnostic Command Set for C (Continued) Function Purpose Executes the ndStopRoutineByLocalIdentifier StopRoutineByLocal Identifier service. Stops a routine on the ECU. Executes the ndTesterPresent TesterPresent service. Keeps the ECU in diagnostic mode.
Page 174
Chapter 6 Automotive Diagnostic Command Set API for C Table 6-2. Functions for the Automotive Diagnostic Command Set for C (Continued) Function Purpose Executes the ndUDSReportSeverityInformationOfDTC ReportSeverity InformationOfDTC subfunction of the UDS ReadDiagnosticTrouble CodeInformation service. Reads selected Diagnostic Trouble Codes (DTCs) are read.
Chapter 6 Automotive Diagnostic Command Set API for C General Functions ndCloseDiagnostic Purpose Closes a diagnostic session. Format long ndCloseDiagnostic( TD1 *diagRefIn); Input diagRefIn Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions. Normally, it is not necessary to manually manipulate the elements of this struct.
Page 178
Chapter 6 Automotive Diagnostic Command Set API for C Output dataOut Points to the byte array to be filled with the binary representation of value On input, must contain the array length. On return, it contains the number dataOut of valid data bytes in the array.
Page 180
Chapter 6 Automotive Diagnostic Command Set API for C dataIn Points to the byte array that contains the binary representation of value Must contain the array length. dataIn Output value The physical value converted from the binary representation. Description Data output from diagnostic services (for example, ) is ndReadDataByLocalIdentifier usually a byte stream of binary data.
Page 182
Chapter 6 Automotive Diagnostic Command Set API for C Output transmitID The generated CAN identifier for sending diagnostic request messages from the host to the ECU. receiveID The generated CAN identifier for sending diagnostic response messages from the ECU to the host. Description ISO 15765-2 specifies a method for creating (extended/29 bit) CAN identifiers for diagnostic applications given the addressing mode (physical/functional), the transport protocol...
Page 184
Chapter 6 Automotive Diagnostic Command Set API for C 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.
Chapter 6 Automotive Diagnostic Command Set API for C ndGetProperty Purpose Gets a diagnostic global internal parameter. Format void ndGetProperty( unsigned short propertyID, unsigned long *propertyValue); Input propertyID Defines the parameter whose value is to be retrieved: Timeout Diag Command is the timeout in milliseconds the master waits for the response to a diagnostic request message.
Chapter 6 Automotive Diagnostic Command Set API for C ndOBDOpen Purpose Opens a diagnostic session on a CAN port for OBD-II. Format long ndOBDOpen ( char CANInterface[], unsigned long baudrate, unsigned long transmitID, unsigned long receiveID, TD1 *diagRefOut); Input CANInterface Specifies the CAN interface on which the diagnostic communication should take place.
Chapter 6 Automotive Diagnostic Command Set API for C ndOpenDiagnostic Purpose Opens a diagnostic session on a CAN port. Communication to the ECU is not yet started. Format long ndOpenDiagnostic( char CANInterface[], unsigned long baudrate, unsigned short transportProtocol, unsigned long transmitID, unsigned long receiveID, TD1 *diagRefOut);...
Chapter 6 Automotive Diagnostic Command Set API for C ndSetProperty Purpose Sets a diagnostic global internal parameter. Format void ndSetProperty( unsigned short propertyID, unsigned long propertyValue); Input propertyID Defines the parameter whose value is to be modified: Timeout Diag Command is the timeout in milliseconds the master waits for the response to a diagnostic request message.
Chapter 6 Automotive Diagnostic Command Set API for C ndStatusToString Purpose Returns a description for an error code. Format void ndStatusToString( long errorCode, char message[], long *len); Input errorCode The status code (return value) of any other diagnostic functions. Output message Returns a descriptive string for the error code.
Chapter 6 Automotive Diagnostic Command Set API for C ndVWTPConnect Purpose Establishes a connection channel to an ECU using the VW TP 2.0. Format long ndVWTPConnect( TD1 *diagRef, unsigned long channelID, unsigned char applicationType); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Chapter 6 Automotive Diagnostic Command Set API for C ndVWTPConnectionTest Purpose Maintains a connection channel to an ECU using the VW TP 2.0. Format long ndVWTPConnectionTest( TD1 *diagRef); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Chapter 6 Automotive Diagnostic Command Set API for C KWP2000 Services ndClearDiagnosticInformation Purpose Executes the ClearDiagnosticInformation service. Clears selected Diagnostic Trouble Codes (DTCs). Format long ndClearDiagnosticInformation( TD1 *diagRef, unsigned short groupOfDTC, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Chapter 6 Automotive Diagnostic Command Set API for C ndControlDTCSetting Purpose Executes the ControlDTCSetting service. Modifies the generation behavior of selected Diagnostic Trouble Codes (DTCs). Format long ndControlDTCSetting( TD1 *diagRef, unsigned short groupOfDTC, unsigned char dataIn[], long len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from...
Chapter 6 Automotive Diagnostic Command Set API for C ndDisableNormalMessageTransmission Purpose Executes the DisableNormalMessageTransmission service. The ECU no longer transmits its regular communication messages (usually CAN messages). Format long ndDisableNormalMessageTransmission( TD1 *diagRef, LVBoolean *requireResponse, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Page 206
Chapter 6 Automotive Diagnostic Command Set API for C Output success Indicates successful receipt of a positive response message for this diagnostic service. Return Value The return value indicates the function call status as a signed 32-bit integer. Zero means the function executed successfully.
Chapter 6 Automotive Diagnostic Command Set API for C ndInputOutputControlByLocalIdentifier Purpose Executes the InputOutputControlByLocalIdentifier service. Modifies the ECU I/O port behavior. Format long ndInputOutputControlByLocalIdentifier( TD1 *diagRef, unsigned char localID, unsigned char mode, unsigned char dataIn[], long len, unsigned char dataOut[], long *len2, LVBoolean *success);...
Chapter 6 Automotive Diagnostic Command Set API for C ndReadDataByLocalIdentifier Purpose Executes the ReadDataByLocalIdentifier service. Reads an ECU data record. Format long ndReadDataByLocalIdentifier( TD1 *diagRef, unsigned char localID, unsigned char dataOut[], long *len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Chapter 6 Automotive Diagnostic Command Set API for C ndReadDTCByStatus Purpose Executes the ReadDiagnosticTroubleCodesByStatus service. Reads selected Diagnostic Trouble Codes (DTCs). Format long ndReadDTCByStatus( TD1 *diagRef, unsigned char mode, unsigned short groupOfDTC, TD3 *DTCDescriptor, TD4 DTCs[], long *len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from...
Page 214
Chapter 6 Automotive Diagnostic Command Set API for C testNotCompletedThisMonitoringCycle warningIndicatorRequested contains optional additional data for this DTC. Usually, this does not AddData contain valid information (refer to DTCDescriptor On input, must contain the array length in elements. On return, it contains the DTCs number of valid elements in the array.
Page 216
Chapter 6 Automotive Diagnostic Command Set API for C Description This function requests identification data from the ECU. identifies the type of mode identification data requested. The ECU returns identification data that can access. dataOut format and definition are vehicle manufacturer specific. dataOut For further details about this service, refer to the ISO 14230-3 standard.
Page 218
Chapter 6 Automotive Diagnostic Command Set API for C 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.
Page 220
Chapter 6 Automotive Diagnostic Command Set API for C indicates the number of bytes the ECU sends for each DTC’s StatusByteLength status. The default is 1. indicates the number of bytes the ECU sends for each DTC’s AddDataByteLength additional data. Usually, there are no additional data, so the default is 0. indicates the byte ordering for multibyte items: ByteOrder 0: MSB_FIRST (Motorola), default...
Chapter 6 Automotive Diagnostic Command Set API for C ndRequestRoutineResultsByLocalIdentifier Purpose Executes the RequestRoutineResultsByLocalIdentifier service. Returns results from an ECU routine. Format long ndRequestRoutineResultsByLocalIdentifier( TD1 *diagRef, unsigned char localID, unsigned char dataOut[], long *len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Chapter 6 Automotive Diagnostic Command Set API for C ndRequestSeed Purpose Executes the SecurityAccess service to retrieve a seed from the ECU. Format long ndRequestSeed( TD1 *diagRef, unsigned char accessMode, unsigned char seedOut[], long *len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Chapter 6 Automotive Diagnostic Command Set API for C ndSendKey Purpose Executes the SecurityAccess service to send a key to the ECU. Format long ndSendKey( TD1 *diagRef, unsigned char accessMode, unsigned char keyIn[], long len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Chapter 6 Automotive Diagnostic Command Set API for C ndStartDiagnosticSession Purpose Executes the StartDiagnosticSession service. The ECU is set up in a specific diagnostic mode. Format long ndStartDiagnosticSession( TD1 *diagRef, unsigned char mode, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Chapter 6 Automotive Diagnostic Command Set API for C ndStartRoutineByLocalIdentifier Purpose Executes the StartRoutineByLocalIdentifier service. Executes a routine on the ECU. Format long ndStartRoutineByLocalIdentifier( TD1 *diagRef, unsigned char localID, unsigned char dataIn[], long len, unsigned char dataOut[], long *len2, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from...
Chapter 6 Automotive Diagnostic Command Set API for C ndStopDiagnosticSession Purpose Executes the StopDiagnosticSession service. Returns the ECU to normal mode. Format long ndStopDiagnosticSession( TD1 *diagRef, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Page 234
Chapter 6 Automotive Diagnostic Command Set API for C 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.
Page 236
Chapter 6 Automotive Diagnostic Command Set API for C The TesterPresent service is this “keep alive” signal. It does not affect any other ECU operation. Keep calling within the ECU timeout period if no other service is ndTesterPresent executed. Automotive Diagnostic Command Set User Manual 6-72 ni.com...
Page 238
Chapter 6 Automotive Diagnostic Command Set API for C Description This function performs the WriteDataByLocalIdentifier service and writes RecordValues (data values) to the ECU. identifies the data values to be transmitted. The vehicle dataIn manufacturer must ensure the ECU conditions are met when performing this service. Typical use cases are clearing nonvolatile memory, resetting learned values, setting option content, setting the Vehicle Identification Number, or changing calibration values.
Page 240
Chapter 6 Automotive Diagnostic Command Set API for C 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 function to obtain a descriptive string for the return value. ndStatusToString Description This VI performs the KWP2000 WriteDataByAddress service and writes RecordValues (data...
Page 242
Chapter 6 Automotive Diagnostic Command Set API for C Description This function clears the diagnostic information on the ECU memory. Depending on the value , the ECU is requested to clear the corresponding DTCs. The groupOfDTC groupOfDTC values are application specific. For further details about this service, refer to the ISO 15765-3 standard.
Page 244
Chapter 6 Automotive Diagnostic Command Set API for C 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 function to obtain a descriptive string for the return value. ndStatusToString Description This function executes the UDS CommunicationControl service and switches transmission...
Chapter 6 Automotive Diagnostic Command Set API for C ndUDSDiagnosticSessionControl Purpose Executes the UDS DiagnosticSessionControl service. The ECU is set up in a specific diagnostic mode. Format long ndUDSDiagnosticSessionControl( TD1 *diagRef, unsigned char mode, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed ndOpenDiagnostic to subsequent diagnostic functions.
Page 248
Chapter 6 Automotive Diagnostic Command Set API for C Description This function requests the ECU to perform an ECU reset effectively based on the mode parameter value content. The vehicle manufacturer determines when the positive response message is sent. Depending the value of , the corresponding ECU reset event is executed mode as a hard reset, key off/on reset, soft reset, or other reset.
Page 250
Chapter 6 Automotive Diagnostic Command Set API for C Output dataOut Returns application-specific data for this service. len2 On input, must contain the array length. On return, it contains the number len2 dataOut of valid data bytes in the array. dataOut success Indicates successful receipt of a positive response message for this diagnostic service.
Page 252
Chapter 6 Automotive Diagnostic Command Set API for C Description This function requests data record values from the ECU identified by the parameter. For further details about this service, refer to the ISO 15765-3 standard. Automotive Diagnostic Command Set User Manual 6-88 ni.com...
Page 254
Chapter 6 Automotive Diagnostic Command Set API for C 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.
Page 256
Chapter 6 Automotive Diagnostic Command Set API for C indicates the number of bytes the ECU sends for each DTC’s AddDataByteLength additional data. For this subfunction, the default is 2. indicates the byte ordering for multibyte items: ByteOrder 0: MSB_FIRST (Motorola), default 1: LSB_FIRST (Intel) This function interprets the response byte stream according to this description and returns the resulting DTC records in the...
Chapter 6 Automotive Diagnostic Command Set API for C ndUDSReportDTCByStatusMask Purpose Executes the ReportDTCByStatusMask subfunction of the UDS ReadDiagnosticTroubleCodeInformation service. Reads selected Diagnostic Trouble Codes (DTCs). Format long ndUDSReportDTCByStatusMask( TD1 *diagRef, unsigned char statusMask, TD3 *DTCDescriptor, unsigned char *statusAvailMask, TD4 DTCs[], long *len, LVBoolean *success);...
Page 260
Chapter 6 Automotive Diagnostic Command Set API for C 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.
Page 262
Chapter 6 Automotive Diagnostic Command Set API for C indicates the byte ordering for multibyte items: ByteOrder 0: MSB_FIRST (Motorola), default 1: LSB_FIRST (Intel) This function interprets the response byte stream according to this description and returns the resulting DTC records in the struct array.
Chapter 6 Automotive Diagnostic Command Set API for C ndUDSReportSupportedDTCs Purpose Executes the ReportSupportedDTCs subfunction of the UDS ReadDiagnosticTroubleCodeInformation service. Reads all supported Diagnostic Trouble Codes (DTCs). Format long ndUDSReportSupportedDTCs( TD1 *diagRef, TD3 *DTCDescriptor, unsigned char *statusAvailMask, TD4 DTCs[], long *len, LVBoolean *success);...
Page 266
Chapter 6 Automotive Diagnostic Command Set API for C 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.
Page 268
Chapter 6 Automotive Diagnostic Command Set API for C Description The usual procedure for getting a security access to the ECU is as follows: Request a seed from the ECU using with access mode = n. ndUDSRequestSeed From the seed, compute a key for the ECU on the host. Send the key to the ECU using with access mode = n + 1.
Page 270
Chapter 6 Automotive Diagnostic Command Set API for C Output dataOut Returns application-specific output parameters from the routine. len2 On input, must contain the array length. On return, it contains the number len2 dataOut of valid data bytes in the array.
Page 272
Chapter 6 Automotive Diagnostic Command Set API for C Description The usual procedure for getting a security access to the ECU is as follows: Request a seed from the ECU using with access mode = n. ndUDSRequestSeed From the seed, compute a key for the ECU on the host. Send the key to the ECU using with access mode = n + 1.
Page 274
Chapter 6 Automotive Diagnostic Command Set API for C The TesterPresent service is this “keep alive” signal. It does not affect any other ECU operation. Keep calling within the ECU timeout period if no other service is ndUDSTesterPresent executed. Automotive Diagnostic Command Set User Manual 6-110 ni.com...
Page 276
Chapter 6 Automotive Diagnostic Command Set API for C Description This function performs the UDS service WriteDataByIdentifier and writes RecordValues (data values) into the ECU. identifies the data. The vehicle manufacturer must ensure dataIn the ECU conditions are met when performing this service. Typical use cases are clearing nonvolatile memory, resetting learned values, setting option content, setting the Vehicle Identification Number, or changing calibration values.
Page 278
Chapter 6 Automotive Diagnostic Command Set API for C 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 function to obtain a descriptive string for the return value. ndStatusToString Description This function performs the UDS service WriteMemoryByAddress and writes RecordValues...
Chapter 6 Automotive Diagnostic Command Set API for C ndOBDRequestControlOfOnBoardDevice Purpose Executes the OBD Request Control Of On-Board Device service. Modifies ECU I/O port behavior. Format long ndOBDRequestControlOfOnBoardDevice( TD1 *diagRef, unsigned char TID, unsigned char dataIn[], long len, unsigned char dataOut[], long *len2, LVBoolean *success);...
Chapter 6 Automotive Diagnostic Command Set API for C ndOBDRequestCurrentPowertrainDiagnosticData Purpose Executes the OBD Request Current Powertrain Diagnostic Data service. Reads an ECU data record. Format long ndOBDRequestCurrentPowertrainDiagnosticData( TD1 *diagRef, unsigned char PID, unsigned char dataOut[], long *len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from...
Chapter 6 Automotive Diagnostic Command Set API for C ndOBDRequestEmissionRelatedDTCs Purpose Executes the OBD Request Emission Related DTCs service. Reads all emission-related Diagnostic Trouble Codes (DTCs). Format long ndOBDRequestEmissionRelatedDTCs( TD1 *diagRef, TD3 *DTCDescriptor, TD4 DTCs[], long *len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from and passed...
Chapter 6 Automotive Diagnostic Command Set API for C ndOBDRequestEmissionRelatedDTCsDuringCurrentDriveCycle Purpose Executes the OBD Request Emission Related DTCs During Current Drive Cycle service. Reads the emission-related Diagnostic Trouble Codes (DTCs) that occurred during the current (or last completed) drive cycle. Format long ndOBDRequestEmissionRelatedDTCsDuringCurrentDriveCycle( TD1 *diagRef,...
Chapter 6 Automotive Diagnostic Command Set API for C ndOBDRequestOnBoardMonitoringTestResults Purpose Executes the OBD Request On-Board Monitoring Test Results service. Reads an ECU test data record. Format long ndOBDRequestOnBoardMonitoringTestResults( TD1 *diagRef, unsigned char OBDMID, unsigned char dataOut[], long *len, LVBoolean *success); Input diagRef Specifies the diagnostic session handle, obtained from...
Chapter 6 Automotive Diagnostic Command Set API for C ndOBDRequestPowertrainFreezeFrameData Purpose Executes the OBD Request Powertrain Freeze Frame Data service. Reads an ECU data record stored while a diagnostic trouble code occurred. Format long ndOBDRequestPowertrainFreezeFrameData( TD1 *diagRef, unsigned char PID, unsigned char nFrame, unsigned char dataOut[], long *len,...
Chapter 6 Automotive Diagnostic Command Set API for C ndOBDRequestVehicleInformation Purpose Executes the OBD Request Vehicle Information service. Reads a set of information data from the ECU. Format long ndOBDRequestVehicleInformation( TD1 *diagRef, unsigned char infoType, unsigned char *nItems, unsigned char dataOut[], long *len, LVBoolean *success);...
Technical Support and Professional Services Visit the following sections of the National Instruments Web site at for technical support and professional services: ni.com • Support—Online technical support resources at ni.com/support include the following: – Self-Help Resources—For answers and solutions, visit the...