Pcan-Uds API Userman Eng
Pcan-Uds API Userman Eng
User Manual
PCAN® is a registered trademark of PEAK‐System Technik GmbH. All other product names mentioned in this document may be the
trademarks or registered trademarks of their respective companies. They are not explicitly marked by “™” or “®”.
www.peak‐system.com
info@peak‐system.com
Technical support:
E‐mail: support@peak‐system.com
Forum: www.peak‐system.com/forum/
2
PCAN-UDS API – User Manual
Contents
2 Introduction 8
2.1 Understanding PCAN-UDS 8
2.2 Using PCAN-UDS 8
2.3 Features 9
2.4 System Requirements 9
2.5 Scope of Supply 9
3
PCAN-UDS API – User Manual
3.5.26 TPUDSSvcParamRDTCI_DTCSVM 70
3.5.27 TPUDSSvcParamIOCBI 71
3.5.28 TPUDSSvcParamRC 72
3.5.29 TPUDSSvcParamRC_RID 73
3.6 Methods 74
3.6.1 Initialize 76
3.6.2 Initialize(TPUDSCANHandle, TPUDSBaudrate) 76
3.6.3 Initialize(TPUDSCANHandle, TPUDSBaudrate, TPUDSHWType, UInt32,
UInt16) 79
3.6.4 Uninitialize 82
3.6.5 SetValue 85
3.6.6 SetValue (TPUDSCANHandle, TPUDSParameter, UInt32, Uint32) 85
3.6.7 SetValue (TPUDSCANHandle, TPUDSParameter, StringBuffer,
Uint32) 88
3.6.8 SetValue (TPUDSANHandle, TPUDSParameter, Byte[], Uint32) 89
3.6.9 SetValue(TPUDSCANHandle, TPUDSParameter, IntPtr, UInt32) 91
3.6.10 GetValue 94
3.6.11 GetValue (TPUDSCANHandle, TPUDSParameter, StringBuffer,
Uint32) 94
3.6.12 GetValue (TPUDSCANHandle, TPUDSParameter, Uint32, Uint32) 97
3.6.13 GetValue (TPUDSCANHandle, TPUDSParameter, Byte[], UInt32) 100
3.6.14 GetValue(TPUDSCANHandle, TPUDSParameter, IntPtr, UInt32) 102
3.6.15 GetStatus 105
3.6.16 Read 108
3.6.17 Write 111
3.6.18 Reset 115
3.6.19 WaitForSingleMessage 117
3.6.20 WaitForMultipleMessage 121
3.6.21 WaitForService 127
3.6.22 WaitForServiceFunctional 130
3.6.23 ProcessResponse 134
3.6.24 SvcDiagnosticSessionControl 139
3.6.25 SvcECUReset 142
3.6.26 SvcSecurityAccess 146
3.6.27 SvcCommunicationControl 149
3.6.28 SvcTesterPresent 153
3.6.29 SvcSecuredDataTransmission 156
3.6.30 SvcControlDTCSetting 159
3.6.31 SvcResponseOnEvent 163
3.6.32 SvcLinkControl 167
3.6.33 SvcReadDataByIdentifier 171
3.6.34 SvcReadMemoryByAddress 174
3.6.35 SvcReadScalingDataByIdentifier 178
3.6.36 SvcReadDataByPeriodicIdentifier 181
3.6.37 SvcDynamicallyDefineDataIdentifierDBID 185
3.6.38 SvcDynamicallyDefineDataIdentifierDBMA 189
3.6.39 SvcDynamicallyDefineDataIdentifierCDDDI 194
3.6.40 SvcWriteDataByIdentifier 198
3.6.41 SvcWriteMemoryByAddress 201
3.6.42 SvcClearDiagnosticInformation 206
3.6.43 SvcReadDTCInformation 209
3.6.44 SvcReadDTCInformationRDTCSSBDTC 212
3.6.45 SvcReadDTCInformationRDTCSSBRN 216
4
PCAN-UDS API – User Manual
5
PCAN-UDS API – User Manual
6
PCAN-UDS API – User Manual
Welcome to the documentation of PCAN‐UDS API, a PEAK CAN API that implements ISO 14229‐1:2006, UDS in
CAN, an international standard that allows a diagnostic tester (client) to control diagnostic functions in an on‐
vehicle Electronic Control Unit (ECU or server).
In the following chapters you will find all the information needed to take advantage of this API.
Introduction on page 8
DLL API Reference on page 10
Additional Information on page 336
7
PCAN-UDS API – User Manual
2 Introduction
PCAN‐UDS is a simple programming interface intended to support windows automotive applications that use
PEAK‐Hardware to communicate with Electronic Control Units (ECU) connected to the bus systems of a car, for
maintenance purpose.
The UDS protocol is the result of 3 other standardized diagnostic communication protocols:
The idea of this protocol is to contact all electronic data units installed and
interconnected in a car, in order to provide maintenance, as checking for errors,
actualizing of firmware, etc.
Since the transport protocol of UDS is done using ISO‐TP, an international standard
for sending data packets over a CAN Bus, the maximum data length that can be
transmitted in a single data‐block is 4095 bytes.
Initialization: In order to do UDS on CAN communication using a channel, it is necessary to initialize it first. This
is done by making a call to the function UDS_Initialize (class‐method: Initialize).
8
PCAN-UDS API – User Manual
Interaction: After a successful initialization, a channel is ready to communicate with the connected CAN bus.
Further configuration is not needed. The 24 functions starting with UDS_Svc (class‐methods: starting with Svc)
can be used to transmit UDS requests and the utility functions starting with UDS_WaitFor (class‐methods:
starting with WaitFor) are used to retrieve the results of a previous request. The UDS_Read and UDS_Write
(class‐methods: Read and Write) are lower level functions to read and write UDS messages from scratch. If
desired, extra configuration can be made to improve a communication session, like service request timeouts or
ISO‐TP parameters.
Finalization: When the communication is finished, the function UDS_Uninitialize (class‐method: Uninitialize)
should be called in order to release the PUDS‐Channel and the resources allocated for it. In this way the
channel is marked as "Free" and can be used from other applications.
2.3 Features
Implementation of the UDS protocol (14229‐1:2006) for the communication with control units
Windows DLLs for the development of 32‐bit and 64‐bit applications
Physical communication via CAN using a CAN interface of the PCAN series
Uses the PCAN‐Basic programming interface to access the CAN hardware in the computer
Uses the PCAN‐ISO‐TP programming interface (ISO 15765‐2) for the transfer of data packages up to 4095
bytes via the CAN bus
9
PCAN-UDS API – User Manual
This section contains information about the data types (classes, structures, types, defines, enumerations) and
API functions which are contained in the PCAN‐UDS API.
3.1 Namespaces
PEAK offers the implementation of some specific programming interfaces as namespaces for the .NET
Framework programming environment. The following namespaces are available:
Namespaces
Name Description
{} Peak Contains all namespaces that are part of the managed programming environment from
PEAK‐System
{} Peak.Can Contains types and classes for using the PCAN API from PEAK‐System
{} Peak.Can.Light Contains types and classes for using the PCAN‐Light API from PEAK‐System
{} Peak.Can.Basic Contains types and classes for using the PCAN‐Basic API from PEAK‐System
{} Peak.Can.Ccp Contains types and classes for using the CCP API implementation from PEAK‐System
{} Peak.Can.Xcp Contains types and classes for using the XCP API implementation from PEAK‐System
{} Peak.Can.Iso.Tp Contains types and classes for using the PCAN‐ISO‐TP API implementation from PEAK‐
System
{} Peak.Can.Uds Contains types and classes for using the PCAN‐UDS API implementation from PEAK‐System
{} Peak.Can.ObdII Contains types and classes for using the PCAN‐OBDII API implementation from PEAK‐
System
{} Peak.Lin Contains types and classes used to handle with LIN devices from PEAK‐System
{} Peak.RP1210A Contains types and classes used to handle with CAN devices from PEAK‐System through the
TMC Recommended Practices 1210, version A, as known as RP1210(A)
3.1.1 Peak.Can.Uds
The Peak.Can.Uds namespace contains types and classes to use the PCAN‐UDS API within the .NET Framework
programming environment and handle PCAN devices from PEAK‐System.
Remarks: Under the Delphi environment, these elements are enclosed in the PUDS‐Unit. The functionality of all
elements included here is just the same. The difference between this namespace and the Delphi unit consists in
the fact that Delphi accesses the Windows API directly (it is not Managed Code).
Aliases
Alias Description
TPUDSCANHandle Represents a PCAN‐UDS channel handle
Classes
Class Description
UDSApi Defines a class which represents the PCAN‐UDS API
10
PCAN-UDS API – User Manual
Structures
Class Description
TPUDSMsg Defines a CAN UDS message. The members of this structure are sequentially byte aligned
Enumerations
Name Description
TPUDSBaudrate Represents a PCAN Baud rate register value
TPUDSHWType Represents the type of PCAN hardware to be initialized
TPUDSStatus Represents a PCAN‐UDS status/error code
TPUDSResult Represents the network status of a communicated PCAN‐UDS message
TPUDSParameter Represents a PCAN‐UDS parameter to be read or set
TPUDSService Represents a standardized UDS service
TPUDSAddress Represents a standardized ISO‐15765‐4 address
TPUDSCanId Represents a standardized ISO‐15765‐4 CAN identifier
TPUDSProtocol Represents a standardized and supported network communication protocol
TPUDSAddressingType Represents the type of message addressing of a PCAN‐UDS message
TPUDSMessageType Represents the type of a PCAN‐UDS message
TPUDSSvcParamDSC Represents the subfunction parameter for the UDS service
DiagnosticSessionControl
TPUDSSvcParamER Represents the subfunction parameter for the UDS service ECUReset
TPUDSSvcParamCC Represents the subfunction parameter for the UDS service CommunicationControl
TPUDSSvcParamTP Represents the subfunction parameter for the UDS service TesterPresent
TPUDSSvcParamCDTCS Represents the subfunction parameter for the UDS service ControlDTCSetting
TPUDSSvcParamROE Represents the subfunction parameter for the UDS service ResponseOnEvent
TPUDSSvcParamROERecom Represents the recommended service to respond to for the UDS service
mendedServiceID ResponseOnEvent
TPUDSSvcParamLC Represents the subfunction parameter for the UDS service LinkControl
TPUDSSvcParamLCBaudrat Represents the standard baudrate identifier for the UDS service LinkControl
eIdentifier
TPUDSSvcParamDI Represents the data identifiers parameter for the UDS services like
ReadDataByIdentifier
TPUDSSvcParamRDBPI Represents the subfunction parameter for the UDS service
ReadDataByPeriodicIdentifier
TPUDSSvcParamDDDI Represents the subfunction parameter for the UDS service
DynamicallyDefineDataIdentifier
TPUDSSvcParamRDTCI Represents the subfunction parameter for the UDS service ReadDTCInformation
TPUDSSvcParamRDTCI_DT Represents the DTC severity mask for the UDS service ReadDTCInformation
CSVM
TPUDSSvcParamIOCBI Represents the subfunction parameter for the UDS service
InputOutputControlByIdentifier
TPUDSSvcParamRC Represents the subfunction parameter for the UDS service RoutineControl
TPUDSSvcParamRC_RID Represents the routine identifier for the UDS service RoutineControl
11
PCAN-UDS API – User Manual
3.2 Units
PEAK offers the implementation of some specific programming interfaces as Units for the Delphi’s
programming environment. The following units are available to be used:
Namespaces
Alias Description
{} PUDS Unit Delphi unit for using the PCAN‐UDS API from PEAK‐System
Remarks: For the .NET Framework, these elements are enclosed in the Peak.Can.Uds namespace. The
functionality of all elements included here is just the same. The difference between this Unit and the .NET
namespace consists in the fact that Delphi accesses the Windows API directly (it is not Managed Code).
Aliases
Alias Description
TPUDSCanHandle Represents a PCAN‐UDS channel handle
Classes
Class Description
TUdsApi Defines a class which represents the PCAN‐ISO‐TP API
Structures
Class Description
TPUDSMsg Defines a CAN UDS message. The members of this structure are sequentially byte
aligned
TPUDSSessionInfo Defines a diagnostic session information of a serve
TPUDSNetAddrInfo Defines the Network Addressing Information of an UDS message
Enumerations
Name Description
TPUDSBaudrate Represents a PCAN Baud rate register value
TPUDSHWType Represents the type of PCAN hardware to be initialized
TPUDSStatus Represents a PCAN‐UDS status/error code
TPUDSResult Represents the network status of a communicated PCAN‐UDS message
TPUDSParameter Represents a PCAN‐UDS parameter to be read or set
TPUDSService Represents a standardized UDS service
TPUDSAddress Represents a standardized ISO‐15765‐4 address
TPUDSCanId Represents a standardized ISO‐15765‐4 CAN identifier
TPUDSProtocol Represents a standardized and supported network communication protocol
TPUDSAddressingType Represents the type of message addressing of a PCAN‐UDS message
TPUDSMessageType Represents the type of a PCAN‐UDS message
TPUDSSvcParamDSC Represents the subfunction parameter for the UDS service
DiagnosticSessionControl
12
PCAN-UDS API – User Manual
Name Description
TPUDSSvcParamER Represents the subfunction parameter for the UDS service ECUReset
TPUDSSvcParamCC Represents the subfunction parameter for the UDS service CommunicationControl
TPUDSSvcParamTP Represents the subfunction parameter for the UDS service TesterPresent
TPUDSSvcParamCDTCS Represents the subfunction parameter for the UDS service ControlDTCSetting
TPUDSSvcParamROE Represents the subfunction parameter for the UDS service ResponseOnEvent
TPUDSSvcParamROERecom Represents the recommended service to respond to for the UDS service
mendedServiceID ResponseOnEvent
TPUDSSvcParamLC Represents the subfunction parameter for the UDS service LinkControl
TPUDSSvcParamLCBaudrat Represents the standard baudrate identifier for the UDS service LinkControl
eIdentifier
TPUDSSvcParamDI Represents the data identifiers parameter for the UDS services like
ReadDataByIdentifier
TPUDSSvcParamRDBPI Represents the subfunction parameter for the UDS service
ReadDataByPeriodicIdentifier
TPUDSSvcParamDDDI Represents the subfunction parameter for the UDS service
DynamicallyDefineDataIdentifier
TPUDSSvcParamRDTCI Represents the subfunction parameter for the UDS service ReadDTCInformation
TPUDSSvcParamRDTCI_DT Represents the DTC severity mask for the UDS service ReadDTCInformation
CSVM
TPUDSSvcParamIOCBI Represents the subfunction parameter for the UDS service
InputOutputControlByIdentifier
TPUDSSvcParamRC Represents the subfunction parameter for the UDS service RoutineControl
TPUDSSvcParamRC_RID Represents the routine identifier for the UDS service RoutineControl
3.3 Classes
The following classes are offered to make use of the PCAN‐UDS API in a managed or unmanaged way.
Classes
Class Description
UDSApi Defines a class to use the PCAN‐UDS API within the Microsoft's .NET Framework
programming environment
TUdsApi Defines a class to use the PCAN‐UDS API within the Delphi programming environment
3.3.1 UDSApi
Defines a class which represents the PCAN‐UDS API to be used within the Microsoft's .NET Framework.
Syntax
C#
C++ / CLR
Visual Basic
13
PCAN-UDS API – User Manual
Remarks: The UDSApi class collects and implements the PCAN‐UDS API functions. Each method is called just
like the API function with the exception that the prefix "UDS_" is not used. The structure and functionality of
the methods and API functions are the same.
Within the .NET Framework from Microsoft, the UDSApi class is a static, not inheritable, class. It can (must)
directly be used, without any instance of it, e.g.:
TPUDSStatus res;
// Static use, without any instance
//
res = UDSApi.Initialize(UDSApi.PUDS_USBBUS1, TPUDSBaudrate.PUDS_BAUD_500K);
3.3.2 TUDSApi
Defines a class which represents the PCAN‐UDS API to be used within the Delphi programming environment.
Syntax
Pascal OO
TUdsApi = class
Remarks: TUdsApi is a class containing only class‐methods and constant members, allowing their use without
the creation of any object, just like a static class of another programming languages. It collects and implements
the PCAN‐UDS API functions. Each method is called just like the API function with the exception that the prefix
"UDS_" is not used. The structure and functionality of the methods and API functions are the same.
3.4 Structures
The PCAN‐UDS API defines the following structures:
Name Description
TPUDSMsg Defines a CAN UDS message. The members of this structure are
sequentially byte aligned
TPUDSSessionInfo Defines a diagnostic session information of a server.
TPUDSNetAddrInfo Defines the Network Addressing Information of a UDS message.
3.4.1 TPUDSMsg
Defines a CAN UDS message.
14
PCAN-UDS API – User Manual
Syntax
C++
#pragma pack(push, 8)
typedef struct tagTPUDSMsg
{
TPUDSNetAddrInfo NETADDRINFO;
BYTE RESULT;
BYTE NO_POSITIVE_RESPONSE_MSG;
WORD LEN;
TPUDSMessageType MSGTYPE;
union {
BYTE RAW[PUDS_MAX_DATA];
struct tagREQUEST
{
BYTE SI;
BYTE PARAM[PUDS_MAX_DATA-1];
} REQUEST;
struct tagPOSITIVE
{
BYTE SI;
BYTE PARAM[PUDS_MAX_DATA-1];
} POSITIVE;
struct tagNEGATIVE
{
BYTE NR_SI;
BYTE SI;
BYTE NRC;
} NEGATIVE;
} DATA;
} TPUDSMsg;
Pascal OO
{$A8}
TPUDSMsg = record
NETADDRINFO: TPUDSNetAddrInfo;
RESULT: TPUDSResult;
NO_POSITIVE_RESPONSE_MSG: Byte;
LEN: Word;
MSGTYPE: TPUDSMessageType;
DATA: array[0..4095] of Byte;
end;
PTPUDSMsg = ^TPUDSMsg;
C#
15
PCAN-UDS API – User Manual
C++ / CLR
Byte NO_POSITIVE_RESPONSE_MSG;
unsigned short LEN;
[MarshalAs(UnmanagedType::U1)]
TPUDSMessageType MSGTYPE;
[MarshalAs(UnmanagedType::ByValArray, SizeConst = 4095)]
array<Byte>^ DATA;
16
PCAN-UDS API – User Manual
Visual Basic
<StructLayout(LayoutKind.Sequential, Pack:=8)>
Public Structure TPUDSMsg
Public NETADDRINFO As TPUDSNetAddrInfo
<MarshalAs(UnmanagedType.U1)> _
Public RESULT As TPUDSResult
Public NO_POSITIVE_RESPONSE_MSG As Byte
Public LEN As UShort
<MarshalAs(UnmanagedType.U1)> _
Public MSGTYPE As TPUDSMessageType
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=4095)> _
Public DATA As Byte()
17
PCAN-UDS API – User Manual
Fields
Name Description
NETADDRINFO Network Addressing Information
RESULT Result status of the network communication (see TPUDSResult)
NO_POSITIVE_RESPONSE_MSG States wether Positive Response Message should be ignored upon
reception (see also TPUDSMsg Member Value Definitions)
LEN Data Length of the message.
MSGTYPE Type of UDS Message (see TPUDSMessageType)
DATA Represents the buffer containing the data of this message
Remarks: .NET framework provides three properties to ease UDS message data queries:
See also: TPUDSMsg Member Value Definitions on page 333, TPUDSMessageType on page 50, TPUDSResult on
page 30.
3.4.2 TPUDSSessionInfo
Defines a UDS Session Information.
Syntax
C++
#pragma pack(push, 8)
typedef struct tagTPUDSSessionInfo
{
TPUDSNetAddrInfo NETADDRINFO;
BYTE SESSION_TYPE;
WORD TIMEOUT_P2CAN_SERVER_MAX;
WORD TIMEOUT_ENHANCED_P2CAN_SERVER_MAX;
} TPUDSSessionInfo;
Pascal OO
{$A8}
TPUDSSessionInfo = record
NETADDRINFO: TPUDSNetAddrInfo;
SESSION_TYPE: Byte;
TIMEOUT_P2CAN_SERVER_MAX: Word;
TIMEOUT_ENHANCED_P2CAN_SERVER_MAX: Word;
end;
18
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<StructLayout(LayoutKind.Sequential, Pack:=8)>
Public Structure TPUDSSessionInfo
Public NETADDRINFO As TPUDSNetAddrInfo
Public SESSION_TYPE As Byte
Public TIMEOUT_P2CAN_SERVER_MAX As UShort
Public TIMEOUT_ENHANCED_P2CAN_SERVER_MAX As UShort
End Structure
Fields
Name Description
NETADDRINFO Network Addressing Information (see TPUDSNetAddrInfo)
RESULT Currently activated Diagnostic Session
TIMEOUT_P2CAN_SERVER_MAX Default P2Can_Server_Max timing for the activated session (i.e.
maximum time allowed for an ECU to transmit a response indication)
TIMEOUT_ENHANCED_P2CAN_SERVER_MAX Enhanced P2Can_Server_Max timing for the activated session (i.e.
maximum time allowed for an ECU to transmit a response indication after
having sent a negative response code stating that more time is required:
PUDS_NRC_EXTENDED_TIMING, 0x78)
3.4.3 TPUDSNetAddrInfo
Defines the Network Address Information of a UDS message.
Syntax
C++
#pragma pack(push, 8)
typedef struct tagTPUDSNetAddrInfo
{
BYTE SA;
19
PCAN-UDS API – User Manual
BYTE TA;
TPUDSAddressingType TA_TYPE;
BYTE RA;
TPUDSProtocol PROTOCOL;
} TPUDSNetAddrInfo;
#pragma pack(pop)
Pascal OO
{$A8}
TPUDSNetAddrInfo = record
SA: Byte;
TA: Byte;
TA_TYPE: TPUDSAddressingType;
RA: Byte;
PROTOCOL: TPUDSProtocol;
end;
C#
C++ / CLR
Visual Basic
<StructLayout(LayoutKind.Sequential, Pack:=8)>
Public Structure TPUDSNetAddrInfo
Public SA As Byte
Public TA As Byte
<MarshalAs(UnmanagedType.U1)> _
Public TA_TYPE As TPUDSAddressingType
Public RA As Byte
<MarshalAs(UnmanagedType.U1)> _
Public PROTOCOL As TPUDSProtocol
End Structure
20
PCAN-UDS API – User Manual
Fields
Name Description
SA Represents the Source Address (see TPUDSAddress)
TA Represents the Target Address (see TPUDSAddress)
TA_TYPE Represents the Target Address Type (see TPUDSAddressingType)
RA Represents the Remote Address (see TPUDSAddress)
PROTOCOL Represents the protocol being used for communication (see
TPUDSProtocol)
SA Represents the Source Address (see TPUDSAddress)
See also: TPUDSAddress on page 43, TPUDSAddressingType on page 49, TPUDSProtocol on page 47.
3.5 Types
The PCAN‐ISO‐TP API defines the following types:
Name Description
TPUDSCANHandle Represents a PCAN‐UDS channel handle
TPUDSBaudrate Represents a PCAN Baud rate register value
TPUDSHWType Represents the type of PCAN hardware to be initialized
TPUDSStatus Represents a PCAN‐UDS status/error code
TPUDSResult Represents the network status of a communicated PCAN‐UDS message
TPUDSParameter Represents a PCAN‐UDS parameter to be read or set
TPUDSService Represents a standardized UDS service
TPUDSAddress Represents a standardized ISO‐15765‐4 address
TPUDSCanId Represents a standardized ISO‐15765‐4 CAN identifier
TPUDSProtocol Represents a standardized and supported network communication
protocol
TPUDSAddressingType Represents the type of message addressing of a PCAN‐UDS message
TPUDSMessageType Represents the type of a PCAN‐UDS message
TPUDSSvcParamDSC Represents the subfunction parameter for the UDS service
DiagnosticSessionControl
TPUDSSvcParamER Represents the subfunction parameter for the UDS service ECUReset
TPUDSSvcParamCC Represents the subfunction parameter for the UDS service
CommunicationControl
TPUDSSvcParamTP Represents the subfunction parameter for the UDS service TesterPresent
TPUDSSvcParamCDTCS Represents the subfunction parameter for the UDS service
ControlDTCSetting
TPUDSSvcParamROE Represents the subfunction parameter for the UDS service
ResponseOnEvent
TPUDSSvcParamROEReco Represents the recommended service to respond to for the UDS service
mmendedServiceID ResponseOnEvent
TPUDSSvcParamLC Represents the subfunction parameter for the UDS service LinkControl
TPUDSSvcParamLCBaudr Represents the standard baudrate identifier for the UDS service
ateIdentifier LinkControl
TPUDSSvcParamDI Represents the data identifiers parameter for the UDS services like
ReadDataByIdentifier
TPUDSSvcParamRDBPI Represents the subfunction parameter for the UDS service
ReadDataByPeriodicIdentifier
21
PCAN-UDS API – User Manual
Name Description
TPUDSSvcParamDDDI Represents the subfunction parameter for the UDS service
DynamicallyDefineDataIdentifier
TPUDSSvcParamRDTCI Represents the subfunction parameter for the UDS service
ReadDTCInformation
TPUDSSvcParamRDTCI_D Represents the DTC severity mask for the UDS service
TCSVM ReadDTCInformation
TPUDSSvcParamIOCBI Represents the subfunction parameter for the UDS service
InputOutputControlByIdentifier
TPUDSSvcParamRC Represents the subfunction parameter for the UDS service
RoutineControl
TPUDSSvcParamRC_RID Represents the routine identifier for the UDS service RoutineControl
3.5.1 TPUDSCANHandle
Represents a PCAN‐UDS channel handle.
Syntax
C++ Syntax
C++ / CLR
C# Syntax
Remarks: TPUDSCANHandle is defined for the PCAN‐UDS API but it is identical to a TPCANTPCANHandle from
PCAN‐ISO‐TP API or TPCANHandle from PCAN‐Basic API.
Aliases are defined in the Peak.Can.Uds Namespace for C# and VB .NET. However, including a namespace does
not include the defined aliases.
If it is wished to work with aliases, those must be copied to the working file, right after the inclusion of the
Peak.Can.Uds Namespace. Otherwise, just use the native type, which in this case is a Byte.
C#
using System;
using Peak.Can.UDS;
using TPUDSCANHandle = System.Int16; // Alias's declaration for System.Byte
22
PCAN-UDS API – User Manual
Visual Basic
Imports System
Imports Peak.Can.Uds
Imports TPUDSCANHandle = System.Int16 'Alias' declaration for System.Byte
3.5.2 TPUDSStatus
Represents a PUDS status/error code. According with the programming language, this type can be a group of
defined values or an enumeration.
Syntax
C++ Syntax
C++ / CLR
C# Snytax
23
PCAN-UDS API – User Manual
PUDS_ERROR_NOT_INITIALIZED = 0x00001,
PUDS_ERROR_ALREADY_INITIALIZED = 0x00002,
PUDS_ERROR_NO_MEMORY = 0x00003,
PUDS_ERROR_OVERFLOW = 0x00004,
PUDS_ERROR_TIMEOUT = 0x00006,
PUDS_ERROR_NO_MESSAGE = 0x00007,
PUDS_ERROR_WRONG_PARAM = 0x00008,
PUDS_ERROR_BUSLIGHT = 0x00009,
PUDS_ERROR_BUSHEAVY = 0x0000A,
PUDS_ERROR_BUSOFF = 0x0000B,
PUDS_ERROR_CAN_ERROR = 0x80000000,
};
Pascal OO
TPUDSStatus = (
PUDS_ERROR_OK = $00000
PUDS_ERROR_NOT_INITIALIZED = $00001
PUDS_ERROR_ALREADY_INITIALIZED = $00002
PUDS_ERROR_NO_MEMORY = $00003
PUDS_ERROR_OVERFLOW = $00004
PUDS_ERROR_TIMEOUT = $00006
PUDS_ERROR_NO_MESSAGE = $00007
PUDS_ERROR_WRONG_PARAM = $00008
PUDS_ERROR_BUSLIGHT = $00009
PUDS_ERROR_BUSHEAVY = $0000A
PUDS_ERROR_BUSOFF = $0000B
PUDS_ERROR_CAN_ERROR = LongWord($80000000)
);
Remarks: The PUDS_ERROR_CAN_ERROR status is a generic error code that is used to identify PCAN‐Basic
errors (as PCAN‐Basic API is used internally by the PCAN‐UDS API). When a PCAN‐Basic error occurs, the API
performs a bitwise combination of the PUDS_ERROR_CAN_ERROR and the PCAN‐Basic (TPCANStatus) error.
24
PCAN-UDS API – User Manual
WaitForService function may return exactly PUDS_ERROR_CAN_ERROR, in this specific case the PCAN‐Basic
status states no error meaning that the error occurred in the ISO‐TP layer. The network status result of the UDS
message will provide extra information.
Values
Name Value Description
PUDS_ERROR_OK 0x00000 (000000) No error. Success
PUDS_ERROR_NOT_INITIALIZED 0x00001 (000001) Not initialized
PUDS_ERROR_ALREADY_INITIALIZED 0x00002 (000002) Already initialized
PUDS_ERROR_NO_MEMORY 0x00003 (000003) Failed to allocate memory
PUDS_ERROR_OVERFLOW 0x00004 (000004) Buffer overflow occurred (too many channels initialized or too many
messages in queue)
PUDS_ERROR_TIMEOUT 0x00006 (000006) Timeout while trying to access the PCAN‐UDS API
PUDS_ERROR_NO_MESSAGE 0x00007 (000007) No message available
PUDS_ERROR_WRONG_PARAM 0x00008 (000008) Invalid parameter
PUDS_ERROR_BUSLIGHT 0x00009 (000009) Bus error: an error counter reached the 'light' limit
PUDS_ERROR_BUSHEAVY 0x0000A (000010) Bus error: an error counter reached the 'heavy' limit
PUDS_ERROR_BUSOFF 0x0000B (000011) Bus error: the CAN controller is in bus‐off state
PUDS_ERROR_CAN_ERROR 0x80000000 PCAN‐Basic error flag (remove the flag to get a TPCANStatus error code)
(2147483648)
3.5.3 TPUDSBaudrate
Represents a PCAN Baud rate register value. According with the programming language, this type can be a
group of defined values or an enumeration.
Syntax
C++
Pascal OO
{$Z2}
TPUDSBaudrate = (
PUDS_BAUD_1M = $0014,
25
PCAN-UDS API – User Manual
PUDS_BAUD_800K = $0016,
PUDS_BAUD_500K = $001C,
PUDS_BAUD_250K = $011C,
PUDS_BAUD_125K = $031C,
PUDS_BAUD_100K = $432F,
PUDS_BAUD_95K = $C34E,
PUDS_BAUD_83K = $852B,
PUDS_BAUD_50K = $472F,
PUDS_BAUD_47K = $1414,
PUDS_BAUD_33K = $8B2F,
PUDS_BAUD_20K = $532F,
PUDS_BAUD_10K = $672F,
PUDS_BAUD_5K = $7F7F
);
C#
26
PCAN-UDS API – User Manual
C++ / CLR
Visual Basic
27
PCAN-UDS API – User Manual
Values
Name Value Description
PUDS_BAUD_1M 20 1 MBit/s
PUDS_BAUD_800K 22 800 kBit/s
PUDS_BAUD_500K 28 500 kBit/s
PUDS_BAUD_250K 284 250 kBit/s
PUDS_BAUD_125K 796 125 kBit/s
PUDS_BAUD_100K 17199 100 kBit/s
PUDS_BAUD_95K 49998 95,238 kBit/s
PUDS_BAUD_83K 34091 83,333 kBit/s
PUDS_BAUD_50K 18223 50 kBit/s
PUDS_BAUD_47K 5140 47,619 kBit/s
PUDS_BAUD_33K 35631 33,333 kBit/s
PUDS_BAUD_20K 21295 20 kBit/s
PUDS_BAUD_10K 26415 10 kBit/s
PUDS_BAUD_5K 32639 5 kBit/s
3.5.4 TPUDSHWType
Represents the type of PCAN (not plug & play) hardware to be initialized. According with the programming
language, this type can be a group of defined values or an enumeration.
Syntax
C++
Pascal OO
{$Z1}
TPUDSHWType = (
PUDS_TYPE_ISA = $01,
PUDS_TYPE_ISA_SJA = $09,
PUDS_TYPE_ISA_PHYTEC = $04,
PUDS_TYPE_DNG = $02,
PUDS_TYPE_DNG_EPP = $03,
PUDS_TYPE_DNG_SJA = $05,
PUDS_TYPE_DNG_SJA_EPP = $06
);
28
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_TYPE_ISA 1 PCAN‐ISA 82C200
PUDS_TYPE_ISA_SJA 9 PCAN‐ISA SJA1000
PUDS_TYPE_ISA_PHYTEC 4 PHYTEC ISA
PUDS_TYPE_DNG 2 PCAN‐Dongle 82C200
PUDS_TYPE_DNG_EPP 3 PCAN‐Dongle EPP 82C200
PUDS_TYPE_DNG_SJA 5 PCAN‐Dongle SJA1000
PUDS_TYPE_DNG_SJA_EPP 6 PCAN‐Dongle EPP SJA1000
29
PCAN-UDS API – User Manual
3.5.5 TPUDSResult
Represents the network status of a communicated UDS message (as returned by the ISO‐TP layer).
Syntax
C++
Pascal OO
{$Z1}
TPUDSResult = (
PUDS_RESULT_N_OK = $00,
PUDS_RESULT_N_TIMEOUT_A = $01,
PUDS_RESULT_N_TIMEOUT_BS = $02,
PUDS_RESULT_N_TIMEOUT_CR = $03,
PUDS_RESULT_N_WRONG_SN = $04,
PUDS_RESULT_N_INVALID_FS = $05,
PUDS_RESULT_N_UNEXP_PDU = $06,
PUDS_RESULT_N_WFT_OVRN = $07,
PUDS_RESULT_N_BUFFER_OVFLW = $08,
PUDS_RESULT_N_ERROR = $09
);
C#
C++ / CLR
30
PCAN-UDS API – User Manual
PUDS_RESULT_N_UNEXP_PDU = 0x06,
PUDS_RESULT_N_WFT_OVRN = 0x07,
PUDS_RESULT_N_BUFFER_OVFLW = 0x08,
PUDS_RESULT_N_ERROR = 0x09,
};
Visual Basic
Values
Name Value Description
PUDS_RESULT_N_OK 0 No network error
PUDS_RESULT_N_TIMEOUT_A 1 Timeout occured between 2 frames transmission (sender and receiver
side)
PUDS_RESULT_N_TIMEOUT_Bs 2 Sender side timeout while waiting for flow control frame
PUDS_RESULT_N_TIMEOUT_Cr 3 Receiver side timeout while waiting for consecutive frame
PUDS_RESULT_N_WRONG_SN 4 Unexpected sequence number
PUDS_RESULT_N_INVALID_FS 5 Invalid or unknown FlowStatus
PUDS_RESULT_N_UNEXP_PDU 6 Unexpected protocol data unit
PUDS_RESULT_N_WFT_OVRN 7 Reception of flow control WAIT frame that exceeds the maximum
counter defined by PUDS_PARAM_WFT_MAX
PUDS_RESULT_N_BUFFER_OVFLW 8 Buffer on the receiver side cannot store the data length (server side
only)
PUDS_RESULT_N_ERROR 9 General error
3.5.6 TPUDSParameter
Represents a PCAN‐UDS parameter or a PCAN‐UDS Value that can be read or set. According with the
programming language, this type can be a group of defined values or an enumeration. With some exceptions, a
channel must first be initialized before their parameters can be read or set.
Syntax
C++
31
PCAN-UDS API – User Manual
Pascal OO
TPUDSParameter = (
PUDS_PARAM_SERVER_ADDRESS = $C1,
PUDS_PARAM_SERVER_FILTER = $C2,
PUDS_PARAM_TIMEOUT_REQUEST = $C3,
PUDS_PARAM_TIMEOUT_RESPONSE = $C4,
PUDS_PARAM_SESSION_INFO = $C5,
PUDS_PARAM_API_VERSION = $C6,
PUDS_PARAM_RECEIVE_EVENT = $C7,
PUDS_PARAM_MAPPING_ADD = $C8,
PUDS_PARAM_MAPPING_REMOVE = $C9,
PUDS_PARAM_BLOCK_SIZE = $E1,
PUDS_PARAM_SEPERATION_TIME = $E2,
PUDS_PARAM_DEBUG = $E3,
PUDS_PARAM_CHANNEL_CONDITION = $E4,
PUDS_PARAM_WFT_MAX = $E5,
PUDS_PARAM_CAN_DATA_PADDING = $E8
PUDS_PARAM_PADDING_VALUE = $ED
);
C#
C++ / CLR
32
PCAN-UDS API – User Manual
PUDS_PARAM_TIMEOUT_REQUEST = 0xC3,
PUDS_PARAM_TIMEOUT_RESPONSE = 0xC4,
PUDS_PARAM_SESSION_INFO = 0xC5,
PUDS_PARAM_API_VERSION = 0xC6,
PUDS_PARAM_RECEIVE_EVENT = 0xC7,
PUDS_PARAM_MAPPING_ADD = 0xC8,
PUDS_PARAM_MAPPING_REMOVE = 0xC9,
PUDS_PARAM_BLOCK_SIZE = 0xE1,
PUDS_PARAM_SEPERATION_TIME = 0xE2,
PUDS_PARAM_DEBUG = 0xE3,
PUDS_PARAM_CHANNEL_CONDITION = 0xE4,
PUDS_PARAM_WFT_MAX = 0xE5,
PUDS_PARAM_CAN_DATA_PADDING = 0xE8,
};
Visual Basic
Values
Name Value Data type Description
PUDS_PARAM_SERVER_ADDRESS 0xC1 (193) WORD (2 Bytes) Physical address of the server (or ECU)
PUDS_PARAM_SERVER_FILTER 0xC2 (194) WORD (2 Bytes) Filter for functional addresses
PUDS_PARAM_TIMEOUT_REQUEST 0xC3 (195) DWORD (4 Bytes) Maximum time allowed by the client to transmit
a request
PUDS_PARAM_TIMEOUT_RESPONSE 0xC4 (196) DWORD (4 Bytes) Maximum time allowed by the client to receive a
response
PUDS_PARAM_SESSION_INFO 0xC5 (197) TPUDSSessionInfo UDS current diagnostic session information
PUDS_PARAM_API_VERSION 0xC6 (198) String API version of the PCAN‐UDS API
PUDS_PARAM_RECEIVE_EVENT 0xC7 (199) String Define UDS receive‐event handler, require a
pointer to an event HANDLE
PUDS_PARAM_MAPPING_ADD 0xC8 (200) TPUDSMessage Defines a new ISO‐TP mapping
PUDS_PARAM_MAPPING_REMOVE 0xC9 (201) TPUDSMessage Removes an ISO‐TP mapping
PUDS_PARAM_BLOCK_SIZE 0xE1 (225) Byte ISO‐TP "BlockSize" (BS) parameter
PUDS_PARAM_SEPERATION_TIME 0xE2 (226) Byte ISO‐TP "SeparationTime" (STmin) parameter
PUDS_PARAM_DEBUG 0xE3 (227) Byte Debug mode
PUDS_PARAM_CHANNEL_CONDITION 0xE4 (228) Byte PCAN‐UDS channel condition
PUDS_PARAM_WFT_MAX 0xE5 (229) Integer ISO‐TP "N_WFTmax" parameter
PUDS_PARAM_CAN_DATA_PADDING 0xE8 (232) Byte ISO‐TP CAN frame data handling mode
33
PCAN-UDS API – User Manual
Characteristics
PUDS_PARAM_SERVER_ADDRESS
Access:
Description: This value is used to define the address of the client/server. Defining this parameter is required as
it allows configuration of the underlying ISO‐TP API. By default the address is set to the standard address of
external test equipment (0xF1). Although most UDS addresses are 1 byte data, the parameter requires a 2
bytes value in order to be compatible with ISO 14229‐1:2006 addresses
(see PUDS_SERVER_ADDR_MASK_ENHANCED_ISO_15765_3, 0x7FF). To define an ISO 14229‐1:2006 address,
add the flag PUDS_SERVER_ADDR_FLAG_ENHANCED_ISO_15765_3 (0x1000) to the address (using a bitwise OR
operation, i.e.: (PUDS_SERVER_ADDR_FLAG_ENHANCED_ISO_15765_3 | 0x123).
Possible Values: 0x00 to 0xFF, or 0x1000 to 0x17FF for enhanced ISO 14229‐1:2006 addresses.
PUDS_PARAM_SERVER_Filter
Access:
Description: This parameter allows to add or remove addresses to the filter list. By default, the filter list denies
every communication except the one with the server address. To add another address to the filter list (like a
functional address the server should respond to), add the flag PUDS_SERVER_FILTER_LISTEN (0x8000) to
the wanted address (using a bitwise OR operation). To remove a previously set address, use the flag
PUDS_SERVER_FILTER_IGNORE (0x0000) with the same address.
Possible Values: 0x00 to 0xFF (or 0x7FF for enhanced ISO 14229‐1:2006 addresses) in conjunction with the
flags PUDS_SERVER_FILTER_LISTEN or PUDS_SERVER_FILTER_IGNORE. Example: to allow the address 0x11 use
the value (PUDS_SERVER_FILTER_LISTEN | 0x11), to remove it use (PUDS_SERVER_FILTER_IGNORE | 0x11).
PUDS_PARAM_TIMEOUT_REQUEST
Access:
Description: This value defines the maximum waiting time to receive a confirmation of a transmission. It is
used in UDS utility functions like UDS_WaitForService.
34
PCAN-UDS API – User Manual
PUDS_PARAM_TIMEOUT_RESPONSE
Access:
Description: This value defines the maximum waiting time to receive a response indication. Note that the exact
timeout value is the sum of this parameter and the timeout defined in the active diagnostic session. It is used in
UDS utility functions like UDS_WaitForService.
PUDS_PARAM_SESSION_INFO
Access:
Description: This parameter is used to read or override the current diagnostic session. The diagnostic session
information is a value which is internally updated when the UDS service UDS_SvcDiagnosticSessionControl is
invoked: it keeps track of the active session and its associated timeouts. If a non‐default diagnostic session is
active, a keep‐alive mechanism (using physically addressed TesterPresent service requests with the “suppress
positive response message” flag) is automatically activated according to UDS standard. If a user wants to
deactivate this mechanism, he/she will have to get the current session information of the client and change the
session type to PUDS_SVC_PARAM_DSC_DS (the default diagnostic session). Be careful that this change will
only affect the client side and the ECU will not be aware of it, moreover the client will have to keep alive the
active session by its own. The user can also define a different session with custom networking parameters, for
instance setting back a non‐default session and providing a NETADDRINFO parameter with functional
addressing will send functionally addressed TesterPresent requests.
Default Value: automatically updated when the response of the service UDS_SvcDiagnosticSessionControl is
processed (with the UDS_ProcessResponse function or higher‐level functions: UDS_WaitForMultipleMessage,
UDS_WaitForService and UDS_WaitForServiceFunctional).
PUDS_PARAM_API_Version
Access:
Description: This parameter is used to get information about the PCAN‐UDS API implementation version.
Possible Values: The value is a null‐terminated string indication the version number of the API
implementation. The returned text has the following form: x,x,x,x for major, minor, release and build. It
represents the binary version of the API, within two 32‐bit integers, defined by four 16‐bit integers. The length
of this text value will have a maximum length of 24 bytes, 5 bytes for represent each 16‐bit value, three
separator characters ( , or . ) and the null‐termination.
PCAN-Device: NA. Any PCAN device can be used, including the PUDS_NONEBUS channel.
35
PCAN-UDS API – User Manual
PUDS_PARAM_RECEIVE_EVENT
Access:
Description: This parameter is used to let the PCAN‐UDS API notify an application when UDS messages are
available to be read. In this form, message processing tasks of an application can react faster and make a more
efficient use of the processor time.
Possible Values: This value has to be a handle for an event object returned by the Windows API function
CreateEvent or the value 0 (IntPtr.Zero in a managed environment). When setting this parameter, the value of
0 resets the parameter in the PCAN‐ISO‐TP API. Reading a value of 0 indicates that no event handle is set. For
more information about reading with events, please refer to the topic Using Events.
Note: .NET environment should use the prototype SetValue with a NumericBuffer, as in the following C#
example:
PUDS_PARAM_MAPPING_ADD
Access:
Description: This parameter is used to configure a mapping to the underlying PCAN‐ISO‐TP API. This allows a
user to map a custom Network Address Information to a CAN Identifier, thus allowing to communicate with
non standard UDS requests or responses.
Possible Values: This value has to be a pointer to a valid TPUDSMsg structure where its network address
information (NETADDRINFO) is fully defined. Furthermore, the data of the message shall contain the following
information:
If the mapping concerns an Unacknowledge Segmented Data Transfert (USDT), the length of the message
must be 8 and DATA.RAW[0..3] will hold the mapped CAN ID and DATA.RAW[4..7] will hold the mapped
CAN ID for the ISO‐TP automatic responses. For instance, in OBD the tester present receives messages from
ECU#1 with CAN ID 0x7E8 and responds with 0x7E0 (ex: DATA.RAW[0..7] = 00 00 07 E8 00 00 07 E0). With
functionally addressed messages there are no internal ISO‐TP responses, so the CAN ID response field
should be set to ‐1 (0xFFFFFFFF).
If the mapping concerns an Unacknowledge Unsegmented Data Transfert (UUDT), the length of the
message must be 4 and DATA.RAW[0..3] will hold the mapped CAN ID. For instance, a tester present can
receive UUDT with CAN ID 0x6E8 messages after requesting the readDataByPeriodicDataIdentifier from
ECU#1(ex: DATA.RAW[0..3] = 00 00 06 E8).
For a complete example, check §4.3.3 PCAN‐UDS Example C:\Users\Christoph\Documents\Doku
2019\PCAN‐UDS‐API\Phase 2\PCAN‐UDS‐API_UserMan_eng.doc ‐ _PCAN‐UDS_example#_PCAN‐
UDS_example on page 343.
Note: If an UUDT mapping is added, PCAN‐ISO‐TP will automatically set its configuration to allow the
reception of non‐ISO‐TP messages (i.e. standard CAN ID).
36
PCAN-UDS API – User Manual
PUDS_PARAM_MAPPING_REMOVE
Access:
Description: This parameter is used to remove a previously defined mapping from the underlying PCAN‐ISO‐TP
API.
Possible Values: This value has to be a pointer to a valid TPUDSMsg structure where the network address
information (NETADDRINFO) has at least the PROTOCOL information defined and the data of the message shall
contain the following information the CAN ID of the mapping. That is DATA.RAW[0..3] will hold the previously
mapped CAN ID (ex: DATA.RAW[0..3] = 00 00 06 E8).
Note that if the last UUDT mapping is added, PCAN‐ISO‐TP will automatically set its configuration to disable
reception of non ISO‐TP message (i.e. standard CAN ID).
PUDS_PARAM_BLOCK_SIZE
Access:
Description: This value is used to set the BlockSize (BS) parameter defined in the ISO‐TP standard: it indicates
to the sender the maximum number of consecutive frames that can be received without an intermediate
FlowControl frame from the receiving network entity. A value of 0 indicates that no limit is set and the sending
network layer entity shall send all remaining consecutive frames.
PUDS_PARAM_SEPARATION_TIME
Access:
Description: This value is used to set the SeparationTime (STmin) parameter defined in the ISO‐TP standard: it
indicates the minimum time the sender is to wait between the transmissions of two Consecutive Frames.
Possible Values: 0x00 (unlimited) to 0x7F (range from 0ms to 127ms). Note: as set in ISO‐TP standard, values
from 0xF1 to 0xF9 should define a range from 100µs to 900µs, but due to system time resolution limitation
those value are defaulted to 1ms. Other values are ISO reserved.
37
PCAN-UDS API – User Manual
PUDS_PARAM_DEBUG
Access:
Description: This parameter is used to control debug mode. If enabled, any received or transmitted CAN
frames will be printed to the standard output.
Possible Values: PUDS_DEBUG_NONE disables debug mode and PUDS_DEBUG_CAN enables it.
PUDS_PARAM_CHANNEL_CONDITION
Access:
Description: This parameter is used to check and detect available PCAN hardware on a computer, even before
trying to connect any of them. This is useful when an application wants the user to select which hardware
should be using in a communication session.
Possible Values: This parameter can have one of these values: PUDS_CHANNEL_UNAVAILABLE,
PUDS_CHANNEL_AVAILABLE and PUDS_CHANNEL_OCCUPIED.
Note: It is not needed to have a PCAN channel initialized before asking for its condition.
PUDS_PARAM_WFT_MAX
Access:
Description: This parameter is used to set the maximum number of “FlowControl.Wait” frame transmission
parameter (N_WFTmax) defined in the ISO‐TP standard: it indicates how many FlowControl frames with the
Wait status can be transmitted by a receiver in a row.
PCAN-Device: Any PCAN device can be used, including the PUDS_NONEBUS channel.
Note: also this parameter is set globally, channels will use the value set when they are initialized, so it is
possible to define different values of N_WFTmax on separate channels. Consequently, once a channel is
initialized, changing the WFTmax parameter will not affect that channel.
PUDS_PARAM_CAN_DATA_PADDING
Access:
Description: This parameter is used to define if the API should uses CAN data optimization or CAN data
padding: the first case will optimize the CAN DLC to avoid sending unnecessary data, on the other hand with
CAN data padding the API will always send CAN frames with a DLC of 8 and pads the data with zeroes.
38
PCAN-UDS API – User Manual
Possible Values: PUDS_CAN_DATA_PADDING_NONE disables data padding (enabling CAN data optimization)
and PUDS_CAN_DATA_PADDING_ON enables data padding.
Default Value: PUDS_CAN_DATA_PADDING_ON since ECUs that do not support CAN data optimization may
not respond to UDS/CAN‐TP messages.
PUDS_PARAM_PADDING_VALUE
Access:
Description: This parameter is used to define the value for CAN data padding when it is enabled.
3.5.7 TPUDSService
Represents a UDS on CAN service identifier.
Syntax
C++
39
PCAN-UDS API – User Manual
Pascal OO
TPUDSService = (
PUDS_SI_DiagnosticSessionControl = $10,
PUDS_SI_ECUReset = $11,
PUDS_SI_SecurityAccess = $27,
PUDS_SI_CommunicationControl = $28,
PUDS_SI_TesterPresent = $3E,
PUDS_SI_AccessTimingParameter = $83,
PUDS_SI_SecuredDataTransmission = $84,
PUDS_SI_ControlDTCSetting = $85,
PUDS_SI_ResponseOnEvent = $86,
PUDS_SI_LinkControl = $87,
PUDS_SI_ReadDataByIdentifier = $22,
PUDS_SI_ReadMemoryByAddress = $23,
PUDS_SI_ReadScalingDataByIdentifier = $24,
PUDS_SI_ReadDataByPeriodicIdentifier = $2A,
PUDS_SI_DynamicallyDefineDataIdentifier = $2C,
PUDS_SI_WriteDataByIdentifier = $2E,
PUDS_SI_WriteMemoryByAddress = $3D,
PUDS_SI_ClearDiagnosticInformation = $14,
PUDS_SI_ReadDTCInformation = $19,
PUDS_SI_InputOutputControlByIdentifier = $2F,
PUDS_SI_RoutineControl = $31,
PUDS_SI_RequestDownload = $34,
PUDS_SI_RequestUpload = $35,
PUDS_SI_TransferData = $36,
PUDS_SI_RequestTransferExit = $37,
PUDS_NR_SI = $7f
);
40
PCAN-UDS API – User Manual
C#
PUDS_NR_SI = 0x7f,
}
C++ / CLR
41
PCAN-UDS API – User Manual
PUDS_SI_RequestTransferExit = 0x37,
PUDS_NR_SI = 0x7f,
};
Visual Basic
PUDS_NR_SI = &H7F
End Enum
Values
Name Value Description
PUDS_SI_DiagnosticSessionControl 0x10 (16) Identifier of the UDS Service DiagnosticSessionControl
PUDS_SI_ECUReset 0x11 (17) Identifier of the UDS Service ECUReset
PUDS_SI_SecurityAccess 0x27 (39) Identifier of the UDS Service SecurityAccess
PUDS_SI_CommunicationControl 0x28 (40) Identifier of the UDS Service CommunicationControl
PUDS_SI_TesterPresent 0x3E (62) Identifier of the UDS Service TesterPresent
PUDS_SI_AccessTimingParameter 0x83 (131) Identifier of the UDS Service AccessTimingParameter
PUDS_SI_SecuredDataTransmission 0x84 (132) Identifier of the UDS Service SecuredDataTransmission
PUDS_SI_ControlDTCSetting 0x85 (133) Identifier of the UDS Service ControlDTCSetting
PUDS_SI_ResponseOnEvent 0x86 (134) Identifier of the UDS Service ResponseOnEvent
PUDS_SI_LinkControl 0x87 (135) Identifier of the UDS Service LinkControl
PUDS_SI_ReadDataByIdentifier 0x22 (34) Identifier of the UDS Service ReadDataByIdentifier
PUDS_SI_ReadMemoryByAddress 0x23 (35) Identifier of the UDS Service ReadMemoryByAddress
PUDS_SI_ReadScalingDataByIdentifier 0x24 (36) Identifier of the UDS Service ReadScalingDataByIdentifier
PUDS_SI_ReadDataByPeriodicIdentifier 0x2A (42) Identifier of the UDS Service ReadDataByPeriodicIdentifier
PUDS_SI_DynamicallyDefineDataIdentifier 0x2C (44) Identifier of the UDS Service DynamicallyDefineDataIdentifier
PUDS_SI_WriteDataByIdentifier 0x2E (46) Identifier of the UDS Service WriteDataByIdentifier
42
PCAN-UDS API – User Manual
3.5.8 TPUDSAddress
Represents the legislated addresses used with OBD (ISO‐15765‐4) communication.
Syntax
C++
Pascal OO
TPUDSAddress = (
PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT = $F1,
PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL = $33,
PUDS_ISO_15765_4_ADDR_ECU_1 = $01,
PUDS_ISO_15765_4_ADDR_ECU_2 = $02,
PUDS_ISO_15765_4_ADDR_ECU_3 = $03,
PUDS_ISO_15765_4_ADDR_ECU_4 = $04,
PUDS_ISO_15765_4_ADDR_ECU_5 = $05,
PUDS_ISO_15765_4_ADDR_ECU_6 = $06,
PUDS_ISO_15765_4_ADDR_ECU_7 = $07,
PUDS_ISO_15765_4_ADDR_ECU_8 = $08
);
C#
43
PCAN-UDS API – User Manual
PUDS_ISO_15765_4_ADDR_ECU_6 = 0x06,
PUDS_ISO_15765_4_ADDR_ECU_7 = 0x07,
PUDS_ISO_15765_4_ADDR_ECU_8 = 0x08,
}
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT 0xF1 (241) Legislated physical address for external equipment
PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL 0x33 (51) Functional address for legislated OBD system
PUDS_ISO_15765_4_ADDR_ECU_1 0x01 (1) Legislated‐OBD ECU #1
PUDS_ISO_15765_4_ADDR_ECU_2 0x02 (2) Legislated‐OBD ECU #2
PUDS_ISO_15765_4_ADDR_ECU_3 0x03 (3) Legislated‐OBD ECU #3
PUDS_ISO_15765_4_ADDR_ECU_4 0x04 (4) Legislated‐OBD ECU #4
PUDS_ISO_15765_4_ADDR_ECU_5 0x05 (5) Legislated‐OBD ECU #5
PUDS_ISO_15765_4_ADDR_ECU_6 0x06 (6) Legislated‐OBD ECU #6
PUDS_ISO_15765_4_ADDR_ECU_7 0x07 (7) Legislated‐OBD ECU #7
PUDS_ISO_15765_4_ADDR_ECU_8 0x08 (8) Legislated‐OBD ECU #8
44
PCAN-UDS API – User Manual
3.5.9 TPUDSCanId
Represents the legislated CAN Identifiers used with OBD (ISO‐15765‐4) communication. Each of these CAN IDs
has a specific network addressing associated to.
Syntax
C++
Pascal OO
TPUDSCanId = (
PUDS_ISO_15765_4_CAN_ID_FUNCTIONAL_REQUEST = $7DF,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_1 = $7E0,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_1 = $7E8,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_2 = $7E1,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_2 = $7E9,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_3 = $7E2,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_3 = $7EA,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_4 = $7E3,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_4 = $7EB,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_5 = $7E4,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_5 = $7EC,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_6 = $7E5,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_6 = $7ED,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_7 = $7E6,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_7 = $7EE,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_8 = $7E7,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_8 = $7EF
);
C#
45
PCAN-UDS API – User Manual
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_4 = 0x7EB,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_5 = 0x7E4,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_5 = 0x7EC,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_6 = 0x7E5,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_6 = 0x7ED,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_7 = 0x7E6,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_7 = 0x7EE,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_8 = 0x7E7,
PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_8 = 0x7EF,
}
C++ / CLR
Visual Basic
46
PCAN-UDS API – User Manual
Values
3.5.10 TPUDSProtocol
Represents the supported network layer protocol for UDS communication.
Syntax
C++
Pascal OO
TPUDSProtocol = (
PUDS_PROTOCOL_NONE = $00,
PUDS_PROTOCOL_ISO_15765_2_11B = $01,
PUDS_PROTOCOL_ISO_15765_2_11B_REMOTE = $02,
PUDS_PROTOCOL_ISO_15765_2_29B = $03,
PUDS_PROTOCOL_ISO_15765_2_29B_REMOTE = $04,
PUDS_PROTOCOL_ISO_15765_3_29B = $05,
PUDS_PROTOCOL_ISO_15765_2_29B_NORMAL = $06,
PUDS_PROTOCOL_ISO_15765_2_11B_EXTENDED = $07,
PUDS_PROTOCOL_ISO_15765_2_29B_EXTENDED = $08
);
47
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_PROTOCOL_NONE 0 Network layer configuration for Unacknowlegde Unsegmented Data
Transfer
PUDS_PROTOCOL_ISO_15765_2_11B 1 Network layer configuration for the ISO‐TP API: 11 BIT CAN ID, NORMAL
addressing and diagnostic message type
PUDS_PROTOCOL_ISO_15765_2_11B_REMOTE 2 Network layer configuration for the ISO‐TP API: 11 BIT CAN ID, MIXED
addressing and remote diagnostic message type
PUDS_PROTOCOL_ISO_15765_2_29B 3 Network layer configuration for the ISO‐TP API: 29 BIT CAN ID, FIXED
NORMAL addressing and diagnostic message type
PUDS_PROTOCOL_ISO_15765_2_29B_REMOTE 4 Network layer configuration for the ISO‐TP API: 29 BIT CAN ID, MIXED
addressing and remote diagnostic message type
PUDS_PROTOCOL_ISO_15765_3_29B 5 Network layer configuration for the ISO‐TP API: Enhanced diagnostics 29
bit CAN Identifiers
48
PCAN-UDS API – User Manual
See also: UDS and ISO‐TP Network Addressing Information on page 339, UUDT Read/Write example p. 344.
3.5.11 TPUDSAddressingType
Represents the format addressing type of UDS on CAN messages (using ISO‐TP API).
Syntax
C++
Pascal OO
{$Z1}
TPUDSAddressingType = (
PUDS_ADDRESSING_PHYSICAL = $01,
PUDS_ADDRESSING_FUNCTIONAL = $02,
);
C#
C++ / CLR
49
PCAN-UDS API – User Manual
Visual Basic
Values
Name Value Description
PUDS_ADDRESSING_PHYSICAL 1 Physical addressing (used for communication between 2 nodes)
PUDS_ADDRESSING_FUNCTIONAL 2 Functional addressing (used to broadcast messages on the CAN bus)
Remarks: When using functionally addressed messages (PUDS_ADDRESSING_FUNCTIONAL), keep in mind that
the UDS message must fit in a single CAN frame:
the length of the DATA plus the ISO‐TP header must be equal or less than 8 bytes,
the ISO‐TP header varies from 1 to 2 bytes depending on the network addressing format (MIXED and
EXTENDED addressing will use 2 bytes)
See also: UDS and ISO‐TP Network Addressing Information on page 339.
3.5.12 TPUDSMessageType
Represents the type of UDS messages.
Syntax
C++
Pascal OO
{$Z1}
TPUDSMessageType = (
PUDS_MESSAGE_TYPE_REQUEST = $00,
PUDS_MESSAGE_TYPE_CONFIRM = $01,
PUDS_MESSAGE_TYPE_INDICATION = $02,
PUDS_MESSAGE_TYPE_INDICATION_TX = $03,
PUDS_MESSAGE_TYPE_CONFIRM_UUDT = $04,
);
C#
50
PCAN-UDS API – User Manual
PUDS_MESSAGE_TYPE_CONFIRM = 0x01,
PUDS_MESSAGE_TYPE_INDICATION = 0x02,
PUDS_MESSAGE_TYPE_INDICATION_TX = 0x03,
PUDS_MESSAGE_TYPE_CONFIRM_UUDT = 0x04,
}
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_MESSAGE_TYPE_REQUEST 0 UDS Request message.
PUDS_MESSAGE_TYPE_CONFIRM 1 UDS Request or Response confirmation message.
PUDS_MESSAGE_TYPE_INDICATION 2 Incoming UDS message.
PUDS_MESSAGE_TYPE_INDICATION_TX 3 UDS message transmission started.
PUDS_MESSAGE_TYPE_CONFIRM_UUDT 4 Unacknowledge Unsegmented Data Transfert (UUDT)
response.
3.5.13 TPUDSSvcParamDSC
Represents the subfunction parameter for UDS service DiagnosticSessionControl.
Syntax
C++
51
PCAN-UDS API – User Manual
Pascal OO
{$Z1}
TPUDSSvcParamDSC = (
PUDS_SVC_PARAM_DSC_DS = $01,
PUDS_SVC_PARAM_DSC_ECUPS = $02,
PUDS_SVC_PARAM_DSC_ECUEDS = $03,
PUDS_SVC_PARAM_DSC_SSDS = $04
);
C#
C++ / CLR
Values
Name Value Description
PUDS_SVC_PARAM_DSC_DS 1 Default Session
PUDS_SVC_PARAM_DSC_ECUPS 2 ECU Programming Session
PUDS_SVC_PARAM_DSC_ECUEDS 3 ECU Extended Diagnostic Session
PUDS_SVC_PARAM_DSC_SSDS 4 Safety System Diagnostic Session
3.5.14 TPUDSSvcParamER
Represents the subfunction parameter for UDS service ECUReset.
52
PCAN-UDS API – User Manual
Syntax
C++
Pascal OO
TPUDSSvcParamER = (
PUDS_SVC_PARAM_ER_HR = $01,
PUDS_SVC_PARAM_ER_KOFFONR = $02,
PUDS_SVC_PARAM_ER_SR = $03,
PUDS_SVC_PARAM_ER_ERPSD = $04,
PUDS_SVC_PARAM_ER_DRPSD = $05
);
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_ER_HR 1 Hard Reset
PUDS_SVC_PARAM_ER_KOFFONR 2 Key Off on Reset
PUDS_SVC_PARAM_ER_SR 3 Soft Reset
PUDS_SVC_PARAM_ER_ERPSD 4 Enable Rapid Power Shutdown
53
PCAN-UDS API – User Manual
3.5.15 TPUDSSvcParamCC
Represents the subfunction parameter for UDS service ComunicationControl.
Syntax
C++
Pascal OO
TPUDSSvcParamCC = (
PUDS_SVC_PARAM_CC_ERXTX = $00,
PUDS_SVC_PARAM_CC_ERXDTX = $01,
PUDS_SVC_PARAM_CC_DRXETX = $02,
PUDS_SVC_PARAM_CC_DRXTX = $03
);
C#
C++ / CLR
Visual Basic
54
PCAN-UDS API – User Manual
Values
Name Value Description
PUDS_SVC_PARAM_CC_ERXTX 0 Enable Rx and Tx
PUDS_SVC_PARAM_CC_ERXDTX 1 Enable Rx and Disable Tx
PUDS_SVC_PARAM_CC_DRXETX 2 Disable Rx and Enable Tx
PUDS_SVC_PARAM_CC_DRXTX 3 Disable Rx and Tx
3.5.16 TPUDSSvcParamTP
Represents the subfunction parameter for UDS service TesterPresent.
Syntax
C++
Pascal OO
TPUDSSvcParamTP = (
PUDS_SVC_PARAM_TP_ZSUBF = $00
);
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_TP_ZSUBF 0 Zero subfunction
3.5.17 TPUDSSvcParamCDTCS
Represents the subfunction parameter for UDS service ControlDTCSetting.
55
PCAN-UDS API – User Manual
Syntax
C++
Pascal OO
TPUDSSvcParamCDTCS = (
PUDS_SVC_PARAM_CDTCS_ON = $01,
PUDS_SVC_PARAM_CDTCS_OFF = $02
);
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_CDTCS_ON 1 The server(s) shall resume the setting of diagnostic
trouble codes
PUDS_SVC_PARAM_CDTCS_OFF 2 The server(s) shall stop the setting of diagnostic
trouble codes
3.5.18 TPUDSSvcParamROE
Represents the subfunction parameter for UDS service ControlDTCSetting.
Syntax
C++
56
PCAN-UDS API – User Manual
Pascal OO
TPUDSSvcParamROE = (
PUDS_SVC_PARAM_ROE_STPROE = $00,
PUDS_SVC_PARAM_ROE_ONDTCS = $01,
PUDS_SVC_PARAM_ROE_OTI = $02,
PUDS_SVC_PARAM_ROE_OCODID = $03,
PUDS_SVC_PARAM_ROE_RAE = $04,
PUDS_SVC_PARAM_ROE_STRTROE = $05,
PUDS_SVC_PARAM_ROE_CLRROE = $06,
PUDS_SVC_PARAM_ROE_OCOV = $07
);
C#
C++ / CLR
Visual Basic
57
PCAN-UDS API – User Manual
Values
Name Value Description
PUDS_SVC_PARAM_ROE_STPROE 0 Stop Response On Event
PUDS_SVC_PARAM_ROE_ONDTCS 1 On DTC Status Change
PUDS_SVC_PARAM_ROE_OTI 2 On Timer Interrupt
PUDS_SVC_PARAM_ROE_OCODID 3 On Change Of Data Identifier
PUDS_SVC_PARAM_ROE_RAE 4 Report Activated Events
PUDS_SVC_PARAM_ROE_STRTROE 5 Start Response On Event
PUDS_SVC_PARAM_ROE_CLRROE 6 Clear Response On Event
PUDS_SVC_PARAM_ROE_OCOV 7 On Comparison Of Values
3.5.19 TPUDSSvcParamROERecommendedServiceID
Represents the recommended service to use with the UDS service ResponseOnEvent.
Syntax
C++
Pascal OO
TPUDSSvcParamROERecommendedServiceID = (
PUDS_SVC_PARAM_ROE_STRT_SI_RDBI = 34,
PUDS_SVC_PARAM_ROE_STRT_SI_RDTCI = 25,
PUDS_SVC_PARAM_ROE_STRT_SI_RC = 49,
PUDS_SVC_PARAM_ROE_STRT_SI_IOCBI = 47
);
C#
C++ / CLR
58
PCAN-UDS API – User Manual
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_ROE_STRT_SI_RDBI PUDS_SI_ReadDataByIdentifier UDS service ReadDataByIdentifier
PUDS_SVC_PARAM_ROE_STRT_SI_RDTCI PUDS_SI_ReadDTCInformation UDS service ReadDTCInformation
PUDS_SVC_PARAM_ROE_STRT_SI_RC PUDS_SI_RoutineControl UDS service RoutineControl
PUDS_SVC_PARAM_ROE_STRT_SI_IOCBI PUDS_SI_InputOutputControlByIdentifier UDS service InputOutputControlByIdentifier
3.5.20 TPUDSSvcParamLC
Represents the subfunction parameter for UDS service LinkControl.
Syntax
C++
Pascal OO
TPUDSSvcParamLC = (
PUDS_SVC_PARAM_LC_VBTWFBR = $01,
PUDS_SVC_PARAM_LC_VBTWSBR = $02,
PUDS_SVC_PARAM_LC_TB = $03
);
C#
C++ / CLR
59
PCAN-UDS API – User Manual
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_LC_VBTWFBR 1 Verify Baudrate Transition With Fixed Baudrate
PUDS_SVC_PARAM_LC_VBTWSBR 2 Verify Baudrate Transition With Specific Baudrate
PUDS_SVC_PARAM_LC_TB 3 Transition Baudrate
3.5.21 TPUDSSvcParamLCBaudrateIdentifier
Represents the standard Baudrate Identifiers for use with the UDS service LinkControl.
Syntax
C++
Pascal OO
TPUDSSvcParamLCBaudrateIdentifier = (
PUDS_SVC_PARAM_LC_BAUDRATE_PC_9600 = $01,
PUDS_SVC_PARAM_LC_BAUDRATE_PC_19200 = $02,
PUDS_SVC_PARAM_LC_BAUDRATE_PC_38400 = $03,
PUDS_SVC_PARAM_LC_BAUDRATE_PC_57600 = $04,
PUDS_SVC_PARAM_LC_BAUDRATE_PC_115200 = $05,
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_125K = $10,
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_250K = $11,
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_500K = $12,
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_1M = $13
);
C#
60
PCAN-UDS API – User Manual
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_250K = 0x11,
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_500K = 0x12,
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_1M = 0x13,
}
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_LC_BAUDRATE_PC_9600 1 standard PC baud rate of 9.6 KBaud
PUDS_SVC_PARAM_LC_BAUDRATE_PC_19200 2 standard PC baud rate of 19.2 KBaud
PUDS_SVC_PARAM_LC_BAUDRATE_PC_38400 3 standard PC baud rate of 38.4 KBaud
PUDS_SVC_PARAM_LC_BAUDRATE_PC_57600 4 standard PC baud rate of 57.6 KBaud
PUDS_SVC_PARAM_LC_BAUDRATE_PC_115200 5 standard PC baud rate of 115.2 KBaud
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_125K 0x10 (16) standard CAN baud rate of 125 KBaud
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_250K 0x11 (17) standard CAN baud rate of 250 KBaud
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_500K 0x12 (18) standard CAN baud rate of 500 KBaud
PUDS_SVC_PARAM_LC_BAUDRATE_CAN_1M 0x13 (19) standard CAN baud rate of 1 MBaud
3.5.22 TPUDSSvcParamDI
Represents the Data Identifiers defined in UDS standard ISO‐14229‐1.
61
PCAN-UDS API – User Manual
Syntax
C++
Pascal OO
TPUDSSvcParamDI= (
PUDS_SVC_PARAM_DI_BSIDID = $F180,
PUDS_SVC_PARAM_DI_ASIDID = $F181,
PUDS_SVC_PARAM_DI_ADIDID = $F182,
PUDS_SVC_PARAM_DI_BSFPDID = $F183,
PUDS_SVC_PARAM_DI_ASFPDID = $F184,
PUDS_SVC_PARAM_DI_ADFPDID = $F185,
PUDS_SVC_PARAM_DI_ADSDID = $F186,
PUDS_SVC_PARAM_DI_VMSPNDID = $F187,
PUDS_SVC_PARAM_DI_VMECUSNDID = $F188,
PUDS_SVC_PARAM_DI_VMECUSVNDID = $F189,
PUDS_SVC_PARAM_DI_SSIDDID = $F18A,
PUDS_SVC_PARAM_DI_ECUMDDID = $F18B,
PUDS_SVC_PARAM_DI_ECUSNDID = $F18C,
PUDS_SVC_PARAM_DI_SFUDID = $F18D,
PUDS_SVC_PARAM_DI_VMKAPNDID = $F18E,
PUDS_SVC_PARAM_DI_VINDID = $F190,
PUDS_SVC_PARAM_DI_VMECUHNDID = $F191,
PUDS_SVC_PARAM_DI_SSECUHWNDID = $F192,
PUDS_SVC_PARAM_DI_SSECUHWVNDID = $F193,
PUDS_SVC_PARAM_DI_SSECUSWNDID = $F194,
PUDS_SVC_PARAM_DI_SSECUSWVNDID = $F195,
PUDS_SVC_PARAM_DI_EROTANDID = $F196,
62
PCAN-UDS API – User Manual
PUDS_SVC_PARAM_DI_SNOETDID = $F197,
PUDS_SVC_PARAM_DI_RSCOTSNDID = $F198,
PUDS_SVC_PARAM_DI_PDDID = $F199,
PUDS_SVC_PARAM_DI_CRSCOCESNDID = $F19A,
PUDS_SVC_PARAM_DI_CDDID = $F19B,
PUDS_SVC_PARAM_DI_CESWNDID = $F19C,
PUDS_SVC_PARAM_DI_EIDDID = $F19D,
PUDS_SVC_PARAM_DI_ODXFDID = $F19E,
PUDS_SVC_PARAM_DI_EDID = $F19F
);
C#
C++ / CLR
63
PCAN-UDS API – User Manual
PUDS_SVC_PARAM_DI_VMECUSVNDID = 0xF189,
PUDS_SVC_PARAM_DI_SSIDDID = 0xF18A,
PUDS_SVC_PARAM_DI_ECUMDDID = 0xF18B,
PUDS_SVC_PARAM_DI_ECUSNDID = 0xF18C,
PUDS_SVC_PARAM_DI_SFUDID = 0xF18D,
PUDS_SVC_PARAM_DI_VMKAPNDID = 0xF18E,
PUDS_SVC_PARAM_DI_VINDID = 0xF190,
PUDS_SVC_PARAM_DI_VMECUHNDID = 0xF191,
PUDS_SVC_PARAM_DI_SSECUHWNDID = 0xF192,
PUDS_SVC_PARAM_DI_SSECUHWVNDID = 0xF193,
PUDS_SVC_PARAM_DI_SSECUSWNDID = 0xF194,
PUDS_SVC_PARAM_DI_SSECUSWVNDID = 0xF195,
PUDS_SVC_PARAM_DI_EROTANDID = 0xF196,
PUDS_SVC_PARAM_DI_SNOETDID = 0xF197,
PUDS_SVC_PARAM_DI_RSCOTSNDID = 0xF198,
PUDS_SVC_PARAM_DI_PDDID = 0xF199,
PUDS_SVC_PARAM_DI_CRSCOCESNDID = 0xF19A,
PUDS_SVC_PARAM_DI_CDDID = 0xF19B,
PUDS_SVC_PARAM_DI_CESWNDID = 0xF19C,
PUDS_SVC_PARAM_DI_EIDDID = 0xF19D,
PUDS_SVC_PARAM_DI_ODXFDID = 0xF19E,
PUDS_SVC_PARAM_DI_EDID = 0xF19F,
};
Visual Basic
64
PCAN-UDS API – User Manual
Values
Name Value Description
PUDS_SVC_PARAM_DI_BSIDID 0xF180 Boot Software Identification Data Identifier
PUDS_SVC_PARAM_DI_ASIDID 0xF181 Application Software Identification Data Identifier
PUDS_SVC_PARAM_DI_ADIDID 0xF182 Application Data Identification Data Identifier
PUDS_SVC_PARAM_DI_BSFPDID 0xF183 Boot Software Identification Data Identifier
PUDS_SVC_PARAM_DI_ASFPDID 0xF184 Application Software Fingerprint Data Identifier
PUDS_SVC_PARAM_DI_ADFPDID 0xF185 Application Data Fingerprint Data Identifier
PUDS_SVC_PARAM_DI_ADSDID 0xF186 Active Diagnostic Session Data Identifier
PUDS_SVC_PARAM_DI_VMSPNDID 0xF187 Vehicle Manufacturer Spare Part Number Data Identifier
PUDS_SVC_PARAM_DI_VMECUSNDID 0xF188 Vehicle Manufacturer ECU Software Number Data Identifier
PUDS_SVC_PARAM_DI_VMECUSVNDID 0xF189 Vehicle Manufacturer ECU Software Version Number Data Identifier
PUDS_SVC_PARAM_DI_SSIDDID 0xF18A System Supplier Identifier Data Identifier
PUDS_SVC_PARAM_DI_ECUMDDID 0xF18B ECU Manufacturing Date Data Identifier
PUDS_SVC_PARAM_DI_ECUSNDID 0xF18C ECU Serial Number Data Identifier
PUDS_SVC_PARAM_DI_SFUDID 0xF18D Supported Functional Units Data Identifier
PUDS_SVC_PARAM_DI_VMKAPNDID 0xF18E Vehicle Manufacturer Kit Assembly Part Number Data Identifier
PUDS_SVC_PARAM_DI_VINDID 0xF190 VIN Data Identifier
PUDS_SVC_PARAM_DI_VMECUHNDID 0xF191 Vehicle Manufacturer ECU Hardware Number Data Identifier
PUDS_SVC_PARAM_DI_SSECUHWNDID 0xF192 System Supplier ECU Hardware Number Data Identifier
PUDS_SVC_PARAM_DI_SSECUHWVNDID 0xF193 System Supplier ECU Hardware Version Number Data Identifier
PUDS_SVC_PARAM_DI_SSECUSWNDID 0xF194 System Supplier ECU Software Number Data Identifier
PUDS_SVC_PARAM_DI_SSECUSWVNDID 0xF195 System Supplier ECU Software Version Number Data Identifier
PUDS_SVC_PARAM_DI_EROTANDID 0xF196 Exhaust Regulation Or Type Approval Number Data Identifier
PUDS_SVC_PARAM_DI_SNOETDID 0xF197 System Name Or Engine Type Data Identifier
PUDS_SVC_PARAM_DI_RSCOTSNDID 0xF198 Repair Shop Code Or Tester Serial Number Data Identifier
PUDS_SVC_PARAM_DI_PDDID 0xF199 Programming Date Data Identifier
PUDS_SVC_PARAM_DI_CRSCOCESNDID 0xF19A Calibration Repair Shop Code Or Calibration Equipment Serial Number
Data Identifier
PUDS_SVC_PARAM_DI_CDDID 0xF19B calibrationDate Data Identifier
PUDS_SVC_PARAM_DI_CESWNDID 0xF19C Calibration Equipment Software Number Data Identifier
PUDS_SVC_PARAM_DI_EIDDID 0xF19D ECU Installation Date Data Identifier
PUDS_SVC_PARAM_DI_ODXFDID 0xF19E ODX File Data Identifier
PUDS_SVC_PARAM_DI_EDID 0xF19F Entity Data Identifier
3.5.23 TPUDSSvcParamRDBPI
Represents the subfunction parameter for UDS service ReadDataByPeriodicIdentifier.
Syntax
C++
65
PCAN-UDS API – User Manual
Pascal OO
TPUDSSvcParamRDBPI = (
PUDS_SVC_PARAM_RDBPI_SASR = $01,
PUDS_SVC_PARAM_RDBPI_SAMR = $02,
PUDS_SVC_PARAM_RDBPI_SAFR = $03,
PUDS_SVC_PARAM_RDBPI_SS = $04
);
C#
C++ / CLR
PUDS_SVC_PARAM_RDBPI_SASR = 0x01,
PUDS_SVC_PARAM_RDBPI_SAMR = 0x02,
PUDS_SVC_PARAM_RDBPI_SAFR = 0x03,
PUDS_SVC_PARAM_RDBPI_SS = 0x04,
};
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_RDBPI_SASR 1 Send At Slow Rate
PUDS_SVC_PARAM_RDBPI_SAMR 2 Send At Medium Rate
PUDS_SVC_PARAM_RDBPI_SAFR 3 Send At Fast Rate
PUDS_SVC_PARAM_RDBPI_SS 4 Stop Sending
3.5.24 TPUDSSvcParamDDDI
Represents the subfunction parameter for UDS service DynamicallyDefineDataIdentifier.
Syntax
C++
66
PCAN-UDS API – User Manual
Pascal OO
TPUDSSvcParamDDDI = (
PUDS_SVC_PARAM_DDDI_DBID = $01,
PUDS_SVC_PARAM_DDDI_DBMA = $02,
PUDS_SVC_PARAM_DDDI_CDDDI = $03
);
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_DDDI_DBID 1 Define By Identifier
PUDS_SVC_PARAM_DDDI_DBMA 2 Define By Memory Address
PUDS_SVC_PARAM_DDDI_CDDDI 3 Clear Dynamically Defined Data Identifier
3.5.25 TPUDSSvcParamRDTCI
Represents the subfunction parameter for UDS service ReadDTCInformation.
67
PCAN-UDS API – User Manual
Syntax
C++
Pascal OO
TPUDSSvcParamRDTCI = (
PUDS_SVC_PARAM_RDTCI_RNODTCBSM = $01,
PUDS_SVC_PARAM_RDTCI_RDTCBSM = $02,
PUDS_SVC_PARAM_RDTCI_RDTCSSI = $03,
PUDS_SVC_PARAM_RDTCI_RDTCSSBDTC = $04,
PUDS_SVC_PARAM_RDTCI_RDTCSSBRN = $05,
PUDS_SVC_PARAM_RDTCI_RDTCEDRBDN = $06,
PUDS_SVC_PARAM_RDTCI_RNODTCBSMR = $07,
PUDS_SVC_PARAM_RDTCI_RDTCBSMR = $08,
PUDS_SVC_PARAM_RDTCI_RSIODTC = $09,
PUDS_SVC_PARAM_RDTCI_RSUPDTC = $0A,
PUDS_SVC_PARAM_RDTCI_RFTFDTC = $0B,
PUDS_SVC_PARAM_RDTCI_RFCDTC = $0C,
PUDS_SVC_PARAM_RDTCI_RMRTFDTC = $0D,
PUDS_SVC_PARAM_RDTCI_RMRCDTC = $0E,
PUDS_SVC_PARAM_RDTCI_RMMDTCBSM = $0F,
PUDS_SVC_PARAM_RDTCI_RMMDEDRBDN = $10,
PUDS_SVC_PARAM_RDTCI_RNOMMDTCBSM = $11,
PUDS_SVC_PARAM_RDTCI_RNOOBDDTCBSM = $12,
PUDS_SVC_PARAM_RDTCI_ROBDDTCBSM = $13
);
C#
68
PCAN-UDS API – User Manual
PUDS_SVC_PARAM_RDTCI_RSUPDTC = 0x0A,
PUDS_SVC_PARAM_RDTCI_RFTFDTC = 0x0B,
PUDS_SVC_PARAM_RDTCI_RFCDTC = 0x0C,
PUDS_SVC_PARAM_RDTCI_RMRTFDTC = 0x0D,
PUDS_SVC_PARAM_RDTCI_RMRCDTC = 0x0E,
PUDS_SVC_PARAM_RDTCI_RMMDTCBSM = 0x0F,
PUDS_SVC_PARAM_RDTCI_RMMDEDRBDN = 0x10,
PUDS_SVC_PARAM_RDTCI_RNOMMDTCBSM = 0x11,
PUDS_SVC_PARAM_RDTCI_RNOOBDDTCBSM = 0x12,
PUDS_SVC_PARAM_RDTCI_ROBDDTCBSM = 0x13,
}
C++ / CLR
Visual Basic
69
PCAN-UDS API – User Manual
Values
Name Value Description
PUDS_SVC_PARAM_DI_BSIDID 0xF180 Boot Software Identification Data Identifier
PUDS_SVC_PARAM_DI_ASIDID 0xF181 Application Software Identification Data Identifier
PUDS_SVC_PARAM_DI_ADIDID 0xF182 Application Data Identification Data Identifier
PUDS_SVC_PARAM_DI_BSFPDID 0xF183 Boot Software Identification Data Identifier
PUDS_SVC_PARAM_DI_ASFPDID 0xF184 Application Software Fingerprint Data Identifier
PUDS_SVC_PARAM_DI_ADFPDID 0xF185 Application Data Fingerprint Data Identifier
PUDS_SVC_PARAM_DI_ADSDID 0xF186 Active Diagnostic Session Data Identifier
PUDS_SVC_PARAM_DI_VMSPNDID 0xF187 Vehicle Manufacturer Spare Part Number Data Identifier
PUDS_SVC_PARAM_RDTCI_RNODTCBSM 1 report Number Of DTC By Status Mask
PUDS_SVC_PARAM_RDTCI_RDTCBSM 2 report DTC By Status Mask
PUDS_SVC_PARAM_RDTCI_RDTCSSI 3 report DTC Snapshot Identification
PUDS_SVC_PARAM_RDTCI_RDTCSSBDTC 4 report DTC Snapshot Record By DTC Number
PUDS_SVC_PARAM_RDTCI_RDTCSSBRN 5 report DTC Snapshot Record By Record Number
PUDS_SVC_PARAM_RDTCI_RDTCEDRBDN 6 report DTC Extended Data Record By DTC Number
PUDS_SVC_PARAM_RDTCI_RNODTCBSMR 7 report Number Of DTC By Severity Mask Record
PUDS_SVC_PARAM_RDTCI_RDTCBSMR 8 report DTC By Severity Mask Record
PUDS_SVC_PARAM_RDTCI_RSIODTC 9 report Severity Information Of DTC
PUDS_SVC_PARAM_RDTCI_RSUPDTC 0x0A (10) report Supported DTC
PUDS_SVC_PARAM_RDTCI_RFTFDTC 0x0B (11) report First Test Failed DTC
PUDS_SVC_PARAM_RDTCI_RFCDTC 0x0C (12) report First Confirmed DTC
PUDS_SVC_PARAM_RDTCI_RMRTFDTC 0x0D (13) report Most Recent Test Failed DTC
PUDS_SVC_PARAM_RDTCI_RMRCDTC 0x0E (14) report Most Recent Confirmed DTC
PUDS_SVC_PARAM_RDTCI_RMMDTCBSM 0x0F (15) report Mirror Memory DTC By Status Mask
PUDS_SVC_PARAM_RDTCI_RMMDEDRBDN 0x10 (16) report Mirror Memory DTC Extended Data Record By DTC Number
PUDS_SVC_PARAM_RDTCI_RNOMMDTCBSM 0x11 (16) report Number Of Mirror MemoryDTC By Status Mask
PUDS_SVC_PARAM_RDTCI_RNOOBDDTCBSM 0x12 (17) report Number Of Emissions Related OBD DTC By Status Mask
PUDS_SVC_PARAM_RDTCI_ROBDDTCBSM 0x13 (18) report Emissions Related OBD DTC By Status Mask
3.5.26 TPUDSSvcParamRDTCI_DTCSVM
Represents the DTC severity mask’s flags (DTCSVM) used with the UDS service SvcReadDTCInformation.
Syntax
C++
Pascal OO
TPUDSSvcParamRDTCI_DTCSVM = (
PUDS_SVC_PARAM_RDTCI_DTCSVM_NSA = $00,
PUDS_SVC_PARAM_RDTCI_DTCSVM_MO = $20,
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKANH = $40,
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKI = $80
70
PCAN-UDS API – User Manual
);
C#
[Flags]
public enum TPUDSSvcParamRDTCI_DTCSVM : byte
{
PUDS_SVC_PARAM_RDTCI_DTCSVM_NSA = 0x00,
PUDS_SVC_PARAM_RDTCI_DTCSVM_MO = 0x20,
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKANH = 0x40,
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKI = 0x80,
}
C++ / CLR
[Flags]
enum struct TPUDSSvcParamRDTCI_DTCSVM : Byte
{
PUDS_SVC_PARAM_RDTCI_DTCSVM_NSA = 0x00,
PUDS_SVC_PARAM_RDTCI_DTCSVM_MO = 0x20,
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKANH = 0x40,
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKI = 0x80,
};
Visual Basic
<Flags()> _
Public Enum TPUDSSvcParamRDTCI_DTCSVM As Byte
PUDS_SVC_PARAM_RDTCI_DTCSVM_NSA = &H0
PUDS_SVC_PARAM_RDTCI_DTCSVM_MO = &H20
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKANH = &H40
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKI = &H80
End Enum
Values
Name Value Description
PUDS_SVC_PARAM_RDTCI_DTCSVM_NSA 0 DTC severity bit definitions : no SeverityAvailable
PUDS_SVC_PARAM_RDTCI_DTCSVM_MO 0x20 (32) DTC severity bit definitions : maintenance Only
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKANH 0x40 (64) DTC severity bit definitions : check At Next Halt
PUDS_SVC_PARAM_RDTCI_DTCSVM_CHKI 0x80 (128) DTC severity bit definitions : check Immediately
3.5.27 TPUDSSvcParamIOCBI
Represents the InputOutput Control Parameter for UDS service InputOutputControlByIdentifier.
Syntax
C++
71
PCAN-UDS API – User Manual
Pascal OO
TPUDSSvcParamIOCBI = (
PUDS_SVC_PARAM_IOCBI_RCTECU = $00,
PUDS_SVC_PARAM_IOCBI_RTD = $01,
PUDS_SVC_PARAM_IOCBI_FCS = $02,
PUDS_SVC_PARAM_IOCBI_STA = $03
);
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_IOCBI_RCTECU 0 Return Control To ECU
PUDS_SVC_PARAM_IOCBI_RTD 1 Reset To Default
PUDS_SVC_PARAM_IOCBI_FCS 2 Freeze Current State
PUDS_SVC_PARAM_IOCBI_STA 3 Short Term Adjustment
3.5.28 TPUDSSvcParamRC
Represents the subfunction parameter for UDS service RoutineControl.
Syntax
C++
72
PCAN-UDS API – User Manual
Pascal OO
TPUDSSvcParamRC = (
PUDS_SVC_PARAM_RC_STR = $01,
PUDS_SVC_PARAM_RC_STPR = $02,
PUDS_SVC_PARAM_RC_RRR = $03
);
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_RC_STR 1 Start Routine
PUDS_SVC_PARAM_RC_STPR 2 Stop Routine
PUDS_SVC_PARAM_RC_RRR 3 Request Routine Results
3.5.29 TPUDSSvcParamRC_RID
Represents the routine identifier used with the UDS service RoutineControl.
Syntax
C++
Pascal OO
TPUDSSvcParamRC_RID= (
73
PCAN-UDS API – User Manual
PUDS_SVC_PARAM_RC_RID_DLRI_ = $E200,
PUDS_SVC_PARAM_RC_RID_EM_ = $FF00,
PUDS_SVC_PARAM_RC_RID_CPD_ = $FF01,
PUDS_SVC_PARAM_RC_RID_EMMDTC_ = $FF02
);
C#
C++ / CLR
Visual Basic
Values
Name Value Description
PUDS_SVC_PARAM_RC_RID_DLRI_ 0xE200 (57856) Deploy Loop Routine ID
PUDS_SVC_PARAM_RC_RID_EM_ 0xFF00 (65280) Erase Memory
PUDS_SVC_PARAM_RC_RID_CPD_ 0xFF01 (65281) Check Programming Dependencies
PUDS_SVC_PARAM_RC_RID_EMMDTC_ 0xFF02 (65282) Erase Mirror Memory DTCs
3.6 Methods
The methods defined for the classes UDSApi and TUDSApi are divided in 4 groups of functionality. Note that
these methods are static and can be called in the name of the class, without instantiation.
Connection
Function Description
Initialize Initializes a PUDS channel
Uninitialize Uninitializes a PUDS channel
74
PCAN-UDS API – User Manual
Configuration
Function Description
SetValue Sets a configuration or information value within a PUDS Channel
Information
Function Description
GetValue Retrieves information from a PUDS Channel
GetStatus Retrieves the current BUS status of a PUDS Channel
Communication
Function Description
Read Reads a UDS message from the receive queue of a PUDS Channel
Write Writes to transmit queue a UDS message using a connected PUDS Channel
75
PCAN-UDS API – User Manual
Function Description
SvcClearDiagnosticInformation Writes to the transmit queue a request for UDS service
ClearDiagnosticInformation
SvcReadDTCInformation Writes to the transmit queue a request for UDS service ReadDTCInformation
SvcReadDTCInformationRDTCSSBDTC Writes to the transmit queue a request for UDS service ReadDTCInformation
SvcReadDTCInformationRDTCSSBRN Writes to the transmit queue a request for UDS service ReadDTCInformation
SvcReadDTCInformationReportExtended Writes to the transmit queue a request for UDS service ReadDTCInformation
SvcReadDTCInformationReportSeverity Writes to the transmit queue a request for UDS service ReadDTCInformation
SvcReadDTCInformationRSIODTC Writes to the transmit queue a request for UDS service ReadDTCInformation
SvcReadDTCInformationNoParam Writes to the transmit queue a request for UDS service ReadDTCInformation
SvcInputOutputControlByIdentifier Writes to the transmit queue a request for UDS service
InputOutputControlByIdentifier
SvcRoutineControl Writes to the transmit queue a request for UDS service RoutineControl
SvcRequestDownload Writes to the transmit queue a request for UDS service RequestDownload
SvcRequestUpload Writes to the transmit queue a request for UDS service RequestUpload
SvcTransferData Writes to the transmit queue a request for UDS service TransferData
SvcRequestTransferExit Writes to the transmit queue a request for UDS service RequestTransferExit
3.6.1 Initialize
Initializes a PUDS Channel.
Overloads
Function Description
Initialize(TPUDSCANHandle, TPUDSBaudrate) Initializes a Plug‐And‐Play PUDS Channel
Syntax
Pascal OO
C#
76
PCAN-UDS API – User Manual
C++ / CLR
Visual Basic
Parameters
Parameters Description
CANChannel The handle of a PCANTP Channel (see TPUDSCANHandle on page 22)
Baudrate The speed for the communication (see TPUDSBaudrate on page 25)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
Remarks: As indicated by its name, the Initialize method initiates a PUDS Channel, preparing it for
communication within the CAN bus connected to it. Calls to the other methods will fail if they are used with a
Channel handle, different than PUDS_NONEBUS, that has not been initialized yet. Each initialized channel
should be released when it is not needed anymore.
77
PCAN-UDS API – User Manual
The Initialization process will fail if an application tries to initialize a PUDS‐Channel that has already been
initialized within the same process.
Take in consideration that initializing a channel causes a reset of the CAN hardware. In this way errors like
BUSOFF, BUSHEAVY, and BUSLIGHT, are removed.
Example
The following example shows the initialize and uninitialize processes for a Plug‐And‐Play channel (channel 2 of
a PCAN‐PCI hardware).
C#:
TPUDSStatus result;
C++/CLR:
TPUDSStatus result;
Visual Basic:
Pascal OO:
var
result: TPUDSStatus;
78
PCAN-UDS API – User Manual
begin
// The Plug & Play Channel (PCAN‐PCI) is initialized
result := TUdsApi.Initialize(TUdsApi.PUDS_PCIBUS2, PUDS_BAUD_500K);
if (result <> PUDS_ERROR_OK) then
MessageBox(0, 'Initialization failed', 'Error', MB_OK)
else
MessageBox(0, 'PCAN‐PCI (Ch‐2) was initialized', 'Success', MB_OK);
See also: Uninitialize on page 82, GetValue on page 94, Understanding PCAN‐UDS on page 8.
Syntax
Pascal OO
C#
C++ / CLR
79
PCAN-UDS API – User Manual
TPUDSBaudrate Baudrate,
[MarshalAs(UnmanagedType::U1)]
TPUDSHWType HwType,
UInt32 IOPort,
UInt16 Interrupt);
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="CANTP_Initialize")> _
Public Shared Function Initialize( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U2)> _
ByVal Baudrate As TPUDSBaudrate, _
<MarshalAs(UnmanagedType.U1)> _
ByVal HwType As TPUDSHWType, _
ByVal IOPort As UInt32, _
ByVal Interrupt As UInt16) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Baudrate The speed for the communication (see TPUDSBaudrate on page 25)
HwType The type of hardware (see TPUDSHWType on page 28)
IOPort The I/O address for the parallel port.
Interrupt Interrupt number of the parallel port.
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
Remarks: As indicated by its name, the Initialize method initiates a PUDS Channel, preparing it for
communication within the CAN bus connected to it. Calls to the other methods will fail if they are used with a
Channel handle, different than PUDS_NONEBUS, that has not been initialized yet. Each initialized channel
should be released when it is not needed anymore.
80
PCAN-UDS API – User Manual
Functional request using 11 bits CAN identifier and normal addressing, from External Test Equipment
address (PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT) to OBD functional address
(PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL),
Physical requests and responses using 11 bits CAN identifier and normal addressing, between the
External Test Equipment address (PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT) and standard ECU
addresses (ECU #1 to #8)
The Initialization process will fail if an application tries to initialize a PUDS‐Channel that has already been
initialized within the same process.
Take in consideration that initializing a channel causes a reset of the CAN hardware. In this way errors like
BUSOFF, BUSHEAVY, and BUSLIGHT, are removed.
Example
The following example shows the initialize and uninitializes processes for a Non‐Plug‐And‐Play channel
(channel 1 of the PCAN‐DNG).
C#
TPUDSStatus result;
C++/CLR:
TPUDSStatus result;
Visual Basic:
81
PCAN-UDS API – User Manual
End If
Pascal OO:
var
result: TPUDSStatus;
begin
// The Non‐Plug & Play Channel (PCAN‐DNG) is initialized
result := TUDSApi.Initialize(TUdsApi.PUDS_DNGBUS1, PUDS_BAUD_500K, PUDS_TYPE_DNG_SJA, $378, 7);
if (result <> PUDS_ERROR_OK) then
MessageBox(0, 'Initialization failed', 'Error', MB_OK)
else
MessageBox(0, 'PCAN‐PCI (Ch‐2) was initialized', 'Error', MB_OK);
See also: Uninitialize below, GetValue on page 94, Understanding PCAN‐UDS on page 8.
3.6.4 Uninitialize
Uninitialize a PUDS Channel.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
82
PCAN-UDS API – User Manual
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Returns
The return value is a TPUDSStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in case
of failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel cannot be uninitialized because it was not found
in the list of reserved channels of the calling application.
Single‐Release: Given a handle of a PUDS Channel initialized before with the method initialize. If the given
channel can not be found then an error is returned
Multiple‐Release: Giving the handle value PUDS_NONEBUS which instructs the API to search for all
channels initialized by the calling application and release them all. This option cause no errors if no
hardware were uninitialized
Example
The following example shows the initialize and uninitializes processes for a Plug‐And‐Play channel (channel 2 of
a PCAN‐PCI hardware).
C#:
TPUDSStatus result;
// Release channel
UDSApi.Uninitialize(UDSApi.PUDS_PCIBUS2);
C++/CLR:
TPUDSStatus result;
// Release channel
UDSApi::Uninitialize(UDSApi::PUDS_PCIBUS2);
83
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
result: TPUDSStatus;
begin
// The Plug & Play Channel (PCAN‐PCI) is initialized
result := TUdsApi.Initialize(TUdsApi.PUDS_PCIBUS2, PUDS_BAUD_500K);
if (result <> PUDS_ERROR_OK) then
MessageBox(0, 'Initialization failed', 'Error', MB_OK)
else
MessageBox(0, 'PCAN‐PCI (Ch‐2) was initialized', 'Error', MB_OK);
// Release channel
TUdsApi.Uninitialize(TUdsApi.PUDS _PCIBUS2);
end;
84
PCAN-UDS API – User Manual
3.6.5 SetValue
Set a configuration or information value within a PUDS Channel.
Overloads
Function Description
SetValue(TPUDSCANHandle, Sets a configuration or information numeric value within a PUDS Channel
TPUDSParameter, UInt32,
UInt32);
SetValue(TPUDSCANHandle, Sets a configuration or information string value within a PUDS Channel
TPUDSParameter, String,
UInt32);
SetValue(TPUDSCANHandle, Sets a configuration or information with an array of bytes within a PUDS Channel
TPUDSParameter, Byte[],
UInt32);
SetValue(TPUDSCANHandle, Sets a configuration or information within a PUDS Channel
TPUDSParameter, IntPrt,
UInt32);
Syntax
Pascal OO
C#
C++ / CLR
85
PCAN-UDS API – User Manual
UInt32 BufferLength);
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_SetValue")> _
Public Shared Function SetValue( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPUDSParameter, _
ByRef NumericBuffer As UInt32, _
ByVal BufferLength As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
NumericBuffer The buffer containing the numeric value to be set.
BufferLength The length in bytes of the given buffer.
Returns
The return value is a TPUDSStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in case
of failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel cannot be uninitialized because it was not found
in the list of reserved channels of the calling application.
PUDS_ERROR_WRONG_PARAM Indicates that the parameters passed to the method are invalid. Check the value of
'Parameter' and assert it is compatible with an integer buffer
Remarks: Use the method SetValue to set configuration information or environment values of a PUDS Channel.
Note that any calls with non UDS parameters (ie. TPUDSParameter) will be forwarded to PCAN‐ISO‐TP API and
PCAN‐Basic API.
More information about the parameters and values that can be set can be found in Parameter Value
Definitions. Since most of the UDS parameters require a numeric value (byte or integer) this is the most
common and useful override.
Example
The following example shows the use of the method SetValue on the channel PUDS_PCIBUS2 to enable debug
mode.
C#
TPUDSStatus result;
UInt32 iBuffer = 0;
86
PCAN-UDS API – User Manual
if (result != TPUDSStatus.PUDS_ERROR_OK)
MessageBox.Show("Failed to set value");
else
MessageBox.Show("Value changed successfully ");
C++/CLR:
TPUDSStatus result;
UInt32 iBuffer = 0;
Visual Basic:
Pascal OO:
var
result: TPUDSStatus;
iBuffer: UINT;
begin
// Enable CAN DEBUG mode
iBuffer := TUdsApi.PUDS_DEBUG_CAN;
result := TUdsApi.SetValue(TUdsApi.PUDS_PCIBUS2, PUDS_PARAM_DEBUG, PLongWord(@iBuffer),
sizeof(iBuffer));
if (result <> PUDS_ERROR_OK) then
MessageBox(0, 'Failed to set value', 'Error', MB_OK)
else
MessageBox(0, 'Value changed successfully ', 'Error', MB_OK);
end;
See also: TPUDSParameter on page 31, Parameter Value Definitions on page 332, GetValue on page 94.
87
PCAN-UDS API – User Manual
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_SetValue")> _
Public Shared Function SetValue( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPUDSParameter, _
<MarshalAs(UnmanagedType.LPStr, SizeParamIndex:=3)> _
ByVal StringBuffer As String, _
ByVal BufferLength As UInt32) As TPUDSStatus
End Function
88
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
StringBuffer The buffer containing the string value to be set.
BufferLength The length in bytes of the given buffer.
Returns
The return value is a TPUDSStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in case
of failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel cannot be uninitialized because it was not found
in the list of reserved channels of the calling application
PUDS_ERROR_WRONG_PARAM Indicates that the parameters passedto the method are invalid. Check the value of
'Parameter' and assert it is compatible with an integer buffer
Remarks: This overrides is only defined for users who wishes to configure PCAN‐Basic API through the UDS API.
See also: GetValue on page 94, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
Syntax
C#
C++ / CLR
89
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_SetValue")> _
Public Shared Function SetValue( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPUDSParameter, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PCANTP Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
Buffer The buffer containing the array value to be set
BufferLength The length in bytes of the given buffer
Returns
The return value is a TPUDSStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in case
of failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel cannot be uninitialized because it was not found
in the list of reserved channels of the calling application.
PUDS_ERROR_WRONG_PARAM Indicates that the parameters passedto the method are invalid. Check the value of
'Parameter' and assert it is compatible with an integer buffer
Remarks: Use the method SetValue to set configuration information or environment values of a PUDS Channel.
Note that any calls with non UDS parameters (ie. TPUDSParameter) will be forwarded to PCAN‐ISO‐TP API and
PCAN‐Basic API.
Note: That any calls with non UDS parameters (ie. TPUDSParameter) will be forwarded to PCAN‐ISO‐TP
API and PCAN‐Basic API.
More information about the parameters and values that can be set can be found in Parameter Value Definition.
Example
The following example shows the use of the method SetValue on the channel PUDS_USBBUS1 to change the
current UDS Session Information.
Note: this only affects the API client side ONLY, no communication with any ECUs is made. If a user wants
to disable the automatic transmission of TesterPresent requests that keeps alive a non‐default diagnostic
session, he/she should set the SESSION_TYPE to the default diagnostic session
(TPUDSSvcParamDSC.PUDS_SVC_PARAM_DSC_DS).
It is assumed that the channel was already initialized and the user retrieved the current session
information with the GetValue API function.
90
PCAN-UDS API – User Manual
C#
TPUDSStatus result;
C++/CLR:
TPUDSStatus result;
Visual Basic:
See also: GetValue on page 94, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
Syntax
C#
91
PCAN-UDS API – User Manual
UInt32 BufferLength);
C++ / CLR
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_SetValue")> _
Public Shared Function SetValue( _
<MarshalAs(UnmanagedType.U1)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPUDSParameter, _
ByVal Buffer As IntPtr, _
ByVal BufferLength As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PCANTP Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
Buffer The buffer containing the array value to be set
BufferLength The length in bytes of the given buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel cannot be uninitialized because it was not found
in the list of reserved channels of the calling application.
PUDS_ERROR_WRONG_PARAM Indicates that the parameters passedto the method are invalid. Check the value of
'Parameter' and assert it is compatible with an integer buffer
Remarks
Use the method SetValue to set configuration information or environment values of a PUDS Channel.
Note: That any calls with non UDS parameters (ie. TPUDSParameter) will be forwarded to PCAN‐ISO‐TP
API and PCAN‐Basic API.
More information about the parameters and values that can be set can be found in Parameter Value
Definitions.
92
PCAN-UDS API – User Manual
Example
The following example shows the use of the method SetValue on the channel PUDS_USBBUS1 to change the
current UDS Session Information.
Note: this only affects the API client side ONLY, no communication with any ECUs is made. If a user wants
to disable the automatic transmission of TesterPresent requests that keeps alive a non‐default diagnostic
session, he/she should set the SESSION_TYPE to the default diagnostic session
(TPUDSSvcParamDSC.PUDS_SVC_PARAM_DSC_DS).
It is assumed that the channel was already initialized and the user retrieved the current session
information with the GetValue API function.
C#:
C++/CLR:
93
PCAN-UDS API – User Manual
Visual Basic:
See also: GetValue below, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
3.6.10 GetValue
Retrieve information from a PUDS Channel.
Overloads
Function Description
GetValue(TPUDSCANHandle, Retrieves information from a PUDS Channel in numeric form
TPUDSParameter, UInt32, UInt32);
GetValue(TPUDSCANHandle, Retrieves information from a PUD Channel in text form
TPUDSParameter, String, UInt32);
GetValue(TPUDSCANHandle, Retrieves information from a PUDS Channel in byte array form
TPUDSParameter, Byte[], UInt32)
GetValue(TPUDSCANHandle, Retrieves information from a PUDS Channel in pointer form
TPUDSParameter, IntPtr, UInt32)
Syntax
Pascal OO
94
PCAN-UDS API – User Manual
): TPUDSStatus; overload;
C#
C++ / CLR
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UD_GetValue")> _
Public Shared Function GetValue( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPUDSParameter, _
ByVal StringBuffer As StringBuilder, _
ByVal BufferLength As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PCANTP Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
StringBuffer The buffer to return the required string value
BufferLength The length in bytes of the given buffer
Returns
The return value is a TPUDSStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in case
of failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application.
PUDS_ERROR_WRONG_PARAM Indicates that the parameters passed to the method are invalid. Check the value of
'Parameter' and assert it is compatible with a string buffer
95
PCAN-UDS API – User Manual
Example
The following example shows the use of the method GetValue to retrieve the version of the UDS API.
Depending on the result, a message will be shown to the user.
C#
TPUDSStatus result;
StringBuilder BufferString;
C++ / CLR
TPUDSStatus result;
StringBuilder^ BufferString;
Visual Basic
96
PCAN-UDS API – User Manual
Pascal OO
var
result: TPUDSStatus;
BufferString: array [0..256] of Char;
begin
// Get API version
result := TUdsApi.GetValue(TUdsApi.PUDS_NONEBUS, PUDS_PARAM_API_VERSION, BufferString, 255);
if (result <> PUDS_ERROR_OK) then
MessageBox(0, 'Failed to get value', 'Error', MB_OK)
else
MessageBox(0, BufferString, 'Success', MB_OK);
end;
See also: SetValue on page 85, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
Syntax
Pascal OO
C#
C++ / CLR
97
PCAN-UDS API – User Manual
UInt32 BufferLength);
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_GetValue")> _
Public Shared Function GetValue( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPUDSParameter, _
ByRef NumericBuffer As UInt32, _
ByVal BufferLength As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PCANTP Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
NumericBuffer The buffer to return the required numeric value
BufferLength The length in bytes of the given buffer
Returns
The return value is a TPUDSStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in case
of failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application.
PUDS_ERROR_WRONG_PARAM Indicates that the parameters passed to the method are invalid. Check the value of
'Parameter' and assert it is compatible with a string buffer
Example
The following example shows the use of the method GetValue on the channel PUDS_USBBUS1 to retrieve the
ISO‐TP separation time value (STmin). Depending on the result, a message will be shown to the user.
C#
98
PCAN-UDS API – User Manual
C++ / CLR
Visual Basic
' Get the value of the ISO-TP Separation Time (STmin) parameter
result = UDSApi.GetValue(CanChannel, TPUDSParameter.PUDS_PARAM_SEPERATION_TIME, _
iBuffer, Convert.ToUInt32(Len(iBuffer)))
If result <> TPUDSStatus.PUDS_ERROR_OK Then
MessageBox.Show("Failed to get value")
Else
MessageBox.Show(iBuffer.ToString())
End If
Pascal OO
var
CanChannel: TPUDSCANHandle;
result: TPUDSStatus;
iBuffer: UINT;
begin
CanChannel := TUdsApi.PUDS_USBBUS1;
// Get the value of the ISO‐TP Separation Time (STmin) parameter
result := TUdsApi.GetValue(CanChannel, PUDS_PARAM_SEPERATION_TIME, PLongWord(@iBuffer),
sizeof(iBuffer));
if (result <> PUDS_ERROR_OK) then
MessageBox(0, 'Failed to get value', 'Error', MB_OK)
else
MessageBox(0, PAnsiChar(AnsiString(Format('STmin = %d', [Integer(iBuffer)]))), 'Success', MB_OK);
end;
See also: SetValue on page 85, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
99
PCAN-UDS API – User Manual
Syntax
C#
C++ / CLR
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_GetValue")> _
Public Shared Function GetValue( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPUDSParameter, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PCANTP Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
Buffer The buffer containing the array value to retrieve
BufferLength The length in bytes of the given buffer
100
PCAN-UDS API – User Manual
Returns
The return value is a TPCANTPStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in
case of failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel cannot be used because it was not found in the
list of reserved channels of the calling application.
POBDII_ERROR_WRONG_PARAM Indicates that the parameters passed to the method are invalid. Check the value of
'Parameter' and assert it is compatible with a string buffer
Example
The following example shows the use of the method GetValue on the channel PUDS_USBBUS1 to retrieve the
ISO‐TP separation time value (STmin). Depending on the result, a message will be shown to the user.
C#
C++ / CLR
Visual Basic
' Get the value of the ISO-TP Separation Time (STmin) parameter
result = UDSApi.GetValue(CanChannel, TPUDSParameter.PUDS_PARAM_SEPERATION_TIME, _
bufferArray, Convert.ToUInt32(bufferLength)))
If result <> TPUDSStatus.PUDS_ERROR_OK Then
MessageBox.Show("Failed to get value")
Else
101
PCAN-UDS API – User Manual
MessageBox.Show(bufferArray(0).ToString())
End If
Pascal OO
var
CanChannel: TPUDSCANHandle;
result: TPUDSStatus;
bufferArray: array [0..1] of Byte;
begin
CanChannel := TUdsApi.PUDS_USBBUS1;
See also: SetValue on page 85, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
Syntax
C#
C++ / CLR
102
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_GetValue")> _
Public Shared Function GetValue( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPUDSParameter, _
ByVal Buffer As IntPtr, _
ByVal BufferLength As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PCANTP Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
Buffer The buffer containing the array value to retrieve
BufferLength The length in bytes of the given buffer
Returns
The return value is a TPCANTPStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in
case of failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel cannot be used because it was not found in the
list of reserved channels of the calling application.
POBDII_ERROR_WRONG_PARAM Indicates that the parameters passed to the method are invalid. Check the value of
'Parameter' and assert it is compatible with a string buffer
Example
The following example shows the use of the method GetValue on the channel PUDS_USBBUS1 to retrieve the
UDS Session Information. A console message will be written with the information retrieved.
C#:
103
PCAN-UDS API – User Manual
C++/CLR:
Visual Basic:
104
PCAN-UDS API – User Manual
sessionPtr = Marshal.AllocHGlobal(sessionSize)
Marshal.StructureToPtr(sessionInfo, sessionPtr, false)
' Get Session information
result = UDSApi.GetValue(CanChannel, TPUDSParameter.PUDS_PARAM_SESSION_INFO,
sessionPtr, Convert.ToUInt32(sessionSize))
' Get structure from pointer (note: if status is TPUDSStatus.PUDS_NOT_INITIALIZED,
default TIMEOUT values are still returned)
sessionInfo = Marshal.PtrToStructure(sessionPtr, GetType(TPUDSSessionInfo))
Console.WriteLine("Current session information = {0}", sessionInfo.SESSION_TYPE)
Console.WriteLine(" TIMEOUT_P2CAN_SERVER_MAX = {0}",
sessionInfo.TIMEOUT_P2CAN_SERVER_MAX)
' free ressource
Marshal.FreeHGlobal(sessionPtr)
See also: SetValue on page 85, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
3.6.15 GetStatus
Gets the current BUS status of a PUDS Channel.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_GetStatus")> _
Public Shared Function GetStatus( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
105
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
Remarks: When the hardware status is bus‐off, an application cannot communicate anymore. Consider using
the PCAN‐Basic property PCAN_BUSOFF_AUTORESET which instructs the API to automatically reset the CAN
controller when a bus‐off state is detected.
Another way to reset errors like bus‐off, bus‐heavy and bus‐light, is to uninitialize and initialize again the
channel used. This causes a hardware reset.
Example
The following example shows the use of the method GetStatus on the channel PUDS_PCIBUS1. Depending on
the result, a message will be shown to the user.
C#
TPUDSStatus result;
C++ / CLR
TPUDSStatus result;
106
PCAN-UDS API – User Manual
result = CanTpApi::GetStatus(CanTpApi::PUDS_PCIBUS1);
switch (result)
{
case PUDS_ERROR_BUSLIGHT:
MessageBox::Show("PCAN-PCI (Ch-1): Handling a BUS-LIGHT status...");
break;
case PUDS_ERROR_BUSHEAVY:
MessageBox::Show("PCAN-PCI (Ch-1): Handling a BUS-HEAVY status...");
break;
case PUDS_ERROR_BUSOFF:
MessageBox::Show("PCAN-PCI (Ch-1): Handling a BUS-OFF status...");
break;
case PUDS_ERROR_OK:
MessageBox::Show("PCAN-PCI (Ch-1): Status is OK");
break;
default:
// An error occurred);
MessageBox::Show("Failed to retrieve status");
break;
}
Visual Basic
Pascal OO
var
result: TPUDSStatus;
begin
107
PCAN-UDS API – User Manual
See also: TPUDSParameter on page 31, Parameter Value Definitions on page 332.
3.6.16 Read
Reads a CAN UDS message from the receive queue of a PUDS Channel.
Syntax
Pascal OO
C#
C++ / CLR
Visual basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_Read")> _
Public Shared Function Read( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Message Buffer A TPUDSMsg buffer to store the CAN UDS message
108
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
Remarks: The message type (see TPUDSMessageType) of a CAN UDS message indicates if the message is a
complete received UDS message, a transmission confirmation or an indication of a pending message. This value
should be checked every time a message has been read successfully, along with the RESULT value as it contains
the network status of the message.
Note: That higher level functions like WaitForSingleMessage or WaitForService should be preferred in
cases where a client just has to read the response from a service request.
Example
The following example shows the use of the method Read on the channel PUDS_USBBUS1. Depending on the
result, a message will be shown to the user.
C#
TPUDSStatus result;
TPUDSMsg msg;
bool bStop = false;
do
{
// Read the first message in the queue
result = UDSApi.Read(UDSApi.PUDS_USBBUS1, out msg);
if (result == TPUDSStatus.PUDS_ERROR_OK)
{
// Process the received message
MessageBox.Show("A message was received");
ProcessMessage(msg);
}
else
{
// An error occurred
MessageBox.Show("An error ocured");
// Here can be decided if the loop has to be terminated
bStop = HandleReadError(result);
}
} while (!bStop);
109
PCAN-UDS API – User Manual
C++ / CLR
TPUDSStatus result;
TPUDSMsg msg;
bool bStop = false;
do
{
// Read the first message in the queue
result = UDSApi::Read(UDSApi::PUDS_USBBUS1, msg);
if (result == PUDS_ERROR_OK)
{
// Process the received message
MessageBox::Show("A message was received");
//ProcessMessage(msg);
}
else
{
// An error occurred
MessageBox::Show("An error ocured");
// Here can be decided if the loop has to be terminated
//bStop = HandleReadError(result);
}
} while (!bStop);
Visual Basic
Do
' Read the first message in the queue
msg = New TPUDSMsg()
result = UDSApi.Read(UDSApi.PUDS_USBBUS1, msg)
If result = TPUDSStatus.PUDS_ERROR_OK Then
' Process the received message
MessageBox.Show("A message was received")
ProcessMessage(msg)
Else
' An error occurred
MessageBox.Show("An error ocured")
' Here can be decided if the loop has to be terminated
bStop = HandleReadError(result)
End If
Loop While bStop = False
Pascal OO
var
result: TPUDSStatus;
msg: TPUDSMsg;
bStop: Boolean;
begin
bStop := False;
repeat
// Read the first message in the queue
result := TUdsApi.Read(TUdsApi.PUDS_USBBUS1, msg);
110
PCAN-UDS API – User Manual
3.6.17 Write
Transmits a CAN UDS message.
Syntax
Pascal OO
C#
C++ / CLR
111
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_Write")> _
Public Shared Function Write( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Message Buffer A TPUDSMsg buffer containing the CAN UDS message to be sent
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application or that a required CAN ID mapping was not found
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The Write function do not actually send the UDS message, the transmission is asynchronous. Should
a message fail to be transmitted, it will be added to the reception queue with a specific network error code in
the RESULT value of the TPUDSMsg.
Note: To transmit a standard UDS service request, it is recommended to use the corresponding API
Service method starting with Svc (like SvcDiagnosticSessionControl).
Example
The following example shows the use of the method Write on the channel PUDS_USBBUS1. It adds to the
transmit queue a UDS request from source 0xF1 to ECU #1 and then waits until a confirmation message is
received. Depending on the result, a message will be shown to the user.
Note: It is assumed that the channel was already initialized and mapping were configured, the content of
DATA is not initialized in the example.
C#
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
// prepare an 11bit CAN ID, physically addressed UDS message containing 4095 Bytes
of data
request.DATA = new byte[4095];
// [...] fill data
request.LEN = (ushort)request.DATA.Length;
request.MSGTYPE = TPUDSMessageType.PUDS_MESSAGE_TYPE_REQUEST;
112
PCAN-UDS API – User Manual
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++ / CLR
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
// prepare an 11bit CAN ID, physically addressed UDS message containing 4095 Bytes
of data
request->DATA = gcnew array<Byte>(4095);
// [...] fill data
request->LEN = (unsigned short)request->DATA->Length;
request->MSGTYPE = PUDS_MESSAGE_TYPE_REQUEST;
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
113
PCAN-UDS API – User Manual
Visual Basic
' prepare an 11bit CAN ID, physically addressed UDS message containing 4095 bytes
of data
request.DATA = New Byte(4095) {}
' [...] fill data
request.LEN = request.DATA.Length
request.MSGTYPE = TPUDSMessageType.PUDS_MESSAGE_TYPE_REQUEST
request.NETADDRINFO.SA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT
request.NETADDRINFO.TA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL
request.NETADDRINFO.RA = &H0
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B
Pascal OO
var
request: TPUDSMsg;
result: TPUDSStatus;
begin
// prepare an 11bit CAN ID, physically addressed UDS message containing 4095 bytes of data
// […] fill data
request.LEN := Length(request.DATA);
request.MSGTYPE := PUDS_MESSAGE_TYPE_REQUEST;
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
114
PCAN-UDS API – User Manual
MessageBox(0, PAnsiChar(AnsiString(
Format('Read = %d, type=%d, result=%d',
[Integer(result), Integer(request.MSGTYPE), Integer(request.RESULT)]))), 'Error', MB_OK);
until (result = PUDS_ERROR_NO_MESSAGE);
end
else
// An error occurred
MessageBox(0, PAnsiChar(AnsiString(Format('Error occured = %d', [Integer(result)]))), 'Error', MB_OK);
end;
3.6.18 Reset
Resets the receive and transmit queues of a PCUDS Channel.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN‐UDS.dll", EntryPoint:="UDS_Reset")> _
Public Shared Function Reset( _
<MarshalAs(UnmanagedType.U2)> _
ByVal CanChannel As TPUDSCANHandle) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
115
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
Remarks: Calling this method ONLY clears the queues of a Channel. A reset of the CAN controller doesn't take
place.
Example
The following example shows the use of the method Reset on the channel PUDS_PCIBUS1. Depending on the
result, a message will be shown to the user.
C#
TPUDSStatus result;
C++ / CLR
TPUDSStatus result;
Visual Basic
116
PCAN-UDS API – User Manual
Pascal OO
var
result: TPUDSStatus;
begin
// The PCI Channel is reset
result := TUdsApi.Reset(TUdsApi.PUDS_PCIBUS1);
if (result <> PUDS_ERROR_OK) then
// An error occurred
MessageBox(0, 'An error occured', 'Error', MB_OK)
else
MessageBox(0, 'PCAN‐PCI (Ch‐1) was reset', 'Error', MB_OK);
end;
3.6.19 WaitForSingleMessage
Waits for a UDS response or transmit confirmation based on a UDS request.
Syntax
Pascal OO
C#
C++ / CLR
117
PCAN-UDS API – User Manual
UInt32 Timeout);
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_WaitForSingleMessage")> _
Public Shared Function WaitForSingleMessage( _
<MarshalAs(UnmanagedType.U1)> _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByRef MessageRequest As TPUDSMsg, _
ByVal IsWaitForTransmit As Boolean, _
ByVal TimeInterval As UInt32, _
ByVal Timeout As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Message Buffer A TPUDSMsg buffer cto store the UDS message
MessageRequest A TPUDSMsg buffer containing the UDS message that was previously sent
IsWaitForTransmit States whether the message to wait is a transmit confirmation or a UDS response
TimeInterval Time to wait between polling for new UDS messages in milliseconds
Timeout Maximum time to wait (in milliseconds) for a message indication corresponding to the
MessageRequest. Note: a zero value means unlimited time
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_NO_MESSAGE Indicates that no matching message was received in the time given
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
Remarks: The Timeout parameter is ignored once a message indication matching the request is received (i.e.
the first frame of the message). The function will then return once the message is fully received or a network
error occurred.
To prevent unexpected locking, the user can abort the function by calling the function UDS_Reset (class‐
method: Reset).
Note: that the criteria to identify if a response matches the message request is based only on the network
addressing information and the UDS service identifier: if a same service is requested multiple times with
different parameters (like service ReadDataByIdentifier with different Data IDs), the user will have to
ensure that the extra content matches the original request.
Example
The following example shows the use of the method WaitForSingleMessage on the channel PUDS_USBBUS1. It
writes a UDS message on the CAN Bus and waits for the confirmation of the transmition. Depending on the
result, a message will be shown to the user.
118
PCAN-UDS API – User Manual
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg confirmation = new TPUDSMsg();
// prepare an 11bit CAN ID, physically addressed UDS message containing 4095 Bytes
of data
request.DATA = new byte[4095];
// [...] fill data
request.LEN = (ushort)request.DATA.Length;
request.MSGTYPE = TPUDSMessageType.PUDS_MESSAGE_TYPE_REQUEST;
request.LEN = (ushort)request.DATA.Length;
request.MSGTYPE = TPUDSMessageType.PUDS_MESSAGE_TYPE_REQUEST;
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ confirmation = gcnew TPUDSMsg();
// prepare an 11bit CAN ID, physically addressed UDS message containing 4095 Bytes
of data
request->DATA = gcnew array<Byte>(4095);
// [...] fill data
request->LEN = (unsigned short)request->DATA->Length;
request->MSGTYPE = PUDS_MESSAGE_TYPE_REQUEST;
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
119
PCAN-UDS API – User Manual
Visual Basic:
' prepare an 11bit CAN ID, physically addressed UDS message containing 4095 Bytes
of data
request.DATA = New Byte(4095) {}
' [...] fill data
request.LEN = request.DATA.Length
request.MSGTYPE = TPUDSMessageType.PUDS_MESSAGE_TYPE_REQUEST
request.NETADDRINFO.SA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT
request.NETADDRINFO.TA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL
request.NETADDRINFO.RA = &H0
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B
Else
' An error occurred
MessageBox.Show("Error occured: " + result.ToString())
End If
120
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
confirmation: TPUDSMsg;
result: TPUDSStatus;
begin
// prepare an 11bit CAN ID, physically addressed UDS message containing 4095 bytes of data
// […] fill data
request.LEN := Length(request.DATA);
request.MSGTYPE := PUDS_MESSAGE_TYPE_REQUEST;
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B ;
3.6.20 WaitForMultipleMessage
Waits for multiple UDS responses based on a UDS request (multiple responses can be obtained when a
functional UDS request is transmitted).
Syntax
Pascal OO
121
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_WaitForMultipleMessage")> _
Public Shared Function WaitForMultipleMessage( _
<MarshalAs(UnmanagedType.U1)> _
ByVal CanChannel As TPUDSCANHandle, _
<[In](), Out()> ByVal Buffer As TPUDSMsg(), _
ByVal MaxCount As UInt32, _
ByRef pCount As UInt32, _
ByRef MessageRequest As TPUDSMsg, _
ByVal TimeInterval As UInt32, _
ByVal Timeout As UInt32, _
ByVal TimeoutEnhanced As UInt32, _
ByVal WaitUntilTimeout As Boolean) As TPUDSStatus
End Function
122
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Buffer A buffer to store an array of TPUDSMsge
MaxCount The maximum number of expected responses
pCount Buffer to store the actual number of received responses
MessageRequest A TPUDSMsg buffer containing the UDS message that was previously sent.
TimeInterval Time to wait between polling for new UDS messages in milliseconds.
Timeout Maximum time to wait (in milliseconds) for a message indication corresponding to the
MessageRequest. Note: a zero value means unlimited time.
TimeoutEnhanced Maximum time to wait (in milliseconds) for a message indication corresponding to the
MessageRequest if an ECU asks for extended timing (NRC_EXTENDED_TIMING)
WaitUntilTimeout States whether the function is interrupted if the number of received messages reaches MaxCount
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_NO_MESSAGE Indicates that no matching message was received in the time given
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_OVERFLOW Success but the buffer limit was reached. Check pCount variable to see how many
messages were discarded
Remarks: For each response, the Timeout/TimeoutEnhanced parameter is ignored once a message indication
matching the request is received (i.e. the first frame of the message). The function will then return once all
messages are fully received or a network error occurred.
To prevent unexpected locking, the user can abort the function by calling the function UDS_Reset (class‐
method: Reset).
Note: That the criteria to identify if a response matches the message request is based only on the
network addressing information and the UDS service identifier: if a same service is requested multiple
times with different parameters (like service ReadDataByIdentifier with different Data IDs), the user will
have to ensure that the extra content matches the original request.
The function handles the negative response code PUDS_NRC_EXTENDED_TIMING (0x78) in order to fetch all
responses at the same time: if such a response is read, the function will switch the default timeout to
TimeoutEnhanced and wait for a new response.
Example
The following example shows the use of the method WaitForMultipleMessage on the channel PUDS_ USBBUS1.
It writes a UDS functional message on the CAN Bus, waits for the confirmation of the transmission and then
waits to receive responses from ECUs until timeout occurs. Depending on the result, a message will be shown
to the user.
123
PCAN-UDS API – User Manual
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg confirmation = new TPUDSMsg();
UInt32 MessageArraySize = 5;
TPUDSMsg[] MessageArray = new TPUDSMsg[MessageArraySize];
uint count = 0;
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_FUNCTIONAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ confirmation = gcnew TPUDSMsg();
UInt32 MessageArraySize = 5;
array<TPUDSMsg>^ MessageArray = gcnew array<TPUDSMsg>(MessageArraySize);
UInt32 count;
124
PCAN-UDS API – User Manual
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_FUNCTIONAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
request.NETADDRINFO.SA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT
request.NETADDRINFO.TA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_FUNCTIONAL
request.NETADDRINFO.RA = &H0
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B
125
PCAN-UDS API – User Manual
Else
' An error occurred
MessageBox.Show("Error occured: " + result.ToString())
End If
Pascal OO:
var
request: TPUDSMsg;
confirmation: TPUDSMsg;
result: TPUDSStatus;
MessageArraySize: LongWord;
MessageArray: array[0..4] of TPUDSMsg;
count: LongWord;
begin
MessageArraySize := 5;
// prepare an 11bit CAN ID, functionnaly addressed UDS message
// […] fill data data (functional message is limited to 1 CAN frame)
request.LEN := 7;
request.MSGTYPE := PUDS_MESSAGE_TYPE_REQUEST;
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_FUNCTIONAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B ;
126
PCAN-UDS API – User Manual
3.6.21 WaitForService
Handles the communication workflow for a UDS service expecting a single response. The function waits for a
transmit confirmation then for a message response.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_WaitForService")> _
127
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Message Buffer A TPUDSMsg buffer to store the UDS response
MessageRequest A TPUDSMsg buffer containing the UDS message that was previously sent.
MessageReqBuffer A TPUDSMsg buffer to store the UDS transmit confirmation
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_NO_MESSAGE Indicates that no matching message was received in the time given
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_CAN_ERROR A network error occured either in the transmit confirmation or the response message
Remarks: The WaitForService function is a utility function that calls other UDS API functions to simplify UDS
communication workflow:
The function gets the defined timeouts (global API request and response timeouts and timeouts defined by
the current session information with the ECU),
Waits for the confirmation of request’s transmition,
On success, waits for the response confirmation.
If a negative response code is received stating that the ECU requires extended timing
(PUDS_NRC_EXTENDED_TIMING, 0x78), the function switches to the enhanced timeout and waits for
another response.
The function ProcessResponse is called automatically on the response.
Even if the SuppressPositiveResponseMessage flag is set in the UDS request, the function will still wait for an
eventual Negative Response. If no error message is received the function will return
PUDS_ERROR_NO_MESSAGE, although in this case it is must not be considered as an error. Moreover if a
negative response code PUDS_NRC_EXTENDED_TIMING is received the SuppressPositiveResponseMessage flag
is ignored as stated in ISO‐14229‐1.
Example
The following example shows the use of the method WaitForService on the channel PUDS_USBBUS1. A UDS
physical service request is transmitted (service ECUReset), and the WaitForService function is called to get the
response. Depending on the result, a message will be shown to the user.
128
PCAN-UDS API – User Manual
C# :
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
' initialization
request.NETADDRINFO.SA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT
request.NETADDRINFO.TA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1
129
PCAN-UDS API – User Manual
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL
request.NETADDRINFO.RA = &H0
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B ;
3.6.22 WaitForServiceFunctional
Handles the communication workflow for a UDS service requested with functional addressing, i.e. multiple
responses can be expected. The function waits for a transmit confirmation then for responses.
130
PCAN-UDS API – User Manual
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_WaitForServiceFunctional")> _
Public Shared Function WaitForServiceFunctional( _
<MarshalAs(UnmanagedType.U1)> _
ByVal CanChannel As TPUDSCANHandle, _
<[In](), Out()> ByVal Buffer As TPUDSMsg(), _
ByVal MaxCount As UInt32, _
ByRef pCount As UInt32, _
ByVal WaitUntilTimeout As Boolean, _
ByRef MessageRequest As TPUDSMsg, _
ByRef MessageReqBuffer As TPUDSMsg) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Buffer A buffer to store an array of TPUDSMsg
MaxCount The maximum number of expected responses
131
PCAN-UDS API – User Manual
Parameters Description
pCount Buffer to store the actual number of received responses
WaitUntilTimeout States whether the function is interrupted if the number of received messages reaches MaxCount
MessageRequest A TPUDSMsg buffer containing the UDS message that was previously written
MessageReqBuffer A TPUDSMsg buffer to store the UDS transmit confirmation
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_NO_MESSAGE Indicates that no matching message was received in the time given
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_OVERFLOW Success but the buffer limit was reached. Check pCount variable to see how many
messages were discarded
Remarks: The WaitForServiceFunctional function is a utility function that calls other UDS API functions to
simplify UDS communication workflow when requests involve functional addressing.
The function gets the defined timeouts (global API request and response timeouts and timeouts defined by
the current session information with the ECU),
Waits for the confirmation of request’s transmition.
On success, it waits for the confirmations of the responses like the function WaitForMultipleMessage
would.
Example
The following example shows the use of the method WaitForServiceFunctional on the channel PUDS_USBBUS1.
A UDS functional service request is transmitted (service ECUReset), and the WaitForServiceFunctional function
is called to get the responses. Depending on the result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
UInt32 MessageArraySize = 5;
TPUDSMsg[] MessageArray = new TPUDSMsg[MessageArraySize];
uint count = 0;
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_FUNCTIONAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
132
PCAN-UDS API – User Manual
if (result == TPUDSStatus.PUDS_ERROR_OK)
result = UDSApi.WaitForServiceFunctional(UDSApi.PUDS_USBBUS1, MessageArray,
MessageArraySize, out count, true, ref request, out requestConfirmation);
if (count > 0)
MessageBox.Show(String.Format("Received messages count = {0}.", count));
else
// An error occurred
MessageBox.Show(String.Format("Error occured: {0}", (int)result));
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
UInt32 MessageArraySize = 5;
array<TPUDSMsg>^ MessageArray = gcnew array<TPUDSMsg>(MessageArraySize);
UInt32 count;
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_FUNCTIONAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
else
// An error occurred
MessageBox::Show(String::Format("Error occured: {0}", (int)result));
Visual Basic:
' initialization
request.NETADDRINFO.SA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT
request.NETADDRINFO.TA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_FUNCTIONAL
request.NETADDRINFO.RA = &H0
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B
133
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
MessageArraySize: LongWord;
MessageArray: array[0..4] of TPUDSMsg;
count: LongWord;
begin
// initialization
MessageArraySize := 5;
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B ;
See also: WaitForSingleMessage on page 117, WaitForMultipleMessage on page 121, ProcessResponse below.
3.6.23 ProcessResponse
Processes a UDS response message to manage ISO‐14229/15765 features, like session information.
Syntax
Pascal OO
134
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_ProcessResponse")> _
Public Shared Function ProcessResponse( _
<MarshalAs(UnmanagedType.U1)> _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A TPUDSMsg buffer to store the UDS response
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_WRONG_PARAM MessageBuffer is not valid (data length is zero or the network result indicates an error)
Remarks: The purpose of this function is to update internal UDS settings of the API: currently only the
responses to DiagnosticSessionControl requests require this processing as they contain information on the
active session.
Example
The following example shows the use of the method ProcessResponse on the channel PUDS_USBBUS1. It writes
a UDS physical request (service DiagnosticSessionControl) on the CAN Bus, waits for the confirmation of the
transmission and then waits to receive a response. Once received the ProcessResponse function is called on the
received message, updating the session information inside the API.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg confirmation = new TPUDSMsg();
135
PCAN-UDS API – User Manual
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
136
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ confirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_FUNCTIONAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
' initialization
request.NETADDRINFO.SA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT
request.NETADDRINFO.TA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL
137
PCAN-UDS API – User Manual
request.NETADDRINFO.RA = &H0
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B
Pascal OO:
var
request: TPUDSMsg;
confirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B ;
138
PCAN-UDS API – User Manual
begin
// wait for the responses
result := TUdsApi.WaitForSingleMessage(TUdsApi.PUDS_USBBUS1, response, confirmation, false, 10,
100);
if (result = PUDS_ERROR_OK) then
begin
result := TUdsApi.ProcessResponse(TUdsApi.PUDS_USBBUS1, response);
MessageBox(0, 'Received messages', 'Success', MB_OK);
end
else
// An error occurred
MessageBox(0, 'An error occured while waiting for response', 'Error', MB_OK);
end
else
// An error occurred
MessageBox(0, 'An error occured while waiting for transmit confirmation', 'Error', MB_OK);
end
else
// An error occurred
MessageBox(0, 'An error occured', 'Error', MB_OK)
end;
3.6.24 SvcDiagnosticSessionControl
Writes a UDS request according to the DiagnosticSessionControl service’s specifications.
The DiagnosticSessionControl service is used to enable different diagnostic sessions in the server.
Syntax
Pascal OO
C#
C++ / CLR
139
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcDiagnosticSessionControl")> _
Public Shared Function SvcDiagnosticSessionControl( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal SessionType As TPUDSSvcParamDSC) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
SessionType Subfunction parameter: type of the session (see TPUDSSvcParamDSC)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
If this service is called with the NO_POSITIVE_RESPONSE_MSG parameter of the MessageBuffer set to ignore
responses (i.e. value PUDS_SUPPR_POS_RSP_MSG_INDICATION_BIT), the API will automatically change the
current session to the new one.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
140
PCAN-UDS API – User Manual
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
141
PCAN-UDS API – User Manual
End If
If (result = TPUDSStatus.PUDS_ERROR_OK) Then
MessageBox.Show(String.Format("Response was received."))
Else
' An error occurred
MessageBox.Show(String.Format("Error occured: {0}", result.ToString()))
End If
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.25 SvcECUReset
Writes a UDS request according to the ECUReset service’s specifications.
Syntax
Pascal OO
142
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcECUReset")> _
Public Shared Function SvcECUReset( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal ResetType As TPUDSSvcParamER) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
ResetType Subfunction parameter: type of Reset (see TPUDSSvcParamER)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
143
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
144
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
145
PCAN-UDS API – User Manual
3.6.26 SvcSecurityAccess
Writes a UDS request according to the SecurityAccess service’s specifications.
SecurityAccess service provides a mean to access data and/or diagnostic services which have restricted access
for security, emissions or safety reasons.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcSecurityAccess")> _
Public Shared Function SvcSecurityAccess( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal SecurityAccessType As Byte, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
SecurityAccessType Subfunction parameter: type of SecurityAccess (see PUDS_SVC_PARAM_SA_xxx definitions)
146
PCAN-UDS API – User Manual
Parameters Description
Buffer If Requesting Seed, buffer is the optional data to transmit to a server (like identification). If Sending
Key, data holds the value generated by the security algorithm corresponding to a specific “seed”
value
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
147
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
148
PCAN-UDS API – User Manual
result: TPUDSStatus;
buffer: array[0..3] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
See also: WaitForService on page 127, PCAN‐UDS Service Parameter Definitions on page 334: SecurityAccess.
3.6.27 SvcCommunicationControl
Writes a UDS request according to the CommunicationControl service’s specifications.
CommunicationControl service's purpose is to switch on/off the transmission and/or the reception of certain
messages of (a) server(s).
Syntax
Pascal OO
C#
149
PCAN-UDS API – User Manual
TPUDSSvcParamCC ControlType,
byte CommunicationType);
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcCommunicationControl")> _
Public Shared Function SvcCommunicationControl( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal ControlType As TPUDSSvcParamCC, _
ByVal CommunicationType As Byte) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
ControlType Subfunction parameter: type of CommunicationControl (see TPUDSSvcParamCC)
CommunicationType A bit‐code value to reference the kind of communication to be controlled, see
PUDS_SVC_PARAM_CC_FLAG_xxx flags and ISO_14229‐2006 §B.1 for bit‐encoding
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
150
PCAN-UDS API – User Manual
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
151
PCAN-UDS API – User Manual
request.NETADDRINFO.SA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT
request.NETADDRINFO.TA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL
request.NETADDRINFO.RA = &H0
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
See also: WaitForService on page 127, PCAN‐UDS Service Parameter Definitions on page 334:
CommunicationControl.
152
PCAN-UDS API – User Manual
3.6.28 SvcTesterPresent
Writes a UDS request according to the TesterPresent service’s specifications.
TesterPresent service indicates to a server (or servers) that a client is still connected to the vehicle and that
certain diagnostic services and/or communications that have been previously activated are to remain active.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcTesterPresent")> _
Public Shared Function SvcTesterPresent( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal TesterPresentType As TPUDSSvcParamTP) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
TesterPresentType No Subfunction parameter by default (PUDS_SVC_PARAM_TP_ZSUBF)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
153
PCAN-UDS API – User Manual
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
154
PCAN-UDS API – User Manual
if (result == PUDS_ERROR_OK)
result = UDSApi::WaitForService(UDSApi::PUDS_USBBUS1, *response, *request,
*requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox::Show(String::Format("Response was received."));
else
// An error occurred
MessageBox::Show(String::Format("Error occured: {0}", (int)result));
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
155
PCAN-UDS API – User Manual
3.6.29 SvcSecuredDataTransmission
Writes a UDS request according to the SecuredDataTransmission service’s specifications.
SecuredDataTransmission service's purpose is to transmit data that is protected against attacks from third
parties, which could endanger data security.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcSecuredDataTransmission")> _
Public Shared Function SvcSecuredDataTransmission( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
156
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
Buffer buffer containing the data as processed by the Security Sub‐Layer (See ISO‐15764)
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
157
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
158
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffer: array[0..3] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.30 SvcControlDTCSetting
Writes a UDS request according to the ControlDTCSetting service’s specifications.
ControlDTCSetting service shall be used by a client to stop or resume the setting of diagnostic trouble codes
(DTCs) in the server(s).
Syntax
Pascal OO
159
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcControlDTCSetting")> _
Public Shared Function SvcControlDTCSetting( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DTCSettingType As TPUDSSvcParamCDTCS, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DTCSettingType Subfunction parameter (see TPUDSSvcParamCDTCS)
Buffer This parameter record is user‐optional and transmits data to a server when controlling the DTC
setting. It can contain a list of DTCs to be turned on or off
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
160
PCAN-UDS API – User Manual
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
161
PCAN-UDS API – User Manual
else
// An error occurred
MessageBox::Show(String::Format("Error occured: {0}", (int)result));
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffer: array[0..3] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
162
PCAN-UDS API – User Manual
3.6.31 SvcResponseOnEvent
Writes a UDS request according to the ResponseOnEvent service’s specifications.
The ResponseOnEvent service requests a server to start or stop transmission of responses on a specified event.
Syntax
Pascal OO
C#
C++ / CLR
163
PCAN-UDS API – User Manual
bool StoreEvent,
Byte EventWindowTime,
array<Byte>^ EventTypeRecord,
unsigned short EventTypeRecordLength,
array<Byte>^ ServiceToRespondToRecord,
unsigned short ServiceToRespondToRecordLength);
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcResponseOnEvent")> _
Public Shared Function SvcResponseOnEvent( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal EventType As TPUDSSvcParamROE, _
ByVal StoreEvent As Boolean, _
ByVal EventWindowTime As Byte, _
ByVal EventTypeRecord As Byte(), _
ByVal EventTypeRecordLength As UShort, _
ByVal ServiceToRespondToRecord As Byte(), _
ByVal ServiceToRespondToRecordLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
EventType Subfunction parameter: event type (see TPUDSSvcParamROE).
StoreEvent Storage State (TRUE = Store Event, FALSE = Do Not Store Event)
EventWindowTime Specify a window for the event logic to be active in the server (see also
PUDS_SVC_PARAM_ROE_EWT_ITTR)
EventTypeRecord Additional parameters for the specified eventType
EventTypeRecordLength Size in bytes of the EventType Record (see PUDS_SVC_PARAM_ROE_xxx_LEN definitions)
ServiceToRespondToRecord Service parameters, with first byte as service Id (see TPUDSSvcParamROERecommendedServiceID)
ServiceToRespondToRecordLength Size in bytes of the ServiceToRespondTo Record
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
164
PCAN-UDS API – User Manual
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
165
PCAN-UDS API – User Manual
Visual Basic:
UDSApi.TPUDSSvcParamRDTCI.PUDS_SVC_PARAM_RDTCI_RNODTCBSM, _
&H01}
result = UDSApi.SvcResponseOnEvent(UDSApi.PUDS_USBBUS1, request,
UDSApi.TPUDSSvcParamROE.PUDS_SVC_PARAM_ROE_ONDTCS, _
false, &H1A, evTypeBuffer, evTypeBuffer.Length, siResponseBuffer,
siResponseBuffer.Length)
If (result = TPUDSStatus.PUDS_ERROR_OK) Then
result = UDSApi.WaitForService(UDSApi.PUDS_USBBUS1, response, request,
requestConfirmation)
End If
If (result = TPUDSStatus.PUDS_ERROR_OK) Then
MessageBox.Show(String.Format("Response was received."))
Else
' An error occurred
MessageBox.Show(String.Format("Error occured: {0}", result.ToString()))
End If
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
evTypeBuffer: array[0..0] of Byte;
siResponseBuffer: array[0..2] of Byte;
166
PCAN-UDS API – User Manual
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
See also: WaitForService on page 127, PCAN‐UDS Service Parameter Definitions on page 334:
ResponseOnEvent on page 334.
3.6.32 SvcLinkControl
Writes a UDS request according to the LinkControl service’s specifications.
The LinkControl service is used to control the communication link baud rate between the client and
the server(s) for the exchange of diagnostic data.
Syntax
Pascal OO
167
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcLinkControl")> _
Public Shared Function SvcLinkControl( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal LinkControlType As TPUDSSvcParamLC, _
ByVal BaudrateIdentifier As Byte, _
ByVal LinkBaudrate As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
LinkControlType Subfunction parameter: Link Control Type (see TPUDSSvcParamLC).
BaudrateIdentifier Defined baud rate identifier (see TPUDSSvcParamLCBaudrateIdentifier)
LinkBaudrate Used only with PUDS_SVC_PARAM_LC_VBTWSBR parameter: a three‐byte value baud rate
(baudrate High, Middle and Low Bytes)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
168
PCAN-UDS API – User Manual
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
169
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
170
PCAN-UDS API – User Manual
3.6.33 SvcReadDataByIdentifier
Writes a UDS request according to the ReadDataByIdentifier service’s specifications.
The ReadDataByIdentifier service allows the client to request data record values from the server identified by
one or more dataIdentifiers.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDataByIdentifier")> _
Public Shared Function SvcReadDataByIdentifier( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal Buffer As UShort(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
Buffer Buffer containing a list of two‐byte Data Identifiers (see TPUDSSvcParamDI).
BufferLength Number of elements in the buffer (size in WORD of the buffer)
171
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
172
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
173
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffer: array[0..1] of Word;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.34 SvcReadMemoryByAddress
Writes a UDS request according to the ReadMemoryByAddress service’s specifications.
The ReadMemoryByAddress service allows the client to request memory data from the server via a provided
starting address and to specify the size of memory to be read.
Syntax
Pascal OO
174
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadMemoryByAddress")> _
Public Shared Function SvcReadMemoryByAddress( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal MemoryAddress As Byte(), _
ByVal MemoryAddressLength As Byte, _
ByVal MemorySize As Byte(), _
ByVal MemorySizeLength As Byte) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
MemoryAddress Starting address of server memory from which data is to be retrieved
MemoryAddressLength Size in bytes of the MemoryAddress buffer (max.: 0xF)
MemorySize Number of bytes to be read starting at the address specified by memoryAddress
MemorySizeLength Size in bytes of the MemorySize buffer (max.: 0xF)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
175
PCAN-UDS API – User Manual
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
176
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
lBufferAddr: array[0..3] of Byte;
lBufferSize: array[0..1] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
177
PCAN-UDS API – User Manual
lBufferAddr[1] := $A1;
lBufferAddr[2] := $00;
lBufferAddr[3] := $13;
lBufferSize[0] := $01;
lBufferSize[1] := $11;
result := TUdsApi.SvcReadMemoryByAddress(TUdsApi.PUDS_USBBUS1, request,
@lBufferAddr, Length(lBufferAddr), @lBufferSize, Length(lBufferSize));
if (result = PUDS_ERROR_OK) then
result := TUdsApi.WaitForService(TUdsApi.PUDS_USBBUS1, response, request,
PTPUDSMsg(@requestConfirmation));
if (result = PUDS_ERROR_OK) then
MessageBox(0, 'Response was received.', 'Success', MB_OK)
else
// An error occurred
MessageBox(0, 'An error occured', 'Error', MB_OK)
end;
3.6.35 SvcReadScalingDataByIdentifier
Writes a UDS request according to the ReadScalingDataByIdentifier service’s specifications.
The ReadScalingDataByIdentifier service allows the client to request scaling data record information from the
server identified by a dataIdentifier.
Syntax
Pascal OO
C#
C++ / CLR
178
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadScalingDataByIdentifier")> _
Public Shared Function SvcReadScalingDataByIdentifier( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DataIdentifier As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
179
PCAN-UDS API – User Manual
if (result == TPUDSStatus.PUDS_ERROR_OK)
MessageBox.Show(String.Format("Response was received."));
else
// An error occurred
MessageBox.Show(String.Format("Error occured: {0}", (int)result));
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
180
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.36 SvcReadDataByPeriodicIdentifier
Writes a UDS request according to the ReadDataByPeriodicIdentifier service’s specifications.
The ReadDataByPeriodicIdentifier service allows the client to request the periodic transmission of data record
values from the server identified by one or more periodicDataIdentifiers.
Syntax
Pascal OO
181
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDataByPeriodicIdentifier")> _
Public Shared Function SvcReadDataByPeriodicIdentifier( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal TransmissionMode As TPUDSSvcParamRDBPI, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
TransmissionMode Transmission rate code (see TPUDSSvcParamRDBPI).
Buffer Buffer containing a list of Periodic Data Identifiers.
BufferLength Number of elements in the buffer (size in WORD of the buffer)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
182
PCAN-UDS API – User Manual
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
183
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffer: array[0..0] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
184
PCAN-UDS API – User Manual
else
// An error occurred
MessageBox(0, 'An error occured', 'Error', MB_OK)
end;
3.6.37 SvcDynamicallyDefineDataIdentifierDBID
Writes a UDS request according to the DynamicallyDefineDataIdentifier service’s specifications.
The DynamicallyDefineDataIdentifier service allows the client to dynamically define in a server a data identifier
that can be read via the ReadDataByIdentifier service at a later time. The Define By Identifier subfunction
specifies that definition of the dynamic data identifier shall occur via a data identifier reference.
Syntax
Pascal OO
C#
[DllImport("PCAN-UDS.dll", EntryPoint =
"UDS_SvcDynamicallyDefineDataIdentifierDBID")]
public static extern TPUDSStatus SvcDynamicallyDefineDataIdentifierDBID(
TPUDSCANHandle CanChannel,
ref TPUDSMsg MessageBuffer,
ushort DynamicallyDefinedDataIdentifier,
byte[] SourceDataIdentifier,
byte[] MemorySize,
byte[] PositionInSourceDataRecord,
ushort BuffersLength);
C++ / CLR
[DllImport("PCAN-UDS.dll", EntryPoint =
"UDS_SvcDynamicallyDefineDataIdentifierDBID")]
static TPUDSStatus SvcDynamicallyDefineDataIdentifierDBID(
TPUDSCANHandle CanChannel,
TPUDSMsg %MessageBuffer,
unsigned short DynamicallyDefinedDataIdentifier,
array<Byte>^ SourceDataIdentifier,
array<Byte>^ MemorySize,
array<Byte>^ PositionInSourceDataRecord,
unsigned short BuffersLength);
185
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN-UDS.dll",
EntryPoint:="UDS_SvcDynamicallyDefineDataIdentifierDBID")> _
Public Shared Function SvcDynamicallyDefineDataIdentifierDBID( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DynamicallyDefinedDataIdentifier As UShort, _
ByVal SourceDataIdentifier As Byte(), _
ByVal MemorySize As Byte(), _
ByVal PositionInSourceDataRecord As Byte(), _
ByVal BuffersLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DynamicallyDefinedDataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
SourceDataIdentifier buffer containing the sources of information to be included into the dynamic data record
MemorySize buffer containing the total numbers of bytes from the source data record address
PositionInSourceDataRecord buffer containing the starting byte positions of the excerpt of the source data record
BuffersLength Number of elements in the buffers (SourceDataIdentifier, MemoryAddress and
PositionInSourceDataRecord)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
186
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
187
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
bufferSize: Word;
lBufferSourceDI: array[0..4] of Word;
lBufferMemSize: array[0..4] of Byte;
lBufferPosInSrc: array[0..4] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
188
PCAN-UDS API – User Manual
3.6.38 SvcDynamicallyDefineDataIdentifierDBMA
Writes a UDS request according to the DynamicallyDefineDataIdentifier service’s specifications.
The DynamicallyDefineDataIdentifier service allows the client to dynamically define in a server a data identifier
that can be read via the ReadDataByIdentifier service at a later time. The Define By Memory Address
subfunction specifies that definition of the dynamic data identifier shall occur via an address reference.
Syntax
Pascal OO
C#
[DllImport("PCAN-UDS.dll", EntryPoint =
"UDS_SvcDynamicallyDefineDataIdentifierDBMA")]
public static extern TPUDSStatus SvcDynamicallyDefineDataIdentifierDBMA(
TPUDSCANHandle CanChannel,
ref TPUDSMsg MessageBuffer,
ushort DynamicallyDefinedDataIdentifier,
byte MemoryAddressLength,
byte MemorySizeLength,
byte[] MemoryAddressBuffer,
byte[] MemorySizeBuffer,
ushort BuffersLength);
189
PCAN-UDS API – User Manual
C++ / CLR
[DllImport("PCAN-UDS.dll", EntryPoint =
"UDS_SvcDynamicallyDefineDataIdentifierDBMA")]
static TPUDSStatus SvcDynamicallyDefineDataIdentifierDBMA(
TPUDSCANHandle CanChannel,
TPUDSMsg %MessageBuffer,
unsigned short DynamicallyDefinedDataIdentifier,
Byte MemoryAddressLength,
Byte MemorySizeLength,
array<Byte>^ MemoryAddressBuffer,
array<Byte>^ MemorySizeBuffer,
unsigned short BuffersLength);
Visual Basic
<DllImport("PCAN-UDS.dll",
EntryPoint:="UDS_SvcDynamicallyDefineDataIdentifierDBMA")> _
Public Shared Function SvcDynamicallyDefineDataIdentifierDBMA( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DynamicallyDefinedDataIdentifier As UShort, _
ByVal MemoryAddressLength As Byte, _
ByVal MemorySizeLength As Byte, _
ByVal MemoryAddressBuffer As Byte(), _
ByVal MemorySizeBuffer As Byte(), _
ByVal BuffersLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DynamicallyDefinedDataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
MemoryAddressLength Size in bytes of the MemoryAddress items in the MemoryAddressBuffer buffer (max.: 0xF)
MemorySizeLength Size in bytes of the MemorySize items in the MemorySizeBuffer buffer (max.: 0xF)
MemoryAddressBuffer Buffer containing the MemoryAddress buffers, must be an array of 'BuffersLength' entries which
contains 'MemoryAddressLength' bytes (size is 'BuffersLength * MemoryAddressLength' bytes)
MemorySizeBuffer Buffer containing the MemorySize buffers, must be an array of 'BuffersLength' entries which
contains 'MemorySizeLength' bytes (size is 'BuffersLength * MemorySizeLength' bytes)
BuffersLength Size in bytes of the MemoryAddressBuffer and MemorySizeBuffer buffers
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
190
PCAN-UDS API – User Manual
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
191
PCAN-UDS API – User Manual
192
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffLen: Byte;
buffAddrLen: Byte;
buffSizeLen: Byte;
lBuffsAddr: array[0..14] of Byte; // buffLen * buffAddrLen
lBuffsSize: array[0..8] of Byte; // buffLen * buffSizeLen
i, j: Word;
begin
193
PCAN-UDS API – User Manual
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.39 SvcDynamicallyDefineDataIdentifierCDDDI
Writes a UDS request according to the Clear Dynamically Defined Data Identifier service’s specifications.
The Clear Dynamically Defined Data Identifier subfunction shall be used to clear the specified dynamic data
identifier.
Syntax
Pascal OO
194
PCAN-UDS API – User Manual
C#
[DllImport("PCAN-UDS.dll", EntryPoint =
"UDS_SvcDynamicallyDefineDataIdentifierCDDDI")]
public static extern TPUDSStatus SvcDynamicallyDefineDataIdentifierCDDDI(
TPUDSCANHandle CanChannel,
ref TPUDSMsg MessageBuffer,
ushort DynamicallyDefinedDataIdentifier);
C++ / CLR
[DllImport("PCAN-UDS.dll", EntryPoint =
"UDS_SvcDynamicallyDefineDataIdentifierCDDDI")]
static TPUDSStatus SvcDynamicallyDefineDataIdentifierCDDDI(
TPUDSCANHandle CanChannel,
TPUDSMsg %MessageBuffer,
unsigned short DynamicallyDefinedDataIdentifier);
Visual Basic
<DllImport("PCAN-UDS.dll",
EntryPoint:="UDS_SvcDynamicallyDefineDataIdentifierCDDDI")> _
Public Shared Function SvcDynamicallyDefineDataIdentifierCDDDI( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DynamicallyDefinedDataIdentifier As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DynamicallyDefinedDataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
195
PCAN-UDS API – User Manual
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
196
PCAN-UDS API – User Manual
request.NETADDRINFO.TA = TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL
request.NETADDRINFO.RA = &H0
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
197
PCAN-UDS API – User Manual
3.6.40 SvcWriteDataByIdentifier
Writes a UDS request according to the WriteDataByIdentifier service’s specifications.
The WriteDataByIdentifier service allows the client to write information into the server at an internal location
specified by the provided data identifier.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcWriteDataByIdentifier")> _
Public Shared Function SvcWriteDataByIdentifier( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DataIdentifier As UShort, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
Buffer Buffer containing the data to write.
BufferLength Size in bytes of the buffer.
198
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
199
PCAN-UDS API – User Manual
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
200
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffer: array[0..2] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.41 SvcWriteMemoryByAddress
Writes a UDS request according to the WriteMemoryByAddress service’s specifications.
The WriteMemoryByAddress service allows the client to write information into the server at one or more
contiguous memory locations.
Syntax
Pascal OO
201
PCAN-UDS API – User Manual
MemoryAddressLength: Byte;
MemorySize: PByte;
MemorySizeLength: Byte;
Buffer: PByte;
BufferLength: Word): TPUDSStatus;
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcWriteMemoryByAddress")> _
Public Shared Function SvcWriteMemoryByAddress( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DataIdentifier As UShort, _
ByVal MemoryAddress As Byte(), _
ByVal MemoryAddressLength As Byte, _
ByVal MemorySize As Byte(), _
ByVal MemorySizeLength As Byte, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
MemoryAddress Starting address of server memory to which data is to be written
MemoryAddressLength Size in bytes of the MemoryAddress buffer (max.: 0xF)
MemorySize Number of bytes to be written starting at the address specified by memoryAddress
202
PCAN-UDS API – User Manual
Parameters Description
MemorySizeLength Size in bytes of the MemorySize buffer (max.: 0xF)
Buffer Buffer containing the data to write
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
203
PCAN-UDS API – User Manual
// An error occurred
MessageBox.Show(String.Format("Error occured: {0}", (int)result));
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
204
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
lBufferAddr: array[0..3] of Byte;
lBufferSize: array[0..1] of Byte;
lBuffer: array[0..$105] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
205
PCAN-UDS API – User Manual
3.6.42 SvcClearDiagnosticInformation
Writes a UDS request according to the ClearDiagnosticInformation service’s specifications.
The ClearDiagnosticInformation service is used by the client to clear diagnostic information in one server's or
multiple servers’ memory.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcClearDiagnosticInformation")> _
Public Shared Function SvcClearDiagnosticInformation( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal groupOfDTC As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
groupOfDTC A three‐byte value indicating the group of DTCs (e.g. powertrain, body, chassis) or the particular
DTC to be cleared (see PUDS_SVC_PARAM_CDI_xxx definitions)
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
206
PCAN-UDS API – User Manual
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
207
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
208
PCAN-UDS API – User Manual
See also: WaitForService on page 127, PCAN‐UDS Service Parameter Definitions on page 334:
ClearDiagnosticInformation on page 335.
3.6.43 SvcReadDTCInformation
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
Only reportNumberOfDTCByStatusMask, reportDTCByStatusMask, reportMirrorMemoryDTCByStatusMask,
reportNumberOfMirrorMemoryDTCByStatusMask, reportNumberOfEmissionsRelatedOBDDTCByStatusMask,
reportEmissionsRelatedOBDDTCByStatusMask Sub‐functions are allowed.
Syntax
Pascal OO
C#
C++ / CLR
209
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDTCInformation")> _
Public Shared Function SvcReadDTCInformation( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal RDTCIType As TPUDSSvcParamRDTCI, _
ByVal DTCStatusMask As Byte) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
RDTCIType Subfunction parameter: ReadDTCInformation type, use one of the following:
PUDS_SVC_PARAM_RDTCI_RNODTCBSM,
PUDS_SVC_PARAM_RDTCI_RDTCBSM,
PUDS_SVC_PARAM_RDTCI_RMMDTCBSM,
PUDS_SVC_PARAM_RDTCI_RNOMMDTCBSM,
PUDS_SVC_PARAM_RDTCI_RNOOBDDTCBSM,
PUDS_SVC_PARAM_RDTCI_ROBDDTCBSM.
DTCStatusMask Contains eight DTC status bit.
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
210
PCAN-UDS API – User Manual
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
211
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.44 SvcReadDTCInformationRDTCSSBDTC
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information. The
sub‐function reportDTCSnapshotRecordByDTCNumber (PUDS_SVC_PARAM_RDTCI_RDTCSSBDTC) is implicit.
Syntax
Pascal OO
212
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDTCInformationRDTCSSBDTC")> _
Public Shared Function SvcReadDTCInformationRDTCSSBDTC( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DTCMask As UInt32, _
ByVal DTCSnapshotRecordNumber As Byte) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DTCStatusMask A unique identification number (three byte value) for a specific diagnostic trouble code
DTCSnapshotRecordNumber The number of the specific DTCSnapshot data records
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
213
PCAN-UDS API – User Manual
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
214
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
215
PCAN-UDS API – User Manual
3.6.45 SvcReadDTCInformationRDTCSSBRN
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information. The
sub‐function reportDTCSnapshotByRecordNumber (PUDS_SVC_PARAM_RDTCI_RDTCSSBRN) is implicit.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDTCInformationRDTCSSBRN")> _
Public Shared Function SvcReadDTCInformationRDTCSSBRN( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DTCSnapshotRecordNumber As Byte) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DTCSnapshotRecordNumber The number of the specific DTCSnapshot data records
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
216
PCAN-UDS API – User Manual
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
217
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
218
PCAN-UDS API – User Manual
3.6.46 SvcReadDTCInformationReportExtended
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
Only reportDTCExtendedDataRecordByDTCNumber and
reportMirrorMemoryDTCExtendedDataRecordByDTCNumber Sub‐functions are allowed.
Syntax
Pascal OO
C#
C++ / CLR
219
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDTCInformationReportExtended")>
_
Public Shared Function SvcReadDTCInformationReportExtended( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal RDTCIType As TPUDSSvcParamRDTCI, _
ByVal DTCMask As UInt32, _
ByVal DTCExtendedDataRecordNumber As Byte) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
RDTCIType Subfunction parameter: ReadDTCInformation type, use one of the following:
PUDS_SVC_PARAM_RDTCI_RDTCEDRBDN,
PUDS_SVC_PARAM_RDTCI_RMMDEDRBDN
DTCMask A unique identification number (three byte value) for a specific diagnostic trouble code
DTCExtendedDataRecordNumber The number of the specific DTCExtendedData record requested
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
220
PCAN-UDS API – User Manual
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
221
PCAN-UDS API – User Manual
End If
If (result = TPUDSStatus.PUDS_ERROR_OK) Then
MessageBox.Show(String.Format("Response was received."))
Else
' An error occurred
MessageBox.Show(String.Format("Error occured: {0}", result.ToString()))
End If
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.47 SvcReadDTCInformationReportSeverity
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
Only reportNumberOfDTCBySeverityMaskRecord and reportDTCSeverityInformation Sub‐functions are allowed.
222
PCAN-UDS API – User Manual
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDTCInformationReportSeverity")>
_
Public Shared Function SvcReadDTCInformationReportSeverity( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal RDTCIType As TPUDSSvcParamRDTCI, _
ByVal DTCSeverityMask As Byte, _
ByVal DTCStatusMask As Byte) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
RDTCIType Subfunction parameter: ReadDTCInformation type, use one of the following:
PUDS_SVC_PARAM_RDTCI_RNODTCBSMR,
PUDS_SVC_PARAM_RDTCI_RDTCBSMR
DTCSeverityMask A mask of eight (8) DTC severity bits (see TPUDSSvcParamRDTCI_DTCSVM).
DTCStatusMask A mask of eight (8) DTC status bits.
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
223
PCAN-UDS API – User Manual
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
224
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
225
PCAN-UDS API – User Manual
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.48 SvcReadDTCInformationRSIODTC
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
The sub‐function reportSeverityInformationOfDTC (PUDS_SVC_PARAM_RDTCI_RSIODTC) is implicit.
Syntax
Pascal OO
C#
226
PCAN-UDS API – User Manual
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDTCInformationRSIODTC")> _
Public Shared Function SvcReadDTCInformationRSIODTC( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DTCMask As UInt32) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DTCMask A unique identification number for a specific diagnostic trouble code
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
227
PCAN-UDS API – User Manual
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
228
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.49 SvcReadDTCInformationNoParam
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
Only reportSupportedDTC, reportFirstTestFailedDTC, reportFirstConfirmedDTC,
reportMostRecentTestFailedDTC, reportMostRecentConfirmedDTC, reportDTCFaultDetectionCounter,
reportDTCWithPermanentStatus, and reportDTCSnapshotIdentification Sub‐functions are allowed.
229
PCAN-UDS API – User Manual
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcReadDTCInformationNoParam")> _
Public Shared Function SvcReadDTCInformationNoParam( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal RDTCIType As TPUDSSvcParamRDTCI) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
RDTCIType Subfunction parameter: ReadDTCInformation type, use one of the following:
PUDS_SVC_PARAM_RDTCI_RFTFDTC,
PUDS_SVC_PARAM_RDTCI_RFCDTC,
PUDS_SVC_PARAM_RDTCI_RMRTFDTC,
PUDS_SVC_PARAM_RDTCI_RMRCDTC,
PUDS_SVC_PARAM_RDTCI_RSUPDTC,
PUDS_SVC_PARAM_RDTCI_RDTCWPS,
PUDS_SVC_PARAM_RDTCI_RDTCSSI.
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
230
PCAN-UDS API – User Manual
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
231
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
232
PCAN-UDS API – User Manual
3.6.50 SvcInputOutputControlByIdentifier
Writes a UDS request according to the InputOutputControlByIdentifier service’s specifications.
The InputOutputControlByIdentifier service is used by the client to substitute a value for an input signal,
internal server function and/or control an output (actuator) of an electronic system.
Syntax
Pascal OO
C#
C++ / CLR
233
PCAN-UDS API – User Manual
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcInputOutputControlByIdentifier")> _
Public Shared Function SvcInputOutputControlByIdentifier( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal DataIdentifier As UShort, _
ByVal ControlOptionRecord As Byte(), _
ByVal ControlOptionRecordLength As UShort, _
ByVal ControlEnableMaskRecord As Byte(), _
ByVal ControlEnableMaskRecordLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
DataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
ControlOptionRecord First byte can be used as either an InputOutputControlParameter that describes how the server
shall control its inputs or outputs (see TPUDSSvcParamIOCBI), or as an additional controlState byte
ControlOptionRecordLength Size in bytes of the ControlOptionRecord buffer
ControlEnableMaskRecord The ControlEnableMask shall only be supported when the inputOutputControlParameter is used
and the dataIdentifier to be controlled consists of more than one parameter (i.e. the dataIdentifier
is bit‐mapped or packeted by definition). There shall be one bit in the ControlEnableMask
corresponding to each individual parameter defined within the dataIdentifier
ControlEnableMaskRecordLength Size in bytes of the controlEnableMaskRecord buffer
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
234
PCAN-UDS API – User Manual
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
235
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
lBufferOption: array[0..19] of Byte;
lBufferEnableMask: array[0..19] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
236
PCAN-UDS API – User Manual
3.6.51 SvcRoutineControl
Writes a UDS request according to the RoutineControl service’s specifications.
The RoutineControl service is used by the client to start/stop a routine, and request routine results.
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcRoutineControl")> _
237
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
RoutineControlType Subfunction parameter: RoutineControl type (see TPUDSSvcParamRC).
RoutineIdentifier Server Local Routine Identifier (see TPUDSSvcParamRC_RID).
Buffer Buffer containing the Routine Control Options (only with start and stop routine sub‐functions).
BufferLength Size in bytes of the buffer.
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
238
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
239
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffer: array[0..3] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.52 SvcRequestDownload
Writes a UDS request according to the RequestDownload service’s specifications.
240
PCAN-UDS API – User Manual
The RequestDownload service is used by the client to initiate a data transfer from the client to the server
(download).
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcRequestDownload")> _
Public Shared Function SvcRequestDownload( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal CompressionMethod As Byte, _
ByVal EncryptingMethod As Byte, _
ByVal MemoryAddress As Byte(), _
ByVal MemoryAddressLength As Byte, _
ByVal MemorySize As Byte(), _
ByVal MemorySizeLength As Byte) As TPUDSStatus
End Function
241
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
CompressionMethod A nibble‐value that specifies the "compressionMethod", the value 0x0 specifies that no
compressionMethod is used
EncryptingMethod A nibble‐value that specifies the "encryptingMethod", the value 0x0 specifies that no
encryptingMethod is used
MemoryAddress Starting address of server memory to which data is to be written
MemoryAddressLength Size in bytes of the MemoryAddress buffer (max.: 0xF)
MemorySize Used by the server to compare the uncompressed memory size with the total amount of data
transferred during the TransferData service
MemorySizeLength Size in bytes of the MemorySize buffer (max.: 0xF)
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
242
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
243
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
lBufferAddr: array[0..3] of Byte;
lBufferSize: array[0..1] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.53 SvcRequestUpload
Writes a UDS request according to the RequestUpload service’s specifications.
The RequestUpload service is used by the client to initiate a data transfer from the server to the client (upload).
244
PCAN-UDS API – User Manual
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcRequestUpload")> _
Public Shared Function SvcRequestUpload( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal CompressionMethod As Byte, _
ByVal EncryptingMethod As Byte, _
ByVal MemoryAddress As Byte(), _
ByVal MemoryAddressLength As Byte, _
ByVal MemorySize As Byte(), _
ByVal MemorySizeLength As Byte) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
245
PCAN-UDS API – User Manual
Parameters Description
CompressionMethod A nibble‐value that specifies the "compressionMethod", the value 0x0 specifies that no
compressionMethod is used
EncryptingMethod A nibble‐value that specifies the "encryptingMethod", the value 0x0 specifies that no
encryptingMethod is used
MemoryAddress Starting address of server memory to which data is to be written
MemoryAddressLength Size in bytes of the MemoryAddress buffer (max.: 0xF)
MemorySize Used by the server to compare the uncompressed memory size with the total amount of data
transferred during the TransferData service
MemorySizeLength Size in bytes of the MemorySize buffer (max.: 0xF)
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
246
PCAN-UDS API – User Manual
if (result == TPUDSStatus.PUDS_ERROR_OK)
MessageBox.Show(String.Format("Response was received."));
else
// An error occurred
MessageBox.Show(String.Format("Error occured: {0}", (int)result));
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
247
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
lBufferAddr: array[0..3] of Byte;
lBufferSize: array[0..1] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
248
PCAN-UDS API – User Manual
3.6.54 SvcTransferData
Writes a UDS request according to the TransferData service’s specifications.
The TransferData service is used by the client to transfer data either from the client to the server (download) or
from the server to the client (upload).
Syntax
Pascal OO
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcTransferData")> _
Public Shared Function SvcTransferData( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal BlockSequenceCounter As Byte, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
BlockSequenceCounter The blockSequenceCounter parameter value starts at 01 hex with the first TransferData request
that follows the RequestDownload (34 hex) or RequestUpload (35 hex) service. Its value is
incremented by 1 for each subsequent TransferData request. At the value of FF hex, the
blockSequenceCounter rolls over and starts at 00 hex with the next TransferData request message
249
PCAN-UDS API – User Manual
Parameters Description
Buffer Buffer containing the required transfer parameters
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
250
PCAN-UDS API – User Manual
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
Visual Basic:
251
PCAN-UDS API – User Manual
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffer: array[0..3] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
3.6.55 SvcRequestTransferExit
Writes a UDS request according to the RequestTransferExit service’s specifications.
The RequestTransferExit service is used by the client to terminate a data transfer between client and server
(upload or download).
Syntax
Pascal OO
252
PCAN-UDS API – User Manual
C#
C++ / CLR
Visual Basic
<DllImport("PCAN-UDS.dll", EntryPoint:="UDS_SvcRequestTransferExit")> _
Public Shared Function SvcRequestTransferExit( _
ByVal CanChannel As TPUDSCANHandle, _
ByRef MessageBuffer As TPUDSMsg, _
ByVal Buffer As Byte(), _
ByVal BufferLength As UShort) As TPUDSStatus
End Function
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A PUDS message
Buffer Buffer containing the required transfer parameters
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
253
PCAN-UDS API – User Manual
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C#:
TPUDSStatus result;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
// initialization
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
C++/CLR:
TPUDSStatus result;
TPUDSMsg^ request = gcnew TPUDSMsg();
TPUDSMsg^ requestConfirmation = gcnew TPUDSMsg();
TPUDSMsg^ response = gcnew TPUDSMsg();
// initialization
request->NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request->NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request->NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request->NETADDRINFO.RA = 0x00;
request->NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
254
PCAN-UDS API – User Manual
Visual Basic:
Pascal OO:
var
request: TPUDSMsg;
requestConfirmation: TPUDSMsg;
response: TPUDSMsg;
result: TPUDSStatus;
buffer: array[0..3] of Byte;
begin
// initialization
request.NETADDRINFO.SA := Byte(PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT);
request.NETADDRINFO.TA := Byte(PUDS_ISO_15765_4_ADDR_ECU_1);
request.NETADDRINFO.TA_TYPE := PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA := $00;
request.NETADDRINFO.PROTOCOL := PUDS_PROTOCOL_ISO_15765_2_11B;
255
PCAN-UDS API – User Manual
// An error occurred
MessageBox(0, 'An error occured', 'Error', MB_OK)
end;
256
PCAN-UDS API – User Manual
3.7 Functions
The functions of the PCAN UDS are divided in 4 groups of functionality.
Connection
Function Description
UDS_Initialize Initializes a PUDS channel
Configuration
Function Description
UDS_SetValue Sets a configuration or information value within a PUDS Channel
Information
Function Description
UDS_GetValue Retrieves information from a PUDS Channel
Communication
Function Description
UDS_Read Reads a CAN message from the receive queue of a PUDS Channel
UDS_Write Writes to the transmit queue a CAN message using a connected PUDS
Channel
UDS_Reset Resets the receive and transmit queues of a PUDS Channel
UDS_WaitForService Waits for the confirmation of the transmission of a UDS service request and
the reception of its response
UDS_WaitForServiceFunctional Waits for the confirmation of the transmission of a functional UDS service
request and the reception of its responses
UDS_ProcessResponse Processes a UDS response message to update internal UDS features
UDS_SvcSecurityAccess Writes to the transmit queue a request for UDS service SecurityAccess
UDS_SvcResponseOnEvent Writes to the transmit queue a request for UDS service ResponseOnEvent
UDS_SvcLinkControl Writes to the transmit queue a request for UDS service LinkControl
257
PCAN-UDS API – User Manual
Function Description
UDS_SvcReadMemoryByAddress Writes to the transmit queue a request for UDS service
ReadMemoryByAddress
UDS_SvcReadScalingDataByIdentifier Writes to the transmit queue a request for UDS service
ReadScalingDataByIdentifier
UDS_SvcReadDataByPeriodicIdentifier Writes to the transmit queue a request for UDS service
ReadDataByPeriodicIdentifier
UDS_SvcDynamicallyDefineDataIdentifierDBID Writes to the transmit queue a request for UDS service
DynamicallyDefineDataIdentifier
UDS_SvcDynamicallyDefineDataIdentifierDBMA Writes to the transmit queue a request for UDS service
DynamicallyDefineDataIdentifier
UDS_SvcDynamicallyDefineDataIdentifierCDDDI Writes to the transmit queue a request for UDS service
DynamicallyDefineDataIdentifier
UDS_SvcWriteDataByIdentifier Writes to the transmit queue a request for UDS service
WriteDataByIdentifier
UDS_SvcWriteMemoryByAddress Writes to the transmit queue a request for UDS service
WriteMemoryByAddress
UDS_SvcClearDiagnosticInformation Writes to the transmit queue a request for UDS service
ClearDiagnosticInformation
UDS_SvcReadDTCInformation Writes to the transmit queue a request for UDS service
ReadDTCInformation
UDS_SvcReadDTCInformationRDTCSSBDTC Writes to the transmit queue a request for UDS service
ReadDTCInformation
UDS_SvcReadDTCInformationRDTCSSBRN Writes to the transmit queue a request for UDS service
ReadDTCInformation
UDS_SvcReadDTCInformationReportExtended Writes to the transmit queue a request for UDS service
ReadDTCInformation
UDS_SvcReadDTCInformationReportSeverity Writes to the transmit queue a request for UDS service
ReadDTCInformation
UDS_SvcReadDTCInformationRSIODTC Writes to the transmit queue a request for UDS service
ReadDTCInformation
UDS_SvcReadDTCInformationNoParam Writes to the transmit queue a request for UDS service
ReadDTCInformation
UDS_SvcInputOutputControlByIdentifier Writes to the transmit queue a request for UDS service
InputOutputControlByIdentifier
UDS_SvcRoutineControl Writes to the transmit queue a request for UDS service RoutineControl
UDS_SvcRequestDownload Writes to the transmit queue a request for UDS service RequestDownload
UDS_SvcRequestUpload Writes to the transmit queue a request for UDS service RequestUpload
UDS_SvcTransferData Writes to the transmit queue a request for UDS service TransferData
UDS_SvcRequestTransferExit Writes to the transmit queue a request for UDS service RequestTransferExit
258
PCAN-UDS API – User Manual
3.7.1 UDS_Initialize
Initializes a PUDS Channel which represents a Non‐Plug & Play PCAN‐Device.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Baudrate The speed for the communication (see TPUDSBaudrate on page 25)
HwType The type of hardware (see TPUDSHWType on page 28)
IOPort The I/O address for the parallel port
Interrupt Interrupt number of the parallel port
Returns
The return value is a TPUDSStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in case
of failure are:
Remarks: As indicated by its name, the Initialize method initiates a PUDS Channel, preparing it for
communication within the CAN bus connected to it. Calls to the other methods will fail if they are used with a
Channel handle, different than PUDS_NONEBUS, that has not been initialized yet. Each initialized channel
should be released when it is not needed anymore.
259
PCAN-UDS API – User Manual
Take in consideration that initializing a channel causes a reset of the CAN hardware. In this way errors like
BUSOFF, BUSHEAVY, and BUSLIGHT, are removed.
Example
The following example shows the initialize and uninitialize processes for a Plug‐And‐Play channel (channel 2 of
the PCAN‐PCI).
C++
TPUDSStatus result;
See also: UDS_Uninitialize below, UDS_GetValue on page 262, Understanding PCAN‐UDS on page 8.
3.7.2 UDS_Uninitialize
Uninitializes a PUDS Channel.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Returns
The return value is a TPUDSStatus code. PCANTP_ERROR_OK is returned on success. The typical errors in case
of failure are:
PCANTP_ERROR_NOT_INITIALIZED Indicates that the given PCANTP channel cannot be uninitialized because it was not
found in the list of reserved channels of the calling application
Single‐Release: Given a handle of a PUDS Channel initialized before with the method initialize. If the given
channel can not be found then an error is returned
Multiple‐Release: Giving the handle value PUDS_NONEBUS which instructs the API to search for all
channels initialized by the calling application and release them all. This option cause no errors if no
hardware were uninitialized
260
PCAN-UDS API – User Manual
Example
The following example shows the initialize and uninitializes processes for a Plug‐And‐Play channel (channel 2 of
a PCAN‐PCI hardware).
C++
TPUDSStatus result;
// Release channel
UDS_Uninitialize(PUDS_PCIBUS2);
3.7.3 UDS_SetValue
Sets a configuration or information value within a PUDS Channel.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to be set (see TPUDSParameter on page 31)
Buffer The buffer containing the numeric value to be set
BufferLength The length in bytes of the given buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel cannot be uninitialized because it was not found
in the list of reserved channels of the calling application
PUDS_ERROR_WRONG_PARAM Indicates that the parameters passed to the method are invalid. Check the value of
'Parameter' and assert it is compatible with an integer buffer
Remarks: Use the method SetValue to set configuration information or environment values of a PUDS Channel.
261
PCAN-UDS API – User Manual
Note: That any calls with non ISO‐TP parameters (ie. TPUDSParameter) will be forwarded to PCAN‐Basic
API.
More information about the parameters and values that can be set can be found in Parameter Value
Definitions. Since most of the UDS parameters require a numeric value (byte or integer) this is the most
common and useful override.
Example
he following example shows the use of the method SetValue on the channel PUDS_PCIBUS2 to enable debug
mode.
C++
TPUDSStatus result;
unsigned int iBuffer = 0;
See also: UDS_GetValue below, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
3.7.4 UDS_GetValue
Retrieves information from a PUDS Channel.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PCANTP Channel (see TPUDSCANHandle on page 22)
Parameter The code of the value to retrieve (see TPUDSParameter)
Buffer The buffer to return the required value
BufferLength The length in bytes of the given buffer
262
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels
of the calling application
PUDS_ERROR_WRONG_PARAM Indicates that the parameters passed to the method are invalid. Check the value of
'Parameter' and assert it is compatible with a string buffer
Example
The following example shows the use of the method GetValue to retrieve the version of the ISO‐TP API.
Depending on the result, a message will be shown to the user.
C++
See also: UDS_SetValue on page 261, TPUDSParameter on page 31, Parameter Value Definitions on page 332.
3.7.5 UDS_GetStatus
Gets the current BUS status of a PUDS Channel.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_OK: Indicates that the status of the given PUDS Channel is OK.
263
PCAN-UDS API – User Manual
PUDS_ERROR_BUSLIGHT: Indicates a bus error within the given PUDS Channel. The hardware is in bus‐light status.
PUDS_ERROR_BUSHEAVY: Indicates a bus error within the given PUDS Channel. The hardware is in bus‐heavy status.
PUDS_ERROR_BUSOFF: Indicates a bus error within the given PUDS Channel. The hardware is in bus‐off status.
PUDS_ERROR_NOT_INITIALIZED: Indicates that the given PUDS channel cannot be used because it was not found in the list of
reserved channels of the calling application.
Remarks: When the hardware status is bus‐off, an application cannot communicate anymore. Consider using
the PCAN‐Basic property PCAN_BUSOFF_AUTORESET which instructs the API to automatically reset the CAN
controller when a bus‐off state is detected.
Another way to reset errors like bus‐off, bus‐heavy and bus‐light, is to uninitialize and initialize again the
channel used. This causes a hardware reset.
Example
The following example shows the use of the method GetStatus on the channel PUDS_PCIBUS1. Depending on
the result, a message will be shown to the user.
C++
TPUDSStatus result;
See also: TPUDSParameter on page 31, Parameter Value Definitions on page 332.
264
PCAN-UDS API – User Manual
3.7.6 UDS_Read
Reads a UDS message from the receive queue of a PUDS Channel.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Message Buffer A TPUDSMsg buffer to store the CAN UDS message
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
Remarks: The message type (see TPUDSMessageType) of a CAN UDS message indicates if the message is a
complete received UDS message, a transmission confirmation or an indication of a pending message. This value
should be checked every time a message has been read successfully, along with the RESULT value as it contains
the network status of the message.
Note: That higher level functions like WaitForSingleMessage or WaitForService should be preferred in
cases where a client just has to read the response from a service request.
Example
The following example shows the use of the method Read on the channel PUDS_USBBUS1. Depending on the
result, a message will be shown to the user.
C++
TPCANTPStatus result;
TPCANTPMsg msg;
bool bStop = false;
do
{ // Read the first message in the queue
result = UDS_Read(PUDS_USBBUS1, &msg);
if (result == PUDS_ERROR_OK)
{ // Process the received message
MessageBox(NULL, "A message was received", "Success", MB_OK);
//ProcessMessage(msg);
}
Else
{
// An error occurred
265
PCAN-UDS API – User Manual
3.7.7 UDS_Write
Transmits a CAN UDS message.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A TPUDSMsg buffer containing the CAN UDS message to be sent
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application or that a required CAN ID mapping was not found
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The Write function do not actually send the UDS message, the transmission is asynchronous. Should
a message fail to be transmitted, it will be added to the reception queue with a specific network error code in
the RESULT value of the TPUDSMsg.
Note: To transmit a standard UDS service request, it is recommended to use the corresponding API
Service method starting with Svc (like SvcDiagnosticSessionControl).
Example
The following example shows the use of the method Write on the channel PUDS_USBBUS1. It adds to the
transmit queue a UDS request from source 0xF1 to ECU #1 and then waits until a confirmation message is
received. Depending on the result, a message will be shown to the user.
Note: it is assumed that the channel was already initialized and mapping were configured, the content of
DATA is not initialized in the example.
266
PCAN-UDS API – User Manual
C++
TPUDSStatus result;
// prepare an 11bit CAN ID, physically addressed UDS message containing 4095 BYTEs
of data
TPUDSMsg request;
char strMsg[256];
request.LEN = 4095;
request.MSGTYPE = PUDS_MESSAGE_TYPE_REQUEST;
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.8 UDS_Reset
Resets the receive and transmit queues of a PUDS Channel.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
267
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
Remarks: Calling this method ONLY clear the queues of a Channel. A reset of the CAN controller doesn't take
place.
Example
The following example shows the use of the method Reset on the channel PUDS_PCIBUS1. Depending on the
result, a message will be shown to the user.
C++
TPUDSStatus result;
3.7.9 UDS_WaitForSingleMessage
Waits for a UDS response or transmit confirmation based on a UDS request.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A TPUDSMsg buffer to store the UDS message
268
PCAN-UDS API – User Manual
Parameters Description
MessageRequest A TPUDSMsg buffer containing the UDS message that was previously sent
IsWaitForTransmit States whether the message to wait is a transmit confirmation or a UDS response
TimeInterval Time to wait between polling for new UDS messages in milliseconds
Timeout Maximum time to wait (in milliseconds) for a message indication corresponding to the
MessageRequest. Note: a zero value means unlimited time
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_NO_MESSAGE Indicates that no matching message was received in the time given
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
Remarks: The Timeout parameter is ignored once a message indication matching the request is received (i.e.
the first frame of the message). The function will then return once the message is fully received or a network
error occurred.
To prevent unexpected locking, the user can abort the function by calling the function UDS_Reset (class‐
method: Reset).
Note: That the criteria to identify if a response matches the message request is based only on the
network addressing information and the UDS service identifier: if a same service is requested multiple
times with different parameters (like service ReadDataByIdentifier with different Data IDs), the user will
have to ensure that the extra content matches the original request.
Example
The following example shows the use of the method WaitForSingleMessage on the channel PUDS_USBBUS1. It
writes a UDS message on the CAN Bus and waits for the confirmation of the transmition. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg confirmation;
// prepare an 11bit CAN ID, physically addressed UDS message containing 4095 Bytes
of data
memset(&request, 0, sizeof(TPUDSMsg));
memset(&confirmation, 0, sizeof(TPUDSMsg));
// [...] fill data
request.LEN = 4095;
request.MSGTYPE = PUDS_MESSAGE_TYPE_REQUEST;
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
269
PCAN-UDS API – User Manual
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.10 UDS_WaitForMultipleMessage
Waits for multiple UDS responses based on a UDS request (multiple responses can be obtained when a
functional UDS request is transmitted).
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Buffer A buffer to store an array of TPUDSMsg
MaxCount The maximum number of expected responses
pCount Buffer to store the actual number of received responses
MessageRequest A TPUDSMsg buffer containing the UDS message that was previously transmitted
TimeInterval Time to wait between polling for new UDS messages in milliseconds
Timeout Maximum time to wait (in milliseconds) for a message indication corresponding to the
MessageRequest. Note: a zero value means unlimited time
270
PCAN-UDS API – User Manual
Parameters Description
TimeoutEnhanced Maximum time to wait (in milliseconds) for a message indication corresponding to the
MessageRequest if an ECU asks for extended timing (NRC_EXTENDED_TIMING)
WaitUntilTimeout States whether the function is interrupted if the number of received messages reaches MaxCount
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_NO_MESSAGE Indicates that no matching message was received in the time given
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_OVERFLOW Success but the buffer limit was reached. Check pCount variable to see how many
messages were discarded
Remarks: For each response, the Timeout/TimeoutEnhanced parameter is ignored once a message indication
matching the request is received (i.e. the first frame of the message). The function will then return once all
messages are fully received or a network error occurred.
To prevent unexpected locking, the user can abort the function by calling the function UDS_Reset (class‐
method: Reset).
Note: that the criteria to identify if a response matches the message request is based only on the network
addressing information and the UDS service identifier: if a same service is requested multiple times with
different parameters (like service ReadDataByIdentifier with different Data IDs), the user will have to
ensure that the extra content matches the original request.
The function handles the negative response code PUDS_NRC_EXTENDED_TIMING (0x78) in order to fetch all
responses at the same time: if such a response is read, the function will switch the default timeout to
TimeoutEnhanced and wait for a new response.
Example
The following example shows the use of the method WaitForMultipleMessage on the channel PUDS_ USBBUS1.
It writes a UDS functional message on the CAN Bus, waits for the confirmation of the transmission and then
waits to receive responses from ECUs until timeout occurs. Depending on the result, a message will be shown
to the user.
271
PCAN-UDS API – User Manual
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg confirmation;
DWORD MessageArraySize = 5;
TPUDSMsg MessageArray[5];
DWORD count;
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_FUNCTIONAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
272
PCAN-UDS API – User Manual
3.7.11 UDS_WaitForService
Handles the communication workflow for a UDS service expecting a single response. The function waits for a
transmit confirmation then for a message response.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer A TPUDSMsg buffer to store the UDS response
MessageRequest A TPUDSMsg buffer containing the UDS message that was previously written
MessageReqBuffer A TPUDSMsg buffer to store the UDS transmit confirmation
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_NO_MESSAGE Indicates that no matching message was received in the time given
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_OVERFLOW A network error occured either in the transmit confirmation or the response message
Remarks: The WaitForService function is a utility function that calls other UDS API functions to simplify UDS
communication workflow:
1. The function gets the defined timeouts (global API request and response timeouts and timeouts
defined by the current session information with the ECU),
2. Waits for the confirmation of request’s transmition,
3. On success, waits for the response confirmation.
4. If a negative response code is received stating that the ECU requires extended timing
(PUDS_NRC_EXTENDED_TIMING, 0x78), the function switches to the enhanced timeout and waits for
another response.
5. The function ProcessResponse is called automatically on the response.
Even if the SuppressPositiveResponseMessage flag is set in the UDS request, the function will still wait for an
eventual Negative Response. If no error message is received the function will return
PUDS_ERROR_NO_MESSAGE, although in this case it is must not be considered as an error. Moreover if a
negative response code PUDS_NRC_EXTENDED_TIMING is received the SuppressPositiveResponseMessage flag
is ignored as stated in ISO‐14229‐1.
273
PCAN-UDS API – User Manual
Example
The following example shows the use of the method WaitForService on the channel PUDS_USBBUS1. A UDS
physical service request is transmitted (service ECUReset), and the WaitForService function is called to get the
response. Depending on the result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.12 UDS_WaitForServiceFunctional
Handles the communication workflow for a UDS service requested with functional addressing, i.e. multiple
responses can be expected. The function waits for a transmit confirmation then for responses.
Syntax
C++
274
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
Buffer A buffer to store an array of TPUDSMsg
MaxCount The maximum number of expected responses
pCount Buffer to store the actual number of received responses
WaitUntilTimeout States whether the function is interrupted if the number of received messages reaches MaxCount
MessageRequest A TPUDSMsg buffer containing the UDS message that was previously written
MessageReqBuffer A TPUDSMsg buffer to store the UDS transmit confirmation
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_NO_MESSAGE Indicates that no matching message was received in the time given
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_OVERFLOW Success but the buffer limit was reached. Check pCount variable to see how many
messages were discarded
Remarks: The WaitForServiceFunctional function is a utility function that calls other UDS API functions to
simplify UDS communication workflow when requests involve functional addressing:
1. The function gets the defined timeouts (global API request and response timeouts and timeouts
defined by the current session information with the ECU),
2. Waits for the confirmation of request’s transmition,
3. On success, it waits for the confirmations of the responses like the function WaitForMultipleMessage
would.
4. The function ProcessResponse is called on each response.
Example
The following example shows the use of the method WaitForServiceFunctional on the channel PUDS_USBBUS1.
A UDS functional service request is transmitted (service ECUReset), and the WaitForServiceFunctional function
is called to get the responses. Depending on the result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
WORD MessageArraySize = 5;
TPUDSMsg MessageArray[5];
DWORD count;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
275
PCAN-UDS API – User Manual
3.7.13 UDS_ProcessResponse
Processes a UDS response message to manage ISO‐14229/15765 features, like session information.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
BufferBuffer A TPUDSMsg buffer to store the UDS response
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_WRONG_PARAM MessageBuffer is not valid (data length is zero or the network result indicates an error)
Remarks: The purpose of this function is to update internal UDS settings of the API: currently only the
responses to DiagnosticSessionControl requests require this processing as they contain information on the
active session.
276
PCAN-UDS API – User Manual
Example
The following example shows the use of the method ProcessResponse on the channel PUDS_USBBUS1. It writes
a UDS physical request (service DiagnosticSessionControl) on the CAN Bus, waits for the confirmation of the
transmission and then waits to receive a response. Once received the ProcessResponse function is called on the
received message, updating the session information inside the API.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg confirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&confirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_FUNCTIONAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
}
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
277
PCAN-UDS API – User Manual
3.7.14 UDS_SvcDiagnosticSessionControl
Writes a UDS request according to the DiagnosticSessionControl service’s specifications.
The DiagnosticSessionControl service is used to enable different diagnostic sessions in the server.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS Message
SessionType Subfunction parameter: type of the session (see TPUDSSvcParamDSC)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
If this service is called with the NO_POSITIVE_RESPONSE_MSG parameter of the MessageBuffer set to ignore
responses (i.e. value PUDS_SUPPR_POS_RSP_MSG_INDICATION_BIT), the API will automatically change the
current session to the new one.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
278
PCAN-UDS API – User Manual
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.15 UDS_SvcECUReset
Writes a UDS request according to the ECUReset service’s specifications.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS Message
ResetType Subfunction parameter: type of Reset (see TPUDSSvcParamER)
279
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
DWORD dwBuffer;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
280
PCAN-UDS API – User Manual
3.7.16 UDS_SvcSecurityAccess
Writes a UDS request according to the SecurityAccess service’s specifications.
SecurityAccess service provides a mean to access data and/or diagnostic services which have restricted access
for security, emissions or safety reasons.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS Message
SecurityAccessType Subfunction parameter: type of SecurityAccess (see PUDS_SVC_PARAM_SA_xxx definitions)
Buffer If Requesting Seed, buffer is the optional data to transmit to a server (like identification). If Sending
Key, data holds the value generated by the security algorithm corresponding to a specific “seed”
value
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
The example shows the use of a numeric buffer and points out the fact that Windows uses Little Endian Byte
order and the UDS_SvcXXX functions expects data in Big Endian Byte Order.
281
PCAN-UDS API – User Manual
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
DWORD dwBuffer;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
See also: UDS_WaitForService on page 273, PCAN‐UDS Service Parameter Definitions on page 334:
SecurityAccess on page 334.
3.7.17 UDS_SvcCommunicationControl
Writes a UDS request according to the CommunicationControl service’s specifications.
CommunicationControl service's purpose is to switch on/off the transmission and/or the reception of certain
messages of (a) server(s).
Syntax
C++
282
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS Message
ControlType Subfunction parameter: type of CommunicationControl (see TPUDSSvcParamCC)
CommunicationType A bit‐code value to reference the kind of communication to be controlled, see
PUDS_SVC_PARAM_CC_FLAG_xxx flags and ISO_14229‐2006 §B.1 for bit‐encoding
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
283
PCAN-UDS API – User Manual
See also: UDS_WaitForService on page 273, PCAN‐UDS Service Parameter Definitions on page 334:
CommunicationControl on page 334.
3.7.18 UDS_SvcTesterPresent
Writes a UDS request according to the TesterPresent service’s specifications.
TesterPresent service indicates to a server (or servers) that a client is still connected to the vehicle and that
certain diagnostic services and/or communications that have been previously activated are to remain active.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS Message
TesterPresentType No Subfunction parameter by default (PUDS_SVC_PARAM_TP_ZSUBF)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
284
PCAN-UDS API – User Manual
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.19 UDS_SvcSecuredDataTransmission
Writes a UDS request according to the SecuredDataTransmission service’s specifications.
SecuredDataTransmission service's purpose is to transmit data that is protected against attacks from third
parties, which could endanger data security.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
Buffer Buffer containing the data as processed by the Security Sub‐Layer (See ISO‐15764)
285
PCAN-UDS API – User Manual
Parameters Description
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
DWORD dwBuffer;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Note: next a function is called to set MSB as 1st byte in the buffer
// (Win32 uses little endian format, UDS expects big endian)
DWORD valueLittleEndian = 0xF0A1B2C3;
dwBuffer = ReverseDword(&valueLittleEndian);
// Sends a Physical SecuredDataTransmission Message
result = UDS_SvcSecuredDataTransmission(PUDS_USBBUS1, &request, (BYTE*) &dwBuffer,
4);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
286
PCAN-UDS API – User Manual
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.20 UDS_SvcControlDTCSetting
Writes a UDS request according to the ControlDTCSetting service’s specifications.
ControlDTCSetting service shall be used by a client to stop or resume the setting of diagnostic trouble codes
(DTCs) in the server(s).
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DTCSettingType Subfunction parameter (see TPUDSSvcParamCDTCS)
Buffer This parameter record is user‐optional and transmits data to a server when controlling the DTC
setting. It can contain a list of DTCs to be turned on or off
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel.
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
287
PCAN-UDS API – User Manual
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
DWORD dwBuffer;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Note: next a function is called to set MSB as 1st byte in the buffer
// (Win32 uses little endian format, UDS expects big endian)
DWORD valueLittleEndian = 0xF0A1B2C3;
dwBuffer = ReverseDword(&valueLittleEndian);
// Sends a Physical ControlDTCSetting Message
result = UDS_SvcControlDTCSetting(PUDS_USBBUS1, &request, PUDS_SVC_PARAM_CDTCS_OFF,
(BYTE*)&dwBuffer, 3);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.21 UDS_SvcResponseOnEvent
Writes a UDS request according to the ResponseOnEvent service’s specifications.
The ResponseOnEvent service requests a server to start or stop transmission of responses on a specified event.
Syntax
C++
288
PCAN-UDS API – User Manual
TPUDSMsg * MessageBuffer,
BYTE EventType,
BOOLEAN StoreEvent,
BYTE EventWindowTime,
BYTE * EventTypeRecord,
WORD EventTypeRecordLength,
BYTE * ServiceToRespondToRecord,
WORD ServiceToRespondToRecordLength);
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DTCSettingType Subfunction parameter (see TPUDSSvcParamCDTCS)
EventType Subfunction parameter: event type (see TPUDSSvcParamROE)
StoreEvent Storage State (TRUE = Store Event, FALSE = Do Not Store Event)
EventWindowTime Specify a window for the event logic to be active in the server (see also
PUDS_SVC_PARAM_ROE_EWT_ITTR)
EventTypeRecord Additional parameters for the specified eventType
EventTypeRecordLength Size in bytes of the EventType Record (see PUDS_SVC_PARAM_ROE_xxx_LEN definitions)
ServiceToRespondToRecord Service parameters, with first byte as service Id (see TPUDSSvcParamROERecommendedServiceID)
ServiceToRespondToRecordLength Size in bytes of the ServiceToRespondTo Record
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE evBuffer[5];
289
PCAN-UDS API – User Manual
BYTE siBuffer[5];
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
See also: UDS_WaitForService on page 273, PCAN‐UDS Service Parameter Definitions on page 334:
ResponseOnEvent on page 334.
3.7.22 UDS_SvcLinkControl
Writes a UDS request according to the LinkControl service’s specifications.
The LinkControl service is used to control the communication link baud rate between the client and
the server(s) for the exchange of diagnostic data.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
LinkControlType Subfunction parameter: Link Control Type (see TPUDSSvcParamLC)
290
PCAN-UDS API – User Manual
Parameters Description
BaudrateIdentifier Defined baud rate identifier (see TPUDSSvcParamLCBaudrateIdentifier)
LinkBaudrate Used only with PUDS_SVC_PARAM_LC_VBTWSBR parameter: a three‐byte value baud rate
(baudrate High, Middle and Low Bytes)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
291
PCAN-UDS API – User Manual
3.7.23 UDS_SvcReadDataByIdentifier
Writes a UDS request according to the ReadDataByIdentifier service’s specifications.
The ReadDataByIdentifier service allows the client to request data record values from the server identified by
one or more dataIdentifiers.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
Buffer Buffer containing a list of two‐byte Data Identifiers (see TPUDSSvcParamDI)
BufferLength Number of elements in the buffer (size in WORD of the buffer)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
292
PCAN-UDS API – User Manual
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.24 UDS_SvcReadMemoryByAddress
Writes a UDS request according to the ReadMemoryByAddress service’s specifications.
The ReadMemoryByAddress service allows the client to request memory data from the server via a provided
starting address and to specify the size of memory to be read.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
MemoryAddress Starting address of server memory from which data is to be retrieved
MemoryAddressLength Size in bytes of the MemoryAddress buffer (max.: 0xF)
MemorySize Number of bytes to be read starting at the address specified by memoryAddress
MemorySizeLength Size in bytes of the MemorySize buffer (max.: 0xF)
293
PCAN-UDS API – User Manual
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBufferAddr[10] = {};
BYTE lBufferSize[10] = {};
BYTE buffAddrLen = 10;
BYTE buffSizeLen = 3;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill data
for (int i = 0 ; i < buffAddrLen ; i++) {
lBufferAddr[i] = 'A' + i;
lBufferSize[i] = '1' + i;
}
// Sends a Physical ReadMemoryByAddress Message
result = UDS_SvcReadMemoryByAddress(PUDS_USBBUS1, &request, lBufferAddr,
buffAddrLen, lBufferSize, buffSizeLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
294
PCAN-UDS API – User Manual
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.25 UDS_SvcReadScalingDataByIdentifier
Writes a UDS request according to the ReadScalingDataByIdentifier service’s specifications.
The ReadScalingDataByIdentifier service allows the client to request scaling data record information from the
server identified by a dataIdentifier.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
DataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
295
PCAN-UDS API – User Manual
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.26 UDS_SvcReadDataByPeriodicIdentifier
Writes a UDS request according to the ReadDataByPeriodicIdentifier service’s specifications.
The ReadDataByPeriodicIdentifier service allows the client to request the periodic transmission of data record
values from the server identified by one or more periodicDataIdentifiers.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
TransmissionMode Transmission rate code (see TPUDSSvcParamRDBPI)
Buffer Buffer containing a list of Periodic Data Identifiers
296
PCAN-UDS API – User Manual
Parameters Description
BufferLength Number of elements in the buffer (size in WORD of the buffer)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBuffer[10] = {};
WORD buffLen = 10;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill Data
for (int i = 0 ; i < buffLen ; i++) {
lBuffer[i] = 'A' + i;
}
// Sends a Physical ReadDataByPeriodicIdentifier Message
result = UDS_SvcReadDataByPeriodicIdentifier(PUDS_USBBUS1, &request,
PUDS_SVC_PARAM_RDBPI_SAMR, lBuffer, buffLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
297
PCAN-UDS API – User Manual
3.7.27 UDS_SvcDynamicallyDefineDataIdentifierDBID
Writes a UDS request according to the DynamicallyDefineDataIdentifier service’s specifications.
The DynamicallyDefineDataIdentifier service allows the client to dynamically define in a server a data identifier
that can be read via the ReadDataByIdentifier service at a later time. The Define By Identifier subfunction
specifies that definition of the dynamic data identifier shall occur via a data identifier reference.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DynamicallyDefinedDataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
SourceDataIdentifier Buffer containing the sources of information to be included into the dynamic data record
MemorySize Buffer containing the total numbers of bytes from the source data record address
PositionInSourceDataRecord Buffer containing the starting byte positions of the excerpt of the source data record
BuffersLength Number of elements in the buffers (SourceDataIdentifier, MemoryAddress and
PositionInSourceDataRecord)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
298
PCAN-UDS API – User Manual
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
WORD lBufferSourceDI[10] = {};
BYTE lBufferMemSize[10] = {};
BYTE lBufferPosInSrc[10] = {};
WORD buffLen = 10;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill Data
for (int i = 0 ; i < buffLen ; i++) {
lBufferSourceDI[i] = ((0xF0+i) << 8) + ('A' + i);
lBufferMemSize[i] = i + 1;
lBufferPosInSrc[i] = 100 + i;
}
// Sends a Physical DynamicallyDefineDataIdentifierDBID Message
result = UDS_SvcDynamicallyDefineDataIdentifierDBID(PUDS_USBBUS1, &request,
PUDS_SVC_PARAM_DI_CDDID, lBufferSourceDI, lBufferMemSize, lBufferPosInSrc,
buffLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
299
PCAN-UDS API – User Manual
3.7.28 UDS_SvcDynamicallyDefineDataIdentifierDBMA
Writes a UDS request according to the DynamicallyDefineDataIdentifier service’s specifications.
The DynamicallyDefineDataIdentifier service allows the client to dynamically define in a server a data identifier
that can be read via the ReadDataByIdentifier service at a later time. The Define By Memory Address
subfunction specifies that definition of the dynamic data identifier shall occur via an address reference.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DynamicallyDefinedDataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
MemoryAddressLength Size in bytes of the MemoryAddress items in the MemoryAddressBuffer buffer (max.: 0xF)
MemorySizeLength Size in bytes of the MemorySize items in the MemorySizeBuffer buffer (max.: 0xF)
MemoryAddressBuffer Buffer containing the MemoryAddress buffers, must be an array of 'BuffersLength' entries which
contains 'MemoryAddressLength' bytes (size is 'BuffersLength * MemoryAddressLength'
bytes)
MemorySizeBuffer Buffer containing the MemorySize buffers, must be an array of 'BuffersLength' entries which
contains 'MemorySizeLength' bytes (size is 'BuffersLength * MemorySizeLength' bytes)
BuffersLength Size in bytes of the MemoryAddressBuffer and MemorySizeBuffer buffers
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
300
PCAN-UDS API – User Manual
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
WORD buffLen = 3;
BYTE lBuffsAddr[15] = {};
BYTE lBuffsSize[9] = {};
BYTE buffAddrLen = 5;
BYTE buffSizeLen = 3;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill data
for (int j = 0 ; j < buffLen ; j++)
{
for (int i = 0 ; i < buffAddrLen ; i++) {
lBuffsAddr[buffAddrLen*j+i] = (10 * j) + i + 1;
}
for (int i = 0 ; i < buffSizeLen ; i++) {
lBuffsSize[buffSizeLen*j+i] = 100 + (10 * j) + i + 1;
}
}
// Sends a Physical DynamicallyDefineDataIdentifierDBMA Message
result = UDS_SvcDynamicallyDefineDataIdentifierDBMA(PUDS_USBBUS1, &request,
PUDS_SVC_PARAM_DI_CESWNDID, buffAddrLen, buffSizeLen, lBuffsAddr, lBuffsSize,
buffLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
301
PCAN-UDS API – User Manual
3.7.29 UDS_SvcDynamicallyDefineDataIdentifierCDDDI
Writes a UDS request according to the Clear Dynamically Defined Data Identifier service’s specifications.
The Clear Dynamically Defined Data Identifier subfunction shall be used to clear the specified dynamic data
identifier.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DynamicallyDefinedDataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
302
PCAN-UDS API – User Manual
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.30 UDS_SvcWriteDataByIdentifier
Writes a UDS request according to the WriteDataByIdentifier service’s specifications.
The WriteDataByIdentifier service allows the client to write information into the server at an internal location
specified by the provided data identifier.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
DataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
Buffer Buffer containing the data to write
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
303
PCAN-UDS API – User Manual
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBuffer[10] = {};
WORD buffLen = 10;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill Data
for (int i = 0 ; i < buffLen ; i++) {
lBuffer[i] = 'A' + i;
}
// Sends a Physical WriteDataByIdentifier Message
result = UDS_SvcWriteDataByIdentifier(PUDS_USBBUS1, &request,
PUDS_SVC_PARAM_DI_ASFPDID, lBuffer, buffLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.31 UDS_SvcWriteMemoryByAddress
Writes a UDS request according to the WriteMemoryByAddress service’s specifications.
304
PCAN-UDS API – User Manual
The WriteMemoryByAddress service allows the client to write information into the server at one or more
contiguous memory locations.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
DataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
MemoryAddress Starting address of server memory to which data is to be written
MemoryAddressLength Size in bytes of the MemoryAddress buffer (max.: 0xF)
MemorySize Number of bytes to be written starting at the address specified by memoryAddress
MemorySizeLength Size in bytes of the MemorySize buffer (max.: 0xF)
Buffer Buffer containing the data to write
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
305
PCAN-UDS API – User Manual
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBuffer[50] = {};
BYTE lBufferMemAddr[50] = {};
BYTE lBufferMemSize[50] = {};
WORD buffLen = 50;
BYTE buffAddrLen = 5;
BYTE buffSizeLen = 3;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill Data
for (int i = 0 ; i < buffLen ; i++) {
lBuffer[i] = i+1;
lBufferMemAddr[i] = 'A' + i;
lBufferMemSize[i] = 10 + i;
}
// Sends a Physical WriteMemoryByAddress Message
result = UDS_SvcWriteMemoryByAddress(PUDS_USBBUS1, &request,
PUDS_SVC_PARAM_DI_ASFPDID,
lBufferMemAddr, buffAddrLen, lBufferMemSize, buffSizeLen, lBuffer, buffLen);
result = UDS_SvcECUReset(PUDS_USBBUS1, &request, PUDS_SVC_PARAM_ER_SR);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.32 UDS_SvcClearDiagnosticInformation
Writes a UDS request according to the ClearDiagnosticInformation service’s specifications.
The ClearDiagnosticInformation service is used by the client to clear diagnostic information in one server's or
multiple servers’ memory.
Syntax
C++
306
PCAN-UDS API – User Manual
TPUDSCANHandle CanChannel,
TPUDSMsg * MessageBuffer,
DWORD groupOfDTC);
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
groupOfDTC A three‐byte value indicating the group of DTCs (e.g. powertrain, body, chassis) or the particular
DTC to be cleared (see PUDS_SVC_PARAM_CDI_xxx definitions)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
307
PCAN-UDS API – User Manual
See also: UDS_WaitForService on page 273, PCAN‐UDS Service Parameter Definitions on page 334:
ClearDiagnosticInformation on page 335.
3.7.33 UDS_SvcReadDTCInformation
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
Only reportNumberOfDTCByStatusMask, reportDTCByStatusMask, reportMirrorMemoryDTCByStatusMask,
reportNumberOfMirrorMemoryDTCByStatusMask, reportNumberOfEmissionsRelatedOBDDTCByStatusMask,
reportEmissionsRelatedOBDDTCByStatusMask Sub‐functions are allowed.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
RDTCIType Subfunction parameter: ReadDTCInformation type, use one of the following:
PUDS_SVC_PARAM_RDTCI_RNODTCBSM,
PUDS_SVC_PARAM_RDTCI_RDTCBSM,
PUDS_SVC_PARAM_RDTCI_RMMDTCBSM,
PUDS_SVC_PARAM_RDTCI_RNOMMDTCBSM,
PUDS_SVC_PARAM_RDTCI_RNOOBDDTCBSM,
PUDS_SVC_PARAM_RDTCI_ROBDDTCBSM
DTCStatusMask Contains eight DTC status bit
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid or RDTCIType is not
allowed
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
308
PCAN-UDS API – User Manual
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
309
PCAN-UDS API – User Manual
3.7.34 UDS_SvcReadDTCInformationRDTCSSBDTC
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information. The
sub‐function reportDTCSnapshotRecordByDTCNumber (PUDS_SVC_PARAM_RDTCI_RDTCSSBDTC) is implicit.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DTCMask A unique identification number (three byte value) for a specific diagnostic trouble code
DTCSnapshotRecordNumber The number of the specific DTCSnapshot data records
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
310
PCAN-UDS API – User Manual
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.35 UDS_SvcReadDTCInformationRDTCSSBRN
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information. The
sub‐function reportDTCSnapshotByRecordNumber (PUDS_SVC_PARAM_RDTCI_RDTCSSBRN) is implicit.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DTCSnapshotRecordNumber The number of the specific DTCSnapshot data records
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
311
PCAN-UDS API – User Manual
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.36 UDS_SvcReadDTCInformationReportExtended
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
Only reportDTCExtendedDataRecordByDTCNumber and
reportMirrorMemoryDTCExtendedDataRecordByDTCNumber Sub‐functions are allowed.
312
PCAN-UDS API – User Manual
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
RDTCIType Subfunction parameter: ReadDTCInformation type, use one of the following:
PUDS_SVC_PARAM_RDTCI_RDTCEDRBDN,
PUDS_SVC_PARAM_RDTCI_RMMDEDRBDN
DTCMask A unique identification number (three byte value) for a specific diagnostic trouble code
DTCExtendedDataRecordNumber The number of the specific DTCExtendedData record requested
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid or RDTCIType is not
allowed
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
313
PCAN-UDS API – User Manual
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.37 UDS_SvcReadDTCInformationReportSeverity
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
Only reportNumberOfDTCBySeverityMaskRecord and reportDTCSeverityInformation Sub‐functions are allowed.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
RDTCIType Subfunction parameter: ReadDTCInformation type, use one of the following:
PUDS_SVC_PARAM_RDTCI_RNODTCBSMR,
PUDS_SVC_PARAM_RDTCI_RDTCBSMR
DTCSeverityMask A mask of eight (8) DTC severity bits (see TPUDSSvcParamRDTCI_DTCSVM)
DTCStatusMask A mask of eight (8) DTC status bits
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
314
PCAN-UDS API – User Manual
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid or RDTCIType is not
allowed
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
315
PCAN-UDS API – User Manual
3.7.38 UDS_SvcReadDTCInformationRSIODTC
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information. The
sub‐function reportSeverityInformationOfDTC (PUDS_SVC_PARAM_RDTCI_RSIODTC) is implicit.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DTCMask A unique identification number for a specific diagnostic trouble code.
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
316
PCAN-UDS API – User Manual
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
3.7.39 UDS_SvcReadDTCInformationNoParam
Writes a UDS request according to the ReadDTCInformation service’s specifications.
This service allows a client to read the status of server‐resident Diagnostic Trouble Code (DTC) information.
Only reportSupportedDTC, reportFirstTestFailedDTC, reportFirstConfirmedDTC,
reportMostRecentTestFailedDTC, reportMostRecentConfirmedDTC, reportDTCFaultDetectionCounter,
reportDTCWithPermanentStatus, and reportDTCSnapshotIdentification Sub‐functions are allowed.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
RDTCIType Subfunction parameter: ReadDTCInformation type, use one of the following:
PUDS_SVC_PARAM_RDTCI_RFTFDTC,
PUDS_SVC_PARAM_RDTCI_RFCDTC,
PUDS_SVC_PARAM_RDTCI_RMRTFDTC,
PUDS_SVC_PARAM_RDTCI_RMRCDTC,
PUDS_SVC_PARAM_RDTCI_RSUPDTC,
PUDS_SVC_PARAM_RDTCI_RDTCWPS,
PUDS_SVC_PARAM_RDTCI_RDTCSSI
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
317
PCAN-UDS API – User Manual
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid or RDTCIType is not
allowed
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
318
PCAN-UDS API – User Manual
3.7.40 UDS_SvcInputOutputControlByIdentifier
Writes a UDS request according to the InputOutputControlByIdentifier service’s specifications.
The InputOutputControlByIdentifier service is used by the client to substitute a value for an input signal,
internal server function and/or control an output (actuator) of an electronic system.
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
DataIdentifier A two‐byte Data Identifier (see TPUDSSvcParamDI)
ControlOptionRecord First byte can be used as either an InputOutputControlParameter that describes how the server
shall control its inputs or outputs (see TPUDSSvcParamIOCBI), or as an additional controlState byte
ControlOptionRecordLength Size in bytes of the ControlOptionRecord buffer
ControlEnableMaskRecord The ControlEnableMask shall only be supported when the inputOutputControlParameter is used
and the dataIdentifier to be controlled consists of more than one parameter (i.e. the dataIdentifier
is bit‐mapped or packeted by definition). There shall be one bit in the ControlEnableMask
corresponding to each individual parameter defined within the dataIdentifier
ControlEnableMaskRecordLength Size in bytes of the controlEnableMaskRecord buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
319
PCAN-UDS API – User Manual
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBufferOption[20] = {};
BYTE lBufferEnableMask[20] = {};
WORD lBuffOptionLen = 10;
WORD lBuffMaskLen = 5;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill Data
for (int i = 0 ; i < lBuffOptionLen ; i++) {
lBufferOption[i] = 'A' + i;
lBufferEnableMask[i] = 10 + i;
}
// Sends a Physical InputOutputControlByIdentifier Message
result = UDS_SvcInputOutputControlByIdentifier(PUDS_USBBUS1, &request,
PUDS_SVC_PARAM_DI_SSECUSWVNDID,
lBufferOption, lBuffOptionLen, lBufferEnableMask, lBuffMaskLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.41 UDS_SvcRoutineControl
Writes a UDS request according to the RoutineControl service’s specifications.
The RoutineControl service is used by the client to start/stop a routine, and request routine results.
Syntax
C++
320
PCAN-UDS API – User Manual
WORD RoutineIdentifier,
BYTE * Buffer,
WORD BufferLength);
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message
RoutineControlType Subfunction parameter: RoutineControl type (see TPUDSSvcParamRC)
RoutineIdentifier Server Local Routine Identifier (see TPUDSSvcParamRC_RID)
Buffer Buffer containing the Routine Control Options (only with start and stop routine sub‐functions)
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
321
PCAN-UDS API – User Manual
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBuffer[20] = {};
WORD lBuffLen = 10;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill data
for (int i = 0 ; i < lBuffLen ; i++) {
lBuffer[i] = 'A' + i;
}
// Sends a Physical RoutineControl Message
result = UDS_SvcRoutineControl(PUDS_USBBUS1, &request, PUDS_SVC_PARAM_RC_RRR,
0xF1A2, lBuffer, lBuffLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.42 UDS_SvcRequestDownload
Writes a UDS request according to the RequestDownload service’s specifications.
The RequestDownload service is used by the client to initiate a data transfer from the client to the server
(download).
Syntax
C++
322
PCAN-UDS API – User Manual
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
CompressionMethod A nibble‐value that specifies the "compressionMethod", the value 0x0 specifies that no
compressionMethod is used
EncryptingMethod A nibble‐value that specifies the "encryptingMethod", the value 0x0 specifies that no
encryptingMethod is used
MemoryAddress Starting address of server memory to which data is to be written
MemoryAddressLength Size in bytes of the MemoryAddress buffer (max.: 0xF)
MemorySize Used by the server to compare the uncompressed memory size with the total amount of data
transferred during the TransferData service
MemorySizeLength Size in bytes of the MemorySize buffer (max.: 0xF)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBufferMemAddr[50] = {};
BYTE lBufferMemSize[50] = {};
BYTE buffAddrLen = 15;
BYTE buffSizeLen = 8;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
323
PCAN-UDS API – User Manual
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill data
for (int i = 0 ; i < buffAddrLen ; i++) {
lBufferMemAddr[i] = 'A' + i;
lBufferMemSize[i] = 10 + i;
}
// Sends a Physical RequestDownload Message
result = UDS_SvcRequestDownload(PUDS_USBBUS1, &request, 0x01, 0x02,
lBufferMemAddr, buffAddrLen, lBufferMemSize, buffSizeLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.43 UDS_SvcRequestUpload
Writes a UDS request according to the RequestUpload service’s specifications.
The RequestUpload service is used by the client to initiate a data transfer from the server to the client (upload).
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
CompressionMethod A nibble‐value that specifies the "compressionMethod", the value 0x0 specifies that no
compressionMethod is used
EncryptingMethod A nibble‐value that specifies the "encryptingMethod", the value 0x0 specifies that no
encryptingMethod is used
MemoryAddress Starting address of server memory from which data is to be retrieved
MemoryAddressLength Size in bytes of the MemoryAddress buffer (max.: 0xF)
324
PCAN-UDS API – User Manual
Parameters Description
MemorySize Used by the server to compare the uncompressed memory size with the total amount of data
transferred during the TransferData service
MemorySizeLength Size in bytes of the MemorySize buffer (max.: 0xF)
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBufferMemAddr[50] = {};
BYTE lBufferMemSize[50] = {};
BYTE buffAddrLen = 21;
BYTE buffSizeLen = 32;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
325
PCAN-UDS API – User Manual
3.7.44 UDS_SvcTransferData
Writes a UDS request according to the TransferData service’s specifications.
The TransferData service is used by the client to transfer data either from the client to the server (download) or
from the server to the client (upload).
Syntax
C++
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
BlockSequenceCounter The blockSequenceCounter parameter value starts at 01 hex with the first TransferData request
that follows the RequestDownload (34 hex) or RequestUpload (35 hex) service. Its value is
incremented by 1 for each subsequent TransferData request. At the value of FF hex, the
blockSequenceCounter rolls over and starts at 00 hex with the next TransferData request message
Buffer Buffer containing the required transfer parameters
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
326
PCAN-UDS API – User Manual
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBuffer[50] = {};
BYTE buffLen = 50;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill data
for (int i = 0 ; i < buffLen ; i++) {
lBuffer[i] = 'A' + i;
}
// Sends a Physical TransferData Message
result = UDS_SvcTransferData(PUDS_USBBUS1, &request, 0x01, lBuffer, buffLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
3.7.45 UDS_SvcRequestTransferExit
Writes a UDS request according to the RequestTransferExit service’s specifications.
The RequestTransferExit service is used by the client to terminate a data transfer between client and server
(upload or download).
Syntax
C++
327
PCAN-UDS API – User Manual
TPUDSMsg * MessageBuffer,
BYTE * Buffer,
WORD BufferLength);
Parameters
Parameters Description
CanChannel The handle of a PUDS Channel (see TPUDSCANHandle on page 22)
MessageBuffer The PUDS message (NO_POSITIVE_RESPONSE_MSG is ignored)
Buffer Buffer containing the required transfer parameters
BufferLength Size in bytes of the buffer
Returns
The return value is a TPUDSStatus code. PUDS_ERROR_OK is returned on success. The typical errors in case of
failure are:
PUDS_ERROR_NOT_INITIALIZED Indicates that the given PUDS channel was not found in the list of initialized channels of
the calling application
PUDS_ERROR_TIMEOUT Failed to gain access to the API mutual exclusion or the function was aborted by a call to
reset the channel
PUDS_ERROR_WRONG_PARAM The network addressing information of the message is not valid
PUDS_ERROR_NO_MEMORY Failed to allocate memory and copy message in the transmission queue
PUDS_ERROR_OVERFLOW: Buffer size is too big, the resulting UDS message data size is bigger than the maximum
data length
Remarks: The function reads the MessageBuffer NETADDRINFO parameter and sets the DATA with the given
parameters according to the service’s specifications. It then writes the message to the transmit queue.
Example
The following example shows the use of the service method on the channel PUDS_USBBUS1. A UDS physical
service request is transmitted, and the WaitForService function is called to get the response. Depending on the
result, a message will be shown to the user.
C++:
TPUDSStatus result;
TPUDSMsg request;
TPUDSMsg requestConfirmation;
TPUDSMsg response;
BYTE lBuffer[50] = {};
BYTE buffLen = 20;
// initialization
memset(&request, 0, sizeof(TPUDSMsg));
memset(&requestConfirmation, 0, sizeof(TPUDSMsg));
memset(&response, 0, sizeof(TPUDSMsg));
request.NETADDRINFO.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
request.NETADDRINFO.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
// Fill data
for (int i = 0 ; i < buffLen ; i++) {
328
PCAN-UDS API – User Manual
lBuffer[i] = 'A' + i;
}
// Sends a Physical RequestTransferExit Message
result = UDS_SvcRequestTransferExit(PUDS_USBBUS1, &request, lBuffer, buffLen);
if (result == PUDS_ERROR_OK)
result = UDS_WaitForService(PUDS_USBBUS1, &response, &request,
&requestConfirmation);
if (result == PUDS_ERROR_OK)
MessageBox(NULL, "Response was received", "Success", MB_OK);
else
// An error occurred
MessageBox(NULL, "An error occured", "Error", MB_OK);
329
PCAN-UDS API – User Manual
3.8 Definitions
The PCAN‐UDS API defines the following values:
Name Description
PCAN‐UDS HandleDefinitions Defines the handles for the different PCAN channels
Parameter Value Definitions Defines the possible values for setting and getting PCAN's environment information with the
functions UDS_SetValue and UDS_GetValue
TPUDSMsg Member Value Defines values and constants for the members of the TPUDSMsg structure
Definitions
PCAN‐UDS Service Parameter Defines constants to be used with some UDS service functions
Definitions
Default/Undefined handle:
Type Constant Value Description
TPUDSCANHandle PUDS_NONEBUS 0x0 Undefined/default value for a PCAN‐UDS Channel
330
PCAN-UDS API – User Manual
Note: These definitions are constants values in an object oriented environment (Delphi, .NET Framework)
and declared as defines in C++ and Pascal (plain API).
Not Plug & Play: The hardware channels of this kind are used as registered. This mean, for example, it is
allowed to register the PUDS_ISABUS3 without having registered PUDS_ISA1 and PUDS_ISA2. It is a decision of
each user, how to associate a PCAN‐Channel (logical part) and a port/interrupt pair (physical part).
Plug & Play: For hardware handles of PCI, USB and PC‐Card, the availability of the channels is determined by
the count of hardware connected to a computer in a given moment, in conjunction with their internal handle.
This means that having four PCAN‐USB connected to a computer will let the user to connect the channels
PUDS_USBBUS1 to PUDS_USBBUS4. The association of each channel with a hardware is managed internally
using the handle of a hardware.
331
PCAN-UDS API – User Manual
Debug‐Configuration values:
Type Constant Value Description
Int32 PUDS_DEBUG_NONE 0 No CAN debug messages are being generated
Int32 PUDS_DEBUG_CAN 1 CAN debug messages are written to the stdout output
Channel‐Available values:
Type Constant Value Description
Int32 PUDS_CHANNEL_UNAVAILABLE 0 The UDS PCAN‐Channel handle is illegal, or its associated
hardware is not available
Int32 PUDS_CHANNEL_AVAILABLE 1 The UDS PCAN‐Channel handle is valid to connect/initialize.
Furthermore, for plug&play hardware, this means that the
hardware is plugged‐in
Int32 PUDS_CHANNEL_OCCUPIED 2 The UDS PCAN‐Channel handle is valid, and is currently being
used
332
PCAN-UDS API – User Manual
Remarks: These definitions are constants values in an object oriented environment (Delphi, .NET Framework)
and declared as defines in C++ (plain API).
See also: TPUDSParameter on page 31, PCAN‐UDS Handle Definitions on page 330.
DATA information:
Type Constant Value Description
Int32 PUDS_MAX_DATA 4095 Maximum data length in bytes of UDS message
NO_POSITIVE_RESPONSE_MSG values:
Type Constant Value Description
Int32 PUDS_SUPPR_POS_RSP_MSG_INDICATION 0x80 Value for NO_POSITIVE_RESPONSE_MSG stating to discard
_BIT any positive response
Int32 PUDS_KEEP_POS_RSP_MSG_INDICATION_ 0 Default value for NO_POSITIVE_RESPONSE_MSG stating to
BIT return any responses
333
PCAN-UDS API – User Manual
CommunicationControl
The communicationType parameter is a bit‐code value which allows control of multiple communication types
at the same time.
The following table lists the coding of the communicationType data parameter:
ResponseOnEvent
The following table defines the expected size of the EventTypeRecord based on the EventType
(TPUDSParamROE):
Type Constant Value Description
BYTE PUDS_SVC_PARAM_ROE_STPROE_LEN 0 expected size of EventTypeRecord for ROE_STPROE
BYTE PUDS_SVC_PARAM_ROE_ONDTCS_LEN 1 expected size of EventTypeRecord for ROE_ONDTCS
BYTE PUDS_SVC_PARAM_ROE_OTI_LEN 1 expected size of EventTypeRecord for ROE_OTI
BYTE PUDS_SVC_PARAM_ROE_OCODID_LEN 2 expected size of EventTypeRecord for ROE_OCODID
BYTE PUDS_SVC_PARAM_ROE_RAE_LEN 0 expected size of EventTypeRecord for ROE_RAE
334
PCAN-UDS API – User Manual
The following table lists extra constants to be used with ResponseOnEvent service:
Type Constant Value Description
BYTE PUDS_SVC_PARAM_ROE_EWT_ITTR 2 Infinite Time To Response (eventWindowTime parameter)
ClearDiagnosticInformation
The following table lists constants to be used as the GroupOfDTC parameter with the
ClearDiagnosticInformation service:
Type Constant Value Description
UInt32 PUDS_SVC_PARAM_CDI_ERS 0x000000 groupOfDTC : Emissions‐related systems group of DTCs
UInt32 PUDS_SVC_PARAM_CDI_AGDTC 0xFFFFFF groupOfDTC : All Groups of DTCs
335
PCAN-UDS API – User Manual
4 Additional Information
PCAN is the platform for PCAN‐OBDII, PCAN‐UDS and PCAN‐Basic. In the following topics there is an overview
of PCAN and the fundamental practice with the interface DLL CanApi2 (PCAN‐API).
Topics Description
PCAN Fundamentals This section contains an introduction to PCAN
PCAN‐Basic This section contains general information about the PCAN‐Basic
API
UDS and ISO‐TP Network Addressing This section contains general information about the ISO‐TP
Information network addressing format
Basis for the communication between PCs and external hardware via CAN is a series of Windows Kernel Mode
Drivers (Virtual Device Drivers) e.g. PCAN_USB.SYS, PCAN_PCI.SYS, PCAN_xxx.SYS. These drivers are the core of
a complete CAN environment on a PC running Windows and work as interfaces between CAN software and PC‐
based CAN hardware. The drivers manage the entire data flow of every CAN device connected to the PC.
336
PCAN-UDS API – User Manual
Users of PCAN‐View 3 do not have to define and manage Nets. If PCAN‐View is instructed to connect directly to
a PCAN hardware, the application automatically creates a Net for the selected hardware, and automatically
establishes a connection with this Net.
See also: PCAN‐Basic below, ISO‐TP Network Addressing Format on page 342.
4.2 PCAN-Basic
PCAN‐Basic is an Application Programming Interface for the use of a collection of Windows Device Drivers from
PEAK‐System, which allow the real‐time connection of Windows applications to all CAN busses physically
connected to a PC.
Initialization: In order to do CAN communication using a channel, it is necessary to first initialize it. This is done
making a call to the function CAN_Initialize (class‐method: Initialize) or CAN_InitializeFD (class‐method:
InitializeFD) in case FD communication is desired.
Interaction: After a successful initialization, a channel is ready to communicate with the connected CAN bus.
Further configuration is not needed. The functions CAN_Read and CAN_Write (class‐methods: Read and Write)
can be then used to read and write CAN messages. If the channel being used is FD capable and it was initialized
using CAN_InitializedFD, then the functions to use are CAN_ReadFD and CAN_WriteFD (class‐methods: ReadFD
and WriteFD). If desired, extra configuration can be made to improve a communication session, like changing
the message filter to target specific messages.
Finalization: When the communication is finished, the function CAN_Uninitialize (class‐method: Uninitialize)
should be called in order to release the PCAN‐Channel and the resources allocated for it. In this way the
channel is marked as "Free" and can be used from other applications.
337
PCAN-UDS API – User Manual
See also: PCAN Fundamentals on page 336, ISO‐TP Network Addressing Format on page 342.
338
PCAN-UDS API – User Manual
Functional request using 11 bits CAN identifier and normal addressing, from External Test Equipment
address (PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT) to OBD functional address
(PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL):
CAN ID 0x7DF (PUDS_ISO_15765_4_CAN_ID_FUNCTIONAL_REQUEST) from Source 0xF1
to Target 0x33
Physical requests and responses using 11 bits CAN identifier and normal addressing, between the External
Test Equipment address (PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT) and standard ECU addresses
(ECU #1 to #8):
ECU #1
1. Request: CAN ID 0x7E8 (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_1) from
Source 0xF1 to Target 0x01
2. Response: CAN ID 0x7E0 (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_1)
from Source 0x01 to Target 0xF1
ECU #2:
1. Request: CAN ID 0x7E9 (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_2) from
Source 0xF1 to Target 0x01
2. Response: CAN ID 0x7E1 (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_2)
from Source 0x01 to Target 0xF1
ECU #3:
1. Request: CAN ID 0x7EA (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_3) from
Source 0xF1 to Target 0x01
2. Response: CAN ID 0x7E2 (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_3)
from Source 0x01 to Target 0xF1
ECU #4:
1. Request: CAN ID 0x7EB (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_4) from
Source 0xF1 to Target 0x01
2. Response: CAN ID 0x7E3 (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_4)
from Source 0x01 to Target 0xF1
ECU #5:
1. Request: CAN ID 0x7EC (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_5) from
Source 0xF1 to Target 0x01
2. Response: CAN ID 0x7E4 (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_RESPONSE_5)
from Source 0x01 to Target 0xF1
ECU #6:
1. Request: CAN ID 0x7ED (PUDS_ISO_15765_4_CAN_ID_PHYSICAL_REQUEST_6) from
Source 0xF1 to Target 0x01
339
PCAN-UDS API – User Manual
340
PCAN-UDS API – User Manual
Communications with 29 bits CAN identifier and ENHANCED addressing format (where YYY is Target
Address and XXX Source address, addresses are encoded on 11 bits):
If an application requires other communication settings, it will have to be set with through the parameters
PUDS_PARAM_MAPPING_ADD and PUDS_PARAM_MAPPING_REMOVE. For a complete example, see §4.3.3 PCAN‐UDS
Example C:\Users\Christoph\Documents\Doku 2019\PCAN‐UDS‐API\Phase 2\PCAN‐UDS‐
API_UserMan_eng.doc ‐ _PCAN‐UDS_example#_PCAN‐UDS_exampleon page 343.
Alternatively, it is also possible to directly use PCAN‐ISO‐TP API: although PCAN‐UDS and PCAN‐ISO‐TP define
differents types for CAN channels (respectively TPUDSCANHandle and TPCANTPHandle), they are both the
same type. Once a PCAN‐UDS channel is initialized, PCAN‐ISO‐TP specific functions (like CANTP_AddMapping)
can be called with this PCAN‐UDS channel.
TPUDSCANHandle Channel;
...
// Define server address
BYTE param = 0xA1;
TPUDSStatus Status = UDS_SetValue(Channel, PUDS_PARAM_SERVER_ADDRESS, ¶m,
sizeof(param));
// check status and proceed…
TPUDSCANHandle Channel;
...
// listen to address 0x11
WORD param = (PUDS_SERVER_FILTER_LISTEN | 0x11);
341
PCAN-UDS API – User Manual
The following table sums up the mandatory configuration to the ISO‐TP API for each addressing format:
Addressing format CAN ID length Mandatory configuration steps
Normal addressing 11 bits Define mappings with CANTP_AddMapping
PCANTP_FORMAT_NORMAL 29 bits Define mappings with CANTP_AddMapping
Normal fixed addressing 11 bits Addressing is invalid
PCANTP_FORMAT_FIXED_NORMAL 29 bits ‐
Extended addressing 11 bits Define mappings with CANTP_AddMapping
PCANTP_FORMAT_EXTENDED 29 bits Define mappings with CANTP_AddMapping
Mixed addressing 11 bits Define mappings with CANTP_AddMapping
PCANTP_FORMAT_MIXED 29 bits ‐
Enhanced addressing 11 bits Addressing is invalid
PCANTP_FORMAT_ENHANCED 29 bits ‐
A mapping allows an ISO‐TP node to identify and decode CAN Identifiers, it binds a CAN ID to an ISO‐TP
network address information. CAN messages that cannot be identified are ignored by the API.
342
PCAN-UDS API – User Manual
Mappings involving physically addressed communication are most usually defined in pairs: the first mapping
defines outgoing communication (i.e. request messages from node A to node B) and the second to match
incoming communication (i.e. responses from node B to node A).
Functionally addressed communication requires one mapping to transmit functionally addressed messages (i.e.
request messages from node A to any node) and as many mappings as responding nodes (i.e. responses from
nodes B, C, etc. to node A).
TPUDSCANHandle Channel;
TPUDSMsg Message;
TPUDSStatus Status;
343
PCAN-UDS API – User Manual
Message.DATA.RAW[4] = 0x00;
Message.DATA.RAW[5] = 0x00;
Message.DATA.RAW[6] = 0x03;
Message.DATA.RAW[7] = 0x26;
status = UDS_SetValue(Channel, PUDS_PARAM_MAPPING_ADD, &Message, sizeof(Message));
344
PCAN-UDS API – User Manual
iBuffer = 0xF1;
status = UDS_SetValue(channelRx, PUDS_PARAM_SERVER_ADDRESS, &iBuffer, 1);
printf(" Set ServerAddress: %i (0x%02x)\n", (int)status, iBuffer);
UDS_Uninitialize(channelTx);
The client program doesn't need to check periodically for received messages any longer
The response time on received messages is reduced
To use events, the client application must call the UDS_SetValue function (class‐method: SetValue) to set the
parameter PUDS_PARAM_RECEIVE_EVENT. This parameter sets the handle for the event object. When
receiving a message, the API sets this event to the "Signaled" state.
345
PCAN-UDS API – User Manual
Another thread must be started in the client application, which waits for the event to be signaled, using one of
the Win32 synchronization functions (e.g. WaitForSingleObject) without increasing the processor load. After
the event is signaled, available messages can be read with the UDS_Read function (class method: Read), and
the UDS messages can be processed.
Remarks
Be careful, it is not recommended to use both event‐handler (with a reading thread) and the UDS „WaitFor“
functions:
WaitForSingleMessage,
WaitForMultipleMessage,
WaitForService,
WaitForServiceFunctional.
Indeed both mechanisms would read messages at the same time, the result is that one will not receive any (or
some) messages. If one of the previous functions is called and a thread is waiting for events to call the read
UDS message function, then the user will have to temporarily prevent the thread from reading messages.
Trigger mode "set" (default): After the first waiting thread has been released, the event object's state
changes to non‐signaled. Other waiting threads are not released. If no threads are waiting, the event
object's state remains signaled
Trigger mode "pulse": After the first waiting thread has been released, the event object's state
changes to non‐signaled. Other waiting threads are not released. If no threads are waiting, or if no
thread can be released immediately, the event object's state is simply set to non‐signaled
346
PCAN-UDS API – User Manual
5 License Information
The APIs PCAN‐UDS, PCAN‐ISO‐TP, and PCAN‐Basic are property of the PEAK‐System Technik GmbH and may be
used only in connection with a hardware component purchased from PEAK‐System or one of its partners. If
CAN hardware of third‐party suppliers should be compatible to that of PEAK‐System, then you are not allowed
to use the mentioned APIs with those components.
If a third‐party supplier develops software based on the mentioned APIs and problems occur during the use of
this software, consult that third‐party supplier.
347