Frequently Asked Question

Does Typhoon HIL support UDS on CAN protocol?
Last Updated 4 months ago


The following sections provide a brief introduction to UDS protocol and its implementation in the Typhoon HIL toolchain.

1. Introduction

The Unified Diagnostic Services (UDS) communication protocol is a standardized diagnostic protocol used in the automotive industry for communicating with and diagnosing electronic control units (ECUs) in vehicles. It can operate over Controller Area Network (CAN) bus, a widely-used communication network in modern vehicles.

Unified Diagnostic Services (UDS) is a client-server protocol commonly used in the automotive industry for diagnostic communication between a client (usually a diagnostic tool or tester) and a server (an electronic control unit or ECU within a vehicle). In this context:

  1. Client: The client, typically a diagnostic tool or software application, initiates communication with the ECU by sending diagnostic requests and commands.
  2. Server: The server, which is the ECU within the vehicle, responds to the client's requests, providing diagnostic information, performing actions requested by the client, and managing the internal functions of the ECU.

2. UDS in Typhoon HIL toolchain

UDS Client is supported in the Typhoon HIL toolchain in HIL SCADA, via the Python library udsoncan. Parsing and importing of CDD files is done with the Python library cantools. UDS Server is not supported in the Typhoon HIL toolchain.

Attached below is an example HIL SCADA panel file, where you can open the widget properties and write the Python code you want to execute.

First, import the libraries and modules for XCP communication and other libraries.

import isotp

from udsoncan.connections import *
from udsoncan.client import Client
import cantools
from udsoncan import DataIdentifier, IOValues
from udsoncan.configs import default_client_config
import os.path, os

To access additional Python scripts in your simulation, you will need to append the path for the script to the system path.

from uds_script import UDSclass, create_config_dict

The CDD file plays a crucial role in defining the communication parameters and structure for diagnostic communication between a diagnostic tool (such as a scan tool or diagnostic tester) and the electronic control unit (ECU) within a vehicle. To load this file, we use the cantools library and the create_config_dict function:

database_uds_example = cantools.db.load_file(uds_example_path)
config = dict(default_client_config)
config = create_config_dict(database=database_uds_example, config=config)

To initialize the UDS Client we need to define the link layer, network layer, transport layer, and the interface between the application and transport layer:

bus = VectorBus(channel=0, bitrate=500000, app_name="UDSsim") - Link Layer (CAN protocol)
tp_addr = isotp.Address(isotp.AddressingMode.Normal_11bits, txid=0x700, rxid=0x600)- Network layer
stack = isotp.CanStack(bus=bus, address=tp_addr, params=isotp_params) - Network/Transport layer (IsoTP protocol)
conn = PythonIsoTpConnection(stack) - interface between Application and Transport layer

After we have created the connection layers and config parameters, we can create the UDS Client:  

with Client(conn=conn, request_timeout=3, config=config) as client:

After that, we can use the functions defined in the udsoncan library (open, close, tester_present) to communicate with the server and get additional information. 

Here is an example how to communcate with the server:

# Read and write data example for did = "Windows"
 uds.read_data(client=client, database=database_uds_example, did_ident=0x81)

 uds.write_data(client, database_uds_example, name="Windows", value=(0x04, 0x03, 0x02, 0x01))

 uds.read_data(client, database_uds_example, did_ident=0x81)

 uds.io_control_write(client, database_uds_example, name="Windows", values=(0x08, 0x07, 0x06, 0x05))

The read_data function reads the data from a specific ECU data identifier, while the write_data function writes data to a specific ECU data identifier.

An example UDS script is attached. Feel free to adapt the scripts provided to your needs.

Please Wait!

Please wait... it will take a second!