Skip to Content
UDS Simulator 2.0 Released

Docs baseline actions

Copy this page URLEdit page
Docs0x31 Routine Control

Service Interaction Protocol

Routine Control

0x31
Protocol Identifier
The RoutineControl service is used to execute defined sequences of instructions (routines) in the ECU. Routines can perform actuator tests, self-tests, memory erasure, and other manufacturer-specific operations.
warning _entry

High Risk: Some routines perform irreversible operations — erasing flash, writing calibration, or driving actuators. Running the wrong routine, or running one with the vehicle in the wrong state, can damage the ECU or the vehicle.

0x31

RoutineControl

Execute, stop, and query named ECU routines

Sub-functions

0x01

startRoutine

Begin executing the routine

0x02

stopRoutine

Abort a running routine (if stoppable)

0x03

requestRoutineResults

Poll status / get results

Key Facts

Service ID
0x31
Positive Response
0x71
Min request length
4 bytes (SID + SF + 2-byte RID)
RID
16-bit, big-endian (0x0000–0xFFFF)
Typical session
EXTENDED (0x03) / PROGRAMMING (0x02)
ISO ref
ISO 14229-1:2020 §9.5

Routine Status Byte (Response Byte 4)

0x00In Progress / Started
0x01Completed

Overview

ISO 14229-1

“The RoutineControl service is used by the client to start, stop, or request results for defined execution sequences within the ECU.”

UDS Routine Lifecycle and Control Flow
Click to Enlarge

The primary states and control sub-functions of the RoutineControl service.

Interactive Workflows

Step through complete RoutineControl flows — from session setup to result polling — and watch the exact bytes on the wire. Pick a scenario, then play or step through it.

Goal · Enter EXTENDED, start an actuator self-test, poll for the pass result.
Session
EXTENDED
Security
not required
Outcome
Test passed (0x01 completed)
Press ▶ Play to walk through this workflow

Routine Lifecycle

A routine is a small state machine. Drive a single routine through Start → poll → Stop and see the state, status byte, and progress change live.

Routine Lifecycle Simulator

Pick a routine, then drive it through its FSM states with Start / Poll / Stop.

Routine

Duration: 2000 ms

State

IDLE
RUNNING
COMPLETED
FAILED

Progress

0%

Last Frame

TX
RX
Status bytes: 0x00 = in progress, 0x01 = completed. Stop always returns 0x00. Poll while IDLE or any terminal state returns NRC 0x24 (sequence error). Routines marked resolve with NRC 0x72.

Sub-Functions

SubFunc
Name
Description
0x01Start RoutineBegin executing the specified routine
0x02Stop RoutineAbort a running routine (if stoppable)
0x03Request Routine ResultsGet the status/results of a routine

Routine Identifiers

The Routine Identifier (RID) is a 16-bit value (0x0000–0xFFFF) sent big-endian. Search and filter the standard range conventions, and see the session/security each category needs.

0x31

Routine Identifier (RID) Ranges

RIDs are ECU-configured (config.routines); the ranges below are ISO conventions, not a fixed list.

Session:Security:

9 ranges

0x0000–0x00FF

OEM-specific

EXTENDED
0x0100–0x01FF

Network configuration

EXTENDED
0x0200–0x02FF

Programming prerequisites

PROGRAMMINGSecurity

Examples

  • 0x0202Memory check (checksum)
  • 0x0203Check programming dependencies
0x0300–0xCFFF

OEM-specific

EXTENDEDSecurity

Examples

  • 0x0301Actuator self-test
0xD000–0xD0FF

Diagnostic-connector routines

EXTENDED
0xD100–0xEFFF

OEM-specific

EXTENDEDSecurity
0xF000–0xF0FF

Actuator & self-tests

EXTENDEDSecurity

Examples

  • 0xF001Actuator test (range start)
0xF100–0xF1FF

Sensor tests

EXTENDEDSecurity

Examples

  • 0xF156O2 sensor test
  • 0xF178Lambda test
0xF200–0xFFFF

Supplier-specific / programming ops

PROGRAMMINGSecurity

Examples

  • 0xFF00Erase memory
  • 0xFF01Check programming dependencies

Message Format

Select a frame and inspect each byte. The positive response echoes the sub-function and RID, then carries a routine-specific status record.

Hex →31 01 03 01 ..
Byte 1

SID 0x31

RoutineControl service identifier

SIDSub-FunctionRIDStatusNRC / ErrorOptional data

Session & Security

Session & Security Matrix

Which routine categories run in each session, and which need a security unlock. Select a row for details.

RoutineControl access by routine category, diagnostic session, and security state.
Routine type
DEFAULT
0x01
EXTENDED
0x03
PROGRAMMING
0x02
Security
required
required
required
required
required

Check order: in this simulator the RID-range check (0x31 requestOutOfRange) runs before the session and security checks — an unknown RID returns 0x31 even when the session would also be wrong.

warning _entry

Session Timeout (S3): Extended and Programming sessions time out after 5 seconds with no tester activity. Send TesterPresent (0x3E) every 2–3 seconds during long-running routines to keep the session alive.

Service Dependencies

Service Dependencies

0x31 sits in a small graph of co-services. Select a node to see how it shapes a routine flow.

0x310x100x270x3E0x340x360x190x14
0x10DiagnosticSessionControlPrerequisite
Typical request
10 03

