richClubb / python-uds

A uds library for python
MIT License
99 stars 55 forks source link

Support for multiple ECUs on single connection #45

Closed happyh66 closed 5 years ago

happyh66 commented 5 years ago

The initial implementation does not allow for more than one ECU (Uds class) to use a shared 'bus' connection. This is due to the 'bus' being tightly coupled to the CanTp class (one-to-one with Uds class also). Idea would be to create a small additional class to encapsulate the CAN Connection. This would contain the bus and allow multiple callbacks (CanTp instances). It is also possible to add filters (which CAN Ids are let through) to the bus - so this could be implemented in this new class.

happyh66 commented 5 years ago

The CanConnection.py class has been created to add encapsulation of the Bus instance + add the ability to add multiple callbacks. The CanConnectionFactory class has been modified accordingly. Tested with a single hardware interface (both Peak & Vector) and two Uds/CanTp ECU connections from a test python script - using threads performed multiple RDBI requests to both ECUs simultaneously & also simultaneous software download.