langroodi / OBD-II-Emulator

Linux ODB-II Emulator to interact with OBD2 Scanners via CAN
MIT License
32 stars 13 forks source link
automotive can-bus emulator linux obd-ii obd2

OBD-II-Emulator

example workflow

This is an OBD-II emulator via CAN over Linux that handles diagnostics queries of OBD2 scanners. The emulator listens to the CAN packets coming from the USB-CAN Analyzer device over a serial communication and by using the device CAN driver, converts the packets to CAN frames. Then the OBD emulator extracts the parameter ID (PID) from the frames and routes them to the corresponding OBD service as shown below:

                                 +-------------------------+                                
                                 | Serial Communication :  |                                
                                 | Communication Layer     |                                
                                 +------------|------------+                                
                                              |                                             
                                         Byte Array                                         
                                              |                                             
                                 +-------------------------+                                
                                 |       CAN Driver        |                                
                                 |                         |                                
                                 +------------|------------+                                
                                              |                                             
                                          CAN Frame                                         
                                              |                                             
                                 +------------|------------+                                
                                 |      OBD Emulator       |                                
                                 |                         |                                
                                 /------------|------------\                                
                               /-             |             -\                              
                            PID              PID             PID                            
                           /-                 |                -\                           
+--------------------------      +------------|------------+     --------------------------+
|     OBD Service(0)      |      |     OBD Service(i)      |     |     OBD Service(n)      |
|                         |      |                         |     |                         |
+-------------------------+      +-------------------------+     +-------------------------+

Dependecies

The current library has two categories of dependency as follows:

Hardware dependencies

Software dependencies

Documentation

The library documentation is available from GitHub Pages which is powered by Doxygen .

Samples

The library samples build is disabled by default. To be able to build the library with the samples, following bash command can be used:

cmake -S . -B build -Dbuild_samples=ON
cmake --build build
# To run the tests:
cd build && ctest