Service Interaction Protocol
Routine Control
SERVICE_ACCESS
PROTOCOL_LAYER
RID_SIZE
Overview
“The RoutineControl service is used by the client to start, stop, or request results for defined execution sequences within the ECU.”

The primary states and control sub-functions of the RoutineControl service.
Default Behavior
By default, no routines are active or running within the ECU. Service 0x31 is primarily available in the Extended Diagnostic Session (0x03) or Programming Session (0x02). State transitions (like reset or session timeout) will automatically abort any running routines to ensure system safety.
Sub-Functions
SubFunc | Name | Description |
|---|---|---|
| 0x01 | Start Routine | Begin executing the specified routine |
| 0x02 | Stop Routine | Abort a running routine (if stoppable) |
| 0x03 | Request Routine Results | Get the status/results of a routine |
Interactions & Common Routines
Prerequisites
- DiagnosticSessionControl (0x10) - Most routines require Extended (0x03) session
- SecurityAccess (0x27) - Protected routines require security unlock
- TesterPresent (0x3E) - Maintain session during long-running routines
Common Routines
- 0xFF00 - Erase Flash Memory (Prerequisite for Download (0x34))
- 0x0203 - Check Programming Dependencies
- 0x0202 - Check Memory (Post-requisite for Transfer Data (0x36))
- 0x0301 - Actuator Self-Test
Message Format
Byte | Field | Value | Description |
|---|---|---|---|
| 0 | SID | 0x31 | RoutineControl |
| 1 | Sub-Function | 0x01-0x03 | Start, Stop, or Request Results |
| 2-3 | Routine ID | 0xXXXX | 2-byte Routine Identifier |
| 4-N | Option Record | ... | Optional routine parameters |
◆ PROTOCOL ANATOMY
0x31 ROUTINE CONTROL
0x31 RESPONSE
TX/RX Examples
Successful: Start and Complete Routine
Execute a self-test routine that completes immediately.
Start Routine
31 01 03 01> Start Routine 0x0301 (Actuator Test)
Routine Started
71 01 03 01 00> Status 0x00 = Completed Successfully
Successful: Async Routine with Result Polling
Long-running routine that requires status polling.
Start Memory Erase
31 01 FF 00> Start Routine 0xFF00 (Erase Memory)
Routine Running
71 01 FF 00 01> Status 0x01 = Running
Request Results
31 03 FF 00> Poll for completion
Still Running
71 03 FF 00 01> Status 0x01 = Still Running
Request Results
31 03 FF 00> Poll again...
Completed
71 03 FF 00 00> Status 0x00 = Completed
Stop Running Routine
Abort a running routine before completion.
Stop Routine
31 02 FF 00Routine Stopped
71 02 FF 00 02Error: Request Sequence Error
Requesting results for a routine that wasn’t started.
Request Results (Not Started)
31 03 03 01Negative Response
7F 31 24> NRC 0x24: Request Sequence Error
Error: Security Access Denied
Protected routine requires security unlock.
Start Protected Routine
31 01 FF 00Negative Response
7F 31 33> NRC 0x33: Security Access Denied
Error: Request Out Of Range
Unknown routine identifier.
Unknown Routine
31 01 99 99Negative Response
7F 31 31> NRC 0x31: Request Out Of Range
UML Sequence Diagrams
Memory Erase Before Flash Programming
Unlock → Erase Memory → Poll → Download
10 stepsRoutine Status Codes
Code | Status | Description |
|---|---|---|
| 0x00 | Completed Successfully | Routine finished without errors |
| 0x01 | Running | Routine still executing |
| 0x02 | Stopped | Routine stopped by user |
| 0x03 | Failed | Routine completed with errors |
Session Timeout: Long-running routines may exceed the S3 timer (5s). Use periodic TesterPresent (0x3E) to maintain the session during async routine execution.
Negative Response Codes (NRCs)
Error_Catalog