Woman, Life, Freedom


OBD-II Emulator
Linux ODB-II Emulator public and protected interfaces documentation
obd_emulator.h
1#ifndef OBD_EMULATOR_H
2#define OBD_EMULATOR_H
3
4#include <map>
5#include "./communication_layer.h"
6#include "./can_driver.h"
7#include "./obd_service.h"
8
9namespace ObdEmulator
10{
13 {
14 private:
15 CommunicationLayer *mCommunicationLayer;
16 const CanDriver *mCanDriver;
17 std::map<uint8_t, ObdService *> mObdServices;
18
19 bool tryParseQuery(
20 std::vector<uint8_t> &&query,
21 std::vector<uint8_t> &pid,
22 uint8_t &queriedService) const;
23
24 void generateResponse(
25 const std::vector<uint8_t> &pid,
26 std::vector<uint8_t> &&serviceResponseData,
27 uint8_t queriedService,
28 std::vector<uint8_t> &response) const;
29
30 bool processQuery(
31 std::vector<uint8_t> &&query,
32 std::vector<uint8_t> &response) const;
33
34 void sendResponseAsync(
35 const std::vector<uint8_t> &pid,
36 std::vector<uint8_t> &&serviceResponseData,
37 uint8_t queriedService);
38
39 void processQueryAsync(std::vector<uint8_t> &&query);
40
41 public:
47 CommunicationLayer *communicationLayer,
48 const CanDriver *canDriver,
49 std::initializer_list<ObdService *> obdServices);
51
54 bool TryStart();
55
59
62 bool TryStop();
63 };
64}
65
66#endif
CAN bus controller driver helper.
Definition: can_driver.h:27
Communication medium abstraction layer to send and receive data.
Definition: communication_layer.h:12
A class that routes OBD queries to their corresponding services.
Definition: obd_emulator.h:13
bool TryStartAsync()
Try to start the emulation for asynchrous data handling.
bool TryStop()
Try to stop the emulation.
ObdEmulator(CommunicationLayer *communicationLayer, const CanDriver *canDriver, std::initializer_list< ObdService * > obdServices)
Constructor.
bool TryStart()
Try to start the emulation.