How langroodi/obd-ii-emulator works
OBD-II-Emulator is a Linux library that answers OBD-II scanner queries received from a USB-CAN Analyzer over serial. Its principal workflow is serial byte reception, CAN packet decoding, query/PID parsing, service dispatch, response framing, and serial transmission. It supports synchronous and asynchronous handling, configurable CAN framing, and user-supplied OBD services. The README documents the end-to-end hardware flow; sampled implementation excerpts substantiate the emulator’s routing and serial buffering, but not every internal CAN-driver operation.
Main entry points: obd_emulator.cpp OBD emulator · serial_communication.cpp Serial communication · communication_layer.cpp Communication interface · can_driver.cpp CAN packet driver
Components 11
Serial transport
- Serial communication
src/serial_communication.cpp - Communication interface
src/communication_layer.cpp - Packet send buffer
src/packet_buffer.cpp
CAN framing
- CAN packet driver
src/can_driver.cpp - CAN frame
src/can_frame.cpp
OBD query handling
- OBD emulator
src/obd_emulator.cpp
OBD services
- OBD service contract
src/obd_service.cpp - Current-data service
samples/current_data_obd_service.cpp - Sample application
samples/obd_emulator_sample.cpp
Other components
- OBD-II scanner
- USB-CAN Analyzer
Connections 11
- OBD-II scanner → USB-CAN Analyzer: sends queries
README.md - USB-CAN Analyzer → Serial communication: serial packets
README.md - Serial communication → Communication interface: implements
- Serial communication → Packet send buffer: buffers sends
src/serial_communication.cpp - Communication interface → OBD emulator: dispatches received data
- OBD emulator → CAN packet driver: decodes and encodes
src/obd_emulator.cpp - CAN packet driver → CAN frame: converts packets
README.md - OBD emulator → OBD service contract: routes by service
src/obd_emulator.cpp - Current-data service → OBD service contract: implements
- Sample application → Current-data service: configures
- OBD emulator → Communication interface: sends responses
src/obd_emulator.cpp