UDS Overview

Micael Coutinho,autosarbswdcm

UDS is the diagnostics language all ECU's speak nowadays, linked to the Autosar DCM module. Learn its basic services here

I'm guessing you heard about UDS (Unified Diagnostic Services) at least some time in your life, or, at least, OBD2 (On-Board Diagnostics 2). If these terms sound familiar to you, you're already on the right path to knowing what vehice diagnostics are and the way they are performed.

UDS (Unified Diagnostic Services) is a widely used protocol in production vehicles, for diagnostics. The protocol (ISO 14229) has been around for ages, and it's hard to find a vehicle that does not implement this communication layer. According to the OSI layer, UDS sits between the session and application layers. The remaining layers are handled via the ECU's communication stack, which is likely CAN. It's a client-server protocol, where the ECU is the server, and the client is a testing tool, which can be an OBD2 connector from Amazon.

UDS and the OSI Model, configured via CAN in this example { w: 373, h: 340 }

UDS and the OSI Model, configured via CAN in this example

When your mechanic mentions it connected your vehicle to a computer, he's saying that used the OBD2 port on your vehicle to connect via UDS with some program he overpaid for to get the diagnostics your vehicle picked up along the way. So, you can already decipher the first advantage of UDS: it makes diagnosis of problems easier. But does it stop there? No, not really, and it can also be useful during development. Let's see some of the main advantages of UDS:

Now, these are the two main reasons UDS is used, but there is more you can do with it. A better way to better understand UDS is by learning about the services it provides. A side-note, all SID requests are responded with 0x40 + request SID, unless an error occurs. And, the OEM's can complete the command responses with their own reserved values, so it's not limited to what we're mentioning here.

Diagnostic / communication management:

Service NameSIDDescription
Diagnostic Session Control0x10Switch between operating sessions. These sessions provide access to a subset of commands. There can be OEM-specific sessions, but the most common are: default session (enabled from reset), extended session (allows an extra set of diagnostic functions), programming session (used for ECU reprogramming) and safety system diagnostic session (used for safety-cricical diagnostics). The session is restored in case of a timeout. To avoid it, read the Tester Present service
ECU Reset0x11Resets the ECU. Some of the reset types are: hard reset (emulates a shutdown of the power supply) and soft reset
Security Access0x27Allow access to security-relevant services
Communication Control0x28Control the sending and reception of messages to and from the ECU
Authentication0x29Used for the same purpose as the Security Access service, but for modern security athentication methods. Exists since 2020
Tester Present0x3EPing the ECU in order to keep the current session active
Access Timing Parameters0x83Change the connection timing parameters between the ECU and the client, in order to avoid timeouts while communicating
Secure Data Transmission0x84Used to transmit data in a secure mode, adding chryptographic protection
Control DTC Setting0x85Control DTC detection for specific or all errors. Useful when anomalous behaviors are triggered (for example, by maintenance work on a vehicle)
Response On Event0x86Configure a specific diagnostic service to get triggered in response to an event on the server
Link Control0x87Set the baud rate for diagnostic access. Usually available only on the gateway ECU

Data Transmission:

Service NameSIDDescription
Read Data by Identifier0x22Retrieve values from the ECU. Usually, many values are available for the user, and most of them are OEM-specific. Of course, some are obvious, such as the software version or part number
Read Memory by Address0x23Read memory from an address (if it's made available by the ECU, there are rules to this). Sort-of works as an upload command in calibration
Read Scaling Data by Identifier0x24Read scaling data of a specific DID
Read Data by Identifier Periodic0x2ARetrieve values from an ECU at a periodid pace
Dynamically Define Data Identifier0x2CDefine a DID to send a set of DID's
Write Data by Data Identifier0x2EWrite a value to a DID
Write Memory by Address0x3DWrite to one or a set of contiguous addresses

Stored Data Transmission:

Service NameSIDDescription
Clear Diagnostic Information0x14Delete all stored DTC's (Diagnostic Trouble Codes)
Read DTC Information0x19Read a DTC state. Additional information can also be read

IO Control:

Service NameSIDDescription
IO Control by Identifier0x2FControl a signal in the ECU

Routine Activation:

Service NameSIDDescription
Routine Control0x31Trigger a function on the ECU. There are 3 different options: start (to start execution), stop (to interrupt the service) and to retrieve the results of the service

Upload and Download:

Service NameSIDDescription
Request Downlaod0x34Write data into the ECU, by specifying address and length
Request Upload0x35Read data from the ECU, just as the Request Download service
Transfer Data0x36Used to write or read data. The direction is specified via the two former commands (Request Download and Request Upload). As opposed to the former, it can send multiple commands, in case the data is too large to fit in a single packet, where the former are limited to the ECU-configured packet length
Request Transfer Exit0x37Used to signal completion of the data transferred. The service can be rejected in case the specified length in Treansfer Data is not reached
Request FIle Transfer0x38Download/upload a file from/to the client to/from the server

After all of these services, there is also one message sent via the ECU to your client. You'll see it often, the Negative Response, which has the code 0x7F and signals the service requested could not be performed. There is also a NRC (Negative Response Code) included, giving you a clue on what went wrong.

Before we end this article, I would like to give you a picture on how UDS maps to the Autosar layered architecture. The UDS protocol lies within the DCM (Diagnostic Communication Manager) module, and you can configure all its services there. There is also the option to interface with other modules, most notably DEM (Diagnostic Event Manager), where the DTC's are configured and set. The lower layers are pretty obvious, are the COM-stack you are using (the most common is CAN, an CAN-TP can be used to enhance the size of the PDU's that can be exchanged). Other modules, such as the BSWM (BSW Mode Manager) can be used to provide functionalities, such as the communication control.

As some bottom notes, I would like to mention you don't need to know all these services by heart. You'll deal with them via an external tool. Of course, you'll get the hang of it when you need to put your hands on it. One good exercise is to buy one of those OBD2 connectors, an see how far you can go. Of course, at your own risk!

Author: Micael Coutinho (opens in a new tab)

References:

© AutosarToday —@LinkedIn