uds on python

Python implementation of UDS standard (ISO-14229)

This article is for them those are interested to learn the automotive automation testing using open source programming language python udsoncan.  Since the automotive vehicles are having a complex computer system with a number of ECU connected in multiple networking protocols, it is very difficult to handle them for software validation in the testing phase. But if you have this environment to do it then you might have to pay a lot to make this testing environment. To do it at a low cost, there are so many software platforms available but to write the test scripts for automation python will be the best for the latest cut edge technology.

The python is available in most of the latest computer system which you can use it effectively. You can say, windows, Linux, etc. mostly all of the OS supports python. So for this purpose, most of the OEMs and Tier1 companies are moving their test automation platform to free open source python udsoncan which will reduce the cost and time also. To make this platform is the main objective that how to make it possible with a complex networking environment with a different protocol. 

In the automotive vehicle, there are different protocols which are getting used for communication, diagnostic and power supply purpose. basically how to make this possible with CAN which is a communication protocol and UDS which is a diagnostic protocol. let’s go discuss these two protocols and how to implement a test program using python for doing the diagnostic on the vehicle which called python udsoncan

The goal of this design is to provide a set of tools to interact with a UDS server by building or interpreting UDS payload and detecting malformed messages. All of this, with minimal effort and comprehensive code. It can be useful to develop a tester unit, debugging a server code, searching for security flaws, or just messing with your car.

This is an implementation of the Unified Diagnostic Services (UDS) protocol defined by ISO-14229 written in Python 3. 

Lets go for a example how to use the python for this so that you can design your own UDS On Can.

import SomeLib.SomeCar.SomeModel as MyCar

import udsoncan
from udsoncan.connections import IsoTPConnection
from udsoncan.client import Client
from udsoncan.exceptions import *
from udsoncan.services import *

conn = IsoTPConnection(‘can0’, rxid=0x123, txid=0x456)
with Client(conn, request_timeout=2, config=MyCar.config) as client:
client.change_session(DiagnosticSessionControl.Session.extendedDiagnosticSession) # integer with value of 3
client.unlock_security_access(MyCar.debug_level) # Fictive security level. Integer coming from fictive lib, let’s say its value is 5
vin = client.write_data_by_identifier(udsoncan.DataIdentifier.VIN, ‘ABC123456789’) # Standard ID for VIN is 0xF190. Codec is set in the client configuration
print(‘Vehicle Identification Number successfully changed.’)
client.ecu_reset(ECUReset.ResetType.hardReset) # HardReset = 0x01
except NegativeResponseException as e:
print(‘Server refused our request for service %s with code “%s” (0x%02x)’ % (e.response.service.get_name(), e.response.code_name, e.response.code))
except InvalidResponseException, UnexpectedResponseException as e:
print(‘Server sent an invalid payload : %s’ % e.response.original_payload)

Enjoy the DoCan using Python………….!

Notify of
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Scroll to Top