ejvaughan / obdii

C API for OBD-II vehicle diagnostics
MIT License
129 stars 48 forks source link

Add support for dynamically discovering ECUs #1

Open ejvaughan opened 7 years ago

ejvaughan commented 7 years ago

Overview

Currently, opening a socket to an ECU requires knowing a priori that an ECU with the given (transfer ID, receive ID tuple exists on the bus. We should allow users to dynamically discover the available ECUs they can communicate with.

According to the OBD-II standard, ECUs that use 29-bit identifiers will respond to the broadcast address 0x18db33f1 with an address in the range 0x18daf1xx, and ECUs that use 11-bit identifiers will respond to the broadcast address 7df with an address in the range 0x7e8 - 0x7ef. This should allow us to dynamically discover the available ECUs by sending a mode 1, pid 0 request to the broadcast addresses using a raw CAN socket, and seeing which ECUs respond.