UDS
Unified Diagnostic Services — ISO 14229, the universal diagnostic protocol.
Overview
UDS defines a request/response protocol between a diagnostic tester and ECU. Each request starts with a Service Identifier (SID); responses echo SID+0x40 on success or 0x7F on negative response with a NRC. Sessions, security access, and routine controls enable diagnostics, coding and flashing.
Frame / message structure
| Field | Bits | Description |
|---|---|---|
| SID | 8 | Service Identifier (e.g. 0x22 ReadDataByIdentifier) |
| Sub-function | 8 | Optional, e.g. session type for 0x10 |
| Parameters | var | DID, RID, address+length, data record… |
Byte structure — request & response
UDS — ISO 14229-1 (over CAN ISO-TP, CAN-FD or DoIP)
[(transport header)] [SID:1B][Sub-fn:0–1B][Parameters:var]| Off | Size | Field | Value | Description |
|---|---|---|---|---|
| 0 | 0–2 B | Transport (CAN ISO-TP) | 07 E0 02 | Tester CAN ID 0x7E0 + Single-Frame PCI (length 2). |
| 2 | 1 B | SID | 0x22 | ReadDataByIdentifier. |
| 3–4 | 2 B | DID | F1 90 | Data identifier — 0xF190 = VIN. |
| 5…7 | pad | ISO-TP padding | CC CC CC | Padded to 8 bytes per ISO 15765-2. |
| Off | Size | Field | Value | Description |
|---|---|---|---|---|
| 0 | 0–2 B | Transport (CAN ISO-TP) | 07 E8 10 14 | ECU CAN ID 0x7E8 + First-Frame PCI (length 0x014 = 20). |
| 2 | 1 B | SID + 0x40 | 0x62 | Positive response to 0x22. |
| 3–4 | 2 B | DID echo | F1 90 | Same DID echoed back. |
| 5…21 | 17 B | Data | 57 30 4C … 39 | ASCII VIN 'W0L000123456789'. |
Negative response = 0x7F <SID> <NRC>. NRC 0x78 (responsePending) lets the ECU ask for more time.
Use cases
- · Workshop diagnostics
- · ECU flashing
- · End-of-line programming
- · Coding & calibration
Pros
- Standardized across OEMs
- Rich service catalog
- Works over CAN, CAN-FD, DoIP
Cons
- Security access still vendor-specific
- Complex state machines
Request / Response examples
Read VIN — ReadDataByIdentifier (0x22 F1 90)
Positive response = SID+0x40. Bytes after DID 0xF190 spell 'W0L000123456789'.
Switch to programming session (0x10 02)
ECU confirms session change, returning P2 (50 ms) and P2* (5000 ms) timing.
All UDS services (ISO 14229-1)
Switches the ECU between diagnostic sessions (default, programming, extended).
10 <sub>50 <sub> P2 P2*0x01defaultSession0x02programmingSession0x03extendedDiagnosticSession0x04safetySystemDiagnosticSession
Resets the ECU (hard, key-off-on, soft).
11 <sub>51 <sub>0x01hardReset0x02keyOffOnReset0x03softReset
Clears DTCs by group identifier (0xFFFFFF clears all).
14 <group:3>54Reports stored DTCs and their status.
19 <sub> [mask]59 <sub> <DTC list>0x01reportNumberOfDTCByStatusMask0x02reportDTCByStatusMask0x06reportDTCExtDataRecordByDTCNumber
Reads data record(s) for one or more 16-bit DIDs.
22 <DID:2>62 <DID:2> <data>Reads raw memory at a given address/length.
23 <ALFID> <addr> <len>63 <data>Seed/key handshake to unlock protected services.
27 <level>67 <level> <seed>0x01requestSeed (level 1)0x02sendKey (level 1)
Enables/disables tx/rx of normal communication frames.
28 <ctrl> <commType>68 <ctrl>Writes a data record for a 16-bit DID.
2E <DID:2> <data>6E <DID:2>Forces an actuator/input value (e.g. force fan ON).
2F <DID:2> <ctrl> [value]6F <DID:2> <ctrl> <state>Starts, stops or queries a routine (RID).
31 <type> <RID:2> [params]71 <type> <RID:2> [result]0x01startRoutine0x02stopRoutine0x03requestRoutineResults
Initiates an ECU download (flashing).
34 <DFI> <ALFID> <addr> <size>74 <LFID> <maxBlockLen>Initiates an ECU upload (read-out).
35 <DFI> <ALFID> <addr> <size>75 <LFID> <maxBlockLen>Transfers a block during download/upload.
36 <bsc> <data>76 <bsc>Terminates a download/upload sequence.
3777Writes raw memory at a given address.
3D <ALFID> <addr> <len> <data>7D <ALFID> <addr> <len>Keep-alive to prevent session timeout (S3 timer).
3E <sub>7E <sub>0x00zeroSubFunction (response required)0x80suppressPosRspMsgIndicationBit
Enables/disables DTC storage during testing.
85 <sub>C5 <sub>0x01on0x02off
Negative Response Codes (NRCs)
| Code | Meaning |
|---|---|
| 0x10 | generalReject |
| 0x11 | serviceNotSupported |
| 0x12 | subFunctionNotSupported |
| 0x13 | incorrectMessageLengthOrInvalidFormat |
| 0x22 | conditionsNotCorrect |
| 0x24 | requestSequenceError |
| 0x31 | requestOutOfRange |
| 0x33 | securityAccessDenied |
| 0x35 | invalidKey |
| 0x36 | exceedNumberOfAttempts |
| 0x37 | requiredTimeDelayNotExpired |
| 0x72 | generalProgrammingFailure |
| 0x78 | requestCorrectlyReceivedResponsePending |
| 0x7E | subFunctionNotSupportedInActiveSession |
| 0x7F | serviceNotSupportedInActiveSession |