Woman, Life, Freedom |
OBD-II Emulator
Linux ODB-II Emulator public and protected interfaces documentation
|
Communication medium abstraction layer to send and receive data. More...
#include <communication_layer.h>
Public Types | |
using | CallbackType = std::function< bool(std::vector< uint8_t > &&, std::vector< uint8_t > &)> |
Data received callback type. More... | |
using | AsyncCallbackType = std::function< void(std::vector< uint8_t > &&)> |
Data received callback type to handle the data asynchronously. | |
Public Member Functions | |
virtual bool | TryStart (std::vector< uint8_t > &&configuration)=0 |
Try to start the communication. More... | |
virtual bool | TrySendAsync (std::vector< uint8_t > &&data)=0 |
Try to buffer data for sending. More... | |
void | SetCallback (CallbackType &&callback) |
Set a data received callback and reset the asynchronized callback. More... | |
void | SetCallback (AsyncCallbackType &&asyncCallback) |
Set a data received asynchronous callback and reset the synchronized callback. More... | |
void | ResetCallback () noexcept |
Reset both data received synchronized and asynchronized callbacks. More... | |
virtual bool | TryStop ()=0 |
Try to stop the communication. More... | |
Protected Attributes | |
CallbackType | Callback |
Callback to be invoked when data received. | |
AsyncCallbackType | AsyncCallback |
Callback to be invoked when data received asynch. | |
Communication medium abstraction layer to send and receive data.
using ObdEmulator::CommunicationLayer::CallbackType = std::function<bool(std::vector<uint8_t> &&, std::vector<uint8_t> &)> |
Data received callback type.
The caller moves the received byte array to the callback and expects the handler to return a boolean that indiciates whether or not it fills the other byte array refenrece as the response.
|
noexcept |
Reset both data received synchronized and asynchronized callbacks.
void ObdEmulator::CommunicationLayer::SetCallback | ( | AsyncCallbackType && | asyncCallback | ) |
Set a data received asynchronous callback and reset the synchronized callback.
asyncCallback | Callback to be invoked when a data is received for asynchronous data handling |
void ObdEmulator::CommunicationLayer::SetCallback | ( | CallbackType && | callback | ) |
Set a data received callback and reset the asynchronized callback.
callback | Callback to be invoked when a data is received |
|
pure virtual |
Try to buffer data for sending.
data | Data to be buffered for sending |
Implemented in ObdEmulator::SerialCommunication.
|
pure virtual |
Try to start the communication.
configuration | Configuration packet to sent to the endpoint right after the communication start |
Implemented in ObdEmulator::SerialCommunication.
|
pure virtual |
Try to stop the communication.
Implemented in ObdEmulator::SerialCommunication.