Python-uds

Python-uds is a communication protocol agnostic UDS tool.

It was designed to provide a high-level uds interface which can utilise any communication protocol (e.g. LIN, FlexRay, DoIP). It has a parser tool which can parse an ODX file and produce an easy-to-use interface based on the ODX definition.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import uds 
from uds import Uds

if __name__ == "__main__":

    # This creates an Uds object from the Bootloader.odx file
    odxEcu = uds.createUdsConnection("Bootloader.odx", "", inteface="peak")
    
    # This sends a request for Ecu Serial number and stores the result
    esn = odxEcu.readDataByIdentifier("ECU Serial Number")
    
    # This will be the printed ASCII string
    print(esn)
    
    # This creates a Uds object manually
    rawEcu = Uds(reqId=0x7E0, resId=0x7E8, interface="peak")
    
    # This sends the request for Ecu Serial Number
    esnRaw = rawEcu.send([0x22, 0xF1, 0x8C])
    
    # This prints the raw payload returned from the ECU
    print(esnRaw)

This is an example of how to interface with an ECU using both the raw object and the methods created from the Bootloader.odx file.

Currently it supports diagnostics on CAN using a CAN Transport Protocol defined in ISO-15765 and uses the python-can package to utilise the can device interface.

The final report is available in the repository.