CAN - Controller Area Network

contents

The Controller Area Network (CAN) bus is a high-integrity serial communication protocol designed for real-time data exchange in embedded systems, particularly in automotive and industrial applications. It operates on a multi-master, message-oriented architecture, allowing multiple devices (nodes) to communicate on the same network without a central controller.

Interact#

pip install python-can
pip install python-can-utils
import can
bus = can.Bus()
while True:
    msg = can.Message(3, data=[0 for _ in range(8)])
    bus.send(msg)

UDS#

Unified Diagnostic Services (UDS) is a communication protocol used in automotive Electronic Control Units (ECUs) to enable diagnostics, firmware updates, routine testing and more.

Implementation#

UDS message structure
UDS message structure

SID#

UDS SID (Request)UDS SID (Response)UDS ServiceDetails
0x100x50Diagnostic session controlControl which UDS services are available.
0x110x51ECU ResetIt resets the ECU (includes hard reset, key off and soft reset)
0x270x67Security accessIt enables use of security critical services via authentication.
0x280x68Communication controlThis field turns send/receive of messages ON or OFF in the ECU.
0x290x69AunthenticationEnables more advanced authentication vs. 0x27 (PKI based exchange).
0x3E0x7ETester presentSend a heartbeat message periodically to remain in existing session .
0x830xC3Access timing parametersView/Modify timing parameters used in client/server communication.
0x840xC4Secured Data TransmissionSend encrypted data via ISO 15764 (extended data link security)
0x850xC5Control DTC SettingsEnable/Disable detection of errors (e.g. used during diagnostics)
0x860xC6Response On EventRequest that ECU processes a service request if an event happens
0x870xC7Link ControlSet the baud rate for diagnostic access
0x220x62Read Data by IdentifierRead data from targetted ECU - e.g. VIN, sensor data etc.
0x230x63Read Data by AddressRead data from physical memory (e.g. to understand software behaviour)
0x240x64Read Scaling Data By IdentifierRead information about how to scale data identifiers
0x2A0x6ARead Data by Identifier PeriodicRequest ECU to broadcast sensor data at slow/medium/fast/stop rate
0x2C0x6CDynamically Define Data IdentifierDefine data parameter for use in 0x22 or 0x2A dynamically
0x2E0x6EWrite Data By IdentifierProgram specific variables determined by data parameters
0x3D0x7DWrite Memory By addressWrite information to the ECU’s memory
0x140x54Clear Diagnostic InformationDelete stored DTCs
0x190x59Read DTC InformationRead stored DTCs as well as related information
0x2F0x6FInput Output Control By IdentifierGain control over ECU analog/digital inputs/outputs
0x310x71Routine ControlInitiate/stop routines (e.g. self testing, erasing of flash memory)
0x340x74Request DownloadStart request to add software/data to ECU (including location/size)
0x350x75Request UploadStart request to read software/data from ECU (including location/size)
0x360x76Transfer DataPerform actual transfer of data following use of 0x74/0x75
0x370x77Request Transfer ExitStop the transfer of data
0x380x78Request File TransferPerform a file download/upload to/from the ECU
0x7FNegative ResponseSend with a negative response code when a request can not be handled.

References#