UDS Protocol Explained (ISO 14229): Services, Sessions, Security Access and NRCs

CAN Bus4 min read
UDS protocol request and response frames on the CAN bus
On this page

UDS (Unified Diagnostic Services, ISO 14229) is the protocol that diagnostic testers use to talk to a car’s control modules. When a workshop tool reads fault codes from the ABS module, reads the VIN, runs an injector test or flashes new software into an ECU, it is almost always sending UDS requests. On most cars the messages travel over CAN using ISO-TP (ISO 15765-2), and on newer cars also over Ethernet (DoIP).

For anyone learning car hacking, UDS is the most important protocol after CAN itself: it is the official door into every module.

How a UDS message looks

Every request starts with a service ID (SID), one byte that says what you want. Most services are followed by a sub-function or a data identifier.

  • Positive response: SID + 0x40. A request with 22 is answered with 62.
  • Negative response: 7F, then the SID, then a negative response code (NRC) that tells you why.

On CAN, the tester usually sends on ID 7E0 (engine ECU) and the ECU answers on 7E8. The first data byte is the ISO-TP length.

7E0  03 22 F1 90           read data by identifier F190 (VIN)
7E8  10 14 62 F1 90 57 41 55   first frame, 20 bytes follow
7E0  30 00 00              flow control: send the rest
7E8  21 5A 5A 5A ...       consecutive frames

The most important services

SIDServiceWhat it does
0x10DiagnosticSessionControlSwitch session: default, programming, extended
0x11ECUResetRestart the module
0x14ClearDiagnosticInformationClear fault codes
0x19ReadDTCInformationRead fault codes and their status
0x22ReadDataByIdentifierRead a value by DID (VIN F190, software version, sensor data)
0x23ReadMemoryByAddressRead memory directly, if allowed
0x27SecurityAccessSeed and key unlock for protected functions
0x28CommunicationControlStop or start normal messages, used before flashing
0x2EWriteDataByIdentifierWrite a value, for example coding or VIN
0x2FInputOutputControlByIdentifierActuator tests: fans, lights, injectors
0x31RoutineControlStart routines such as erase memory or calibrations
0x34 / 0x36 / 0x37RequestDownload, TransferData, RequestTransferExitSoftware download (flashing)
0x3ETesterPresentKeep a non-default session alive
0x85ControlDTCSettingStop the module from logging faults during work

Diagnostic sessions

SessionByteTypical use
Default0x01Reading codes and basic data, always active after start
Programming0x02Flashing software
Extended0x03Coding, actuator tests, more data

Many services only work in the extended or programming session. If you leave a session idle, the module returns to default after a timeout (often about 5 seconds), so testers send TesterPresent (3E 00) regularly.

Security access (0x27)

Protected services such as writing coding or flashing need a seed and key unlock:

  1. The tester requests a seed: 27 01.
  2. The ECU answers with a random seed: 67 01 A3 5C 91 0E.
  3. The tester calculates a key with the manufacturer’s algorithm and sends it: 27 02 + key.
  4. If the key is right, the ECU answers 67 02 and the protected services unlock.

Wrong keys lead to NRC 0x35 (invalid key), and too many attempts to 0x36 and a time lock (0x37). A real example on a body module is in our Subaru BRZ security access lab.

Negative response codes you will see

NRCMeaningWhat to try
0x11Service not supportedThe module does not offer this service
0x12Sub-function not supportedWrong sub-function byte
0x13Incorrect message lengthCheck the ISO-TP length and data
0x22Conditions not correctEngine running, speed or voltage condition not met
0x31Request out of rangeUnknown DID or routine
0x33Security access deniedUnlock with 0x27 first
0x35Invalid keyWrong key calculation
0x78Response pendingWait, the module is still working
0x7FService not supported in active sessionSwitch to the extended or programming session

Try it on a bench or simulator

On Linux with a CAN adapter and SocketCAN, the can-utils isotpsend and isotprecv tools handle ISO-TP for you:

echo "22 F1 90" | isotpsend -s 7E0 -d 7E8 can0
isotprecv -s 7E0 -d 7E8 can0

No car on the bench? Practise CAN first with the ICSim simulator tutorial, and keep the can-utils cheat sheet open. Only send requests to vehicles and modules you own or have permission to test: routines and writes can change how a car behaves.

Frequently asked questions

What is the difference between OBD-II and UDS?

OBD-II (SAE J1979) is the legislated emissions diagnostic with a fixed set of services and PIDs. UDS is the much larger manufacturer diagnostic protocol used for all modules, coding and flashing.

Does UDS only work on CAN?

No. UDS is the application layer. It runs over CAN with ISO-TP, over Ethernet with DoIP (ISO 13400), and over other transports such as FlexRay or K-line variants.

What is a DID?

A data identifier, a two-byte number for a value inside the module. F190 is the VIN, F187 the spare part number, F18C the serial number. Manufacturers define many more of their own.

Why does the ECU answer 7F 22 22?

That is a negative response to ReadDataByIdentifier with NRC 0x22, conditions not correct. The module will not answer in the current state; check the session, the ignition state and the engine state.

Sending diagnostic requests to your own vehicle or to bench modules you own is generally legal. Accessing other people’s vehicles without permission is not.

Learn UDS hands-on

Our Car Electronics and Car Hacking course takes you from raw CAN frames to ISO-TP and UDS: capturing real diagnostic sessions, decoding them, and sending your own requests safely on a bench setup.

Written by

Taifun Mamedov

Founder and instructor at Ocsaly Academy.

Courses by Taifun Mamedov

Share this article