Most routines need EXTENDED (0x03) or PROGRAMMING (0x02) — else NRC 0x7F.

TX/RX Examples

Successful: Start, then poll to completion

Start a self-test, then request results until it completes.

tx_packet

Start Routine

31 01 03 01

> Start Routine 0x0301 (Actuator Test)

rx_packet

Routine Started

71 01 03 01 00

> Status 0x00 = Started / In Progress

tx_packet

Request Results

31 03 03 01

> Poll for completion

rx_packet

Completed

71 03 03 01 01

> Status 0x01 = Completed (pass)

Start returns 0x00 (in progress); the routine reports 0x01 (completed) only when polled after it finishes.

Successful: Long routine with result polling

A long-running erase that needs repeated polling.

tx_packet

Start Memory Erase

31 01 FF 00

> Start Routine 0xFF00 (Erase Memory)

rx_packet

Routine Started

71 01 FF 00 00

> Status 0x00 = Started / In Progress

tx_packet

Request Results

31 03 FF 00

> Poll for completion

rx_packet

Still In Progress

71 03 FF 00 00

> Status 0x00 = Still in progress

tx_packet

Request Results

31 03 FF 00

> Poll again...

rx_packet

Completed

71 03 FF 00 01

> Status 0x01 = Completed

Send TesterPresent (0x3E) every 2–3 seconds during long operations to keep the session alive.

Stop a running routine

Abort a running routine before it completes.

tx_packet

Stop Routine

31 02 FF 00
rx_packet

Routine Stopped

71 02 FF 00 00

> Status 0x00 — routine returns to idle

After Stop the routine is idle again. Some routines are not stoppable and will return an NRC.

Error: Request Sequence Error

Requesting results for a routine that was never started.

tx_packet

Request Results (Not Started)

31 03 03 01
rx_packet

Negative Response

7F 31 24

> NRC 0x24: Request Sequence Error

Error
Start the routine (0x01) before requesting results (0x03).

Error: Security Access Denied

A protected routine requires a security unlock.

tx_packet

Start Protected Routine

31 01 FF 00
rx_packet

Negative Response

7F 31 33

> NRC 0x33: Security Access Denied

Error
Unlock security (0x27) before executing protected routines.

Error: Request Out Of Range

Unknown routine identifier.

tx_packet

Unknown Routine

31 01 99 99
rx_packet

Negative Response

7F 31 31

> NRC 0x31: Request Out Of Range

Error
Routine 0x9999 is not implemented in this ECU. The RID range is checked before session and security.

Workflow Diagrams

Workflow 1: Simple Actuator Test (No Security)

Extended Session → Start Test → Get Results

6 steps
Tester
ECU

Workflow 2: Secured Calibration Routine (30s)

Extended → Unlock → Start → Keep Alive → Poll → Done

16 steps
Tester
ECU

Workflow 3: Memory Erase Before Flash Programming

Programming → Unlock → Erase → Poll → Download

12 steps
Tester
ECU

Workflow 4: Routine Cancellation

Start → User Stops → Routine Returns to Idle

8 steps
Tester
ECU

Workflow 5: Failure → Read DTCs → Clear → Retry

Routine Fails, Diagnose, Clear, Retry

12 steps
Tester
ECU

Routine Status Codes

Status Byte
Meaning
Notes
0x00In Progress / StartedReturned by Start, and by Request Results while still running
0x01CompletedReturned by Request Results after the routine finishes
info _entry

This simulator’s conventions: Stop returns status 0x00 and leaves the routine idle (ready to start again). A routine that fails surfaces as NRC 0x72 (generalProgrammingFailure) on Request Results — not as a status byte. The routineStatusRecord format is manufacturer-specific in ISO 14229-1; real ECUs may define richer status records.

Negative Response Codes (NRCs)

NRC Decoder — SID 0x31

9 negative response codes. Click any card to see trace and recovery steps.

NRC Priority

0x130x120x310x12 (per-RID)0x7F0x330x240x72

Order the simulator checks errors — first failing check wins.

Troubleshooting Guide

Troubleshooting Guide

Click any issue to expand diagnosis steps and resolution.

Timing Parameters

Parameter
Value
Use
P2 (Normal Response)50 msStandard request-response timeout
P2* (Extended Response)5000 msLong-running operations (memory erase, calibration)
S3 (Session Timeout)5000 msSession expires without tester activity
Tester Present Interval2000–3000 msKeep-alive frequency during routines
Security Timeout10000 msSecurity access expires if not used

ISO 14229-1 References

info _entry

Standard: ISO 14229-1:2020, Section 9.5 — RoutineControl Service

Compliance Requirements

  • Minimum request length: 4 bytes (SID + SubFunction + RID)
  • Minimum positive response length: 4 bytes (Response SID + SF + RID)
  • SubFunction parameter range: 0x01–0x03 (only three values defined)
  • RID parameter range: 0x0000–0xFFFF (manufacturer-defined)
  • Option record (request) is optional, routine-specific
  • Status record (response) is optional, routine-specific

Related ISO Sections

Section
Topic
9.3DiagnosticSessionControl (prerequisite)
9.4SecurityAccess (for protected routines)
9.6CommunicationControl
9.11TesterPresent (keep-alive)
10.1NRC definitions (Annex B)
Annex ARoutine identifier ranges