DEV Community

smbalawad
smbalawad

Posted on

UDS Services

Hello Readers,
My name is Sadashiv, and I work as a junior software engineer at Luxoft India. I'm happy to share this post, in which I relate my previous experience with UDS services.

1. ** Tester present(0x3E)**
• The Tester present’s service ID is 0x3E and the Response SID is 0x7E.
• This service is used to indicate to the server that the client is still connected to the server.
• This service is used to keep the server alive in the current session except for the default session.
• To keep the client in the current session (Non-default session) tester present (0x3E) is used, and the client will send this service (0x3E) periodically.
• If the client is not exchanging any data with the server for more than the S3 timer value of approximately 5 seconds, the server (ECU) will get disconnected for safety purposes and automatically fall back to the Default session.
• If client requested with service, then server will maintain whatever the session is running at the ECU side we can called it as active session.
• For example, ECU is downloading any SW into the logical blocks with request to download service this service will happen in extended session for this we don’t know how much time it will takes ECU to download for this type of situation tester present request will help more to present in active session, if we didn’t request Tester present then ECU will come from active session to default session.

Message format:
Diag_RQ: 0x18DAXXX: 02 3E 00 00 00 00 00 00
Diag_RS: 0x18DAXXX: 02 7E 00 00 00 00 00 00

Supported Negative response codes:
12-SubFunctionNotSupported
13-IncorrectMessageLength or InvalidFormat

2. Read Data by Identifier(0x22)

  • Read Data by Identifier SID is 0x22 and the Response is 0x62.
  • Read Data by Identifier services allows the tester to request the server for recorded data. With this service, the tester can retrieve one or more data from the server.
  • To read some sensitive data from Server using Read Data by Identifiers, the identifiers may require security access granted from the server.
  • After getting security access from the server, then only the Client can read the data.
  • The data identifiers list should be present with the client to read the data, else there would be a negative response sent by the server.
  • The client can request more than one data by identifier at the same time.
  • The ECU would combine the data for all the DIDs in one single positive response to the client.

Message format:
Diag_RQ: 0x18DAXXX: 03 22 03 13 00 00 00 00
Diag_RS: 0x18DAXXX: 07 62 03 13 01 02 03 04

Supported Negative response codes:
13-IncorrectMessageLength or InvalidFormat
14-ResponseTooLong
22-CondtitionsNotCorrect
31-RequestOutOfRange
33-SecurityAccessDenied

1.Diagnostic session Control(0x10)
• The diagnostic session’s service ID is 0x10 and the Response SID is 0x50.
First understand What is session.
“A session is Time period where the communication channel is active between participating entities .

  • It can be two or more entities but, in our case, it is two entities.
  • So, during that time communication can happen.
  • Why we are doing it only for particular period of time because when session is happening, when communication is happening. It takes a lot of power resources and it blocks some of the other functionality etc.
  • In our case that two entities are
    i. Tester
    ii. ECU
    Tester and ECU are connected in client server Topology.
    Tester acts as Client and ECU acts as server
    • Diagnostic Session control is used for controlling the diagnostic session of the ECU.
    • This service is used to change the current diagnostic session to a different session.
    • There are many services available in UDS, but all the services cannot access the ECU.
    • Some services can access only if the ECU is in the Default session and some of the other services can access the ECU in other sessions.
    • Let’s say for example in the default session we cannot upgrade the software for the ECU because the Default session doesn’t have access to re-program the ECU.
    • Only in the programming session, we have the access to re-program the ECU by the authorized line engineers.
    • The main purpose of this diagnostic session is to give security to the ECU.
    • It will prevent the ECU from unwanted access. And only an authorized person can access it.
    • If every diagnostics service can access the ECU, it may get damaged with the wrong flashing of software.
    • So before doing any diagnostic request, the Client must make sure that this service is accessible or not in ECU current session. If not, then first send a request for session change after that desirable request shall be performed.
    Diagnostic session control has Four Sub Functions
    1.Default session(0x01)
    2.Programming session(0x02)
    3.Extended session(0x03)
    4.Safety system Diagnostic session(0x04)

  • For communication between Tester and ECU a particular session must be maintained in between them.

  • Depending upon what is the purpose of the session, the different diagnostic session should be enabled/disabled.

  1. Default session(0x01) • Whenever the ECU is powered ON, it will be in this default session only. • ECU remains in default session until another diagnostic session is requested from the client. • Services like Write data byte identifier (0x2E), Read data byte identifier (0x22), ECU Reset (0x11), Tester Present (0x3E), Reading DTC (0x19) are available in this session.

Example: In a garage, a person is trying to read the Diagnostic Trouble Code(DTC).

  1. Programming Session(0x02)
    • This Session is used to program the ECU or transfer data from client to server.
    • ECUs are entered into default session if this session is ended or expired.
    • If the purpose of our tester communication with the ECU is to flash new software, then this session should be used.

  2. Extended Session(0x03)
    • If the purpose of our tester communication is to debug the some of the functionality or some of the errors present in the ECU, this session should be used.
    •This session is used to unlock the additional diagnostic functions also.
    • Security access(0x27) is allowed in this session, meaning security levels are unlocked in this session.
    • ECUs entered into default session if this session is ended or expired.

4.Safety system Diagnostic session(0x04)
• Used to test all safety-critical diagnostic functions.
• The diagnostic session enables all diagnostic services required to support safety system related functions.

Example: This session is checking the safety of Airbags, and tire pressure monitors.

Supported Negative response codes:
12-SubFunctionNotSupported
13-IncorrectMessageLength or InvalidFormat
22-ConditionsNotCorect

Default session Message format:
Diag_RQ: 0x18DAXXX: 02 10 01 00 00 00 00 00
Diag_RQ: 0x18DAXXX: 02 50 01 00 00 00 00 00

Conclusion

This article has given an explanation of important services, in the Unified Diagnostic Services (UDS) protocol. It has provided insights into what these services do. How they format their messages. UDS is vital for diagnostics as it facilitates communication between tools and electronic control units (ECUs), in vehicles.

Top comments (0)