Woman, Life, Freedom


OBD-II Emulator
Linux ODB-II Emulator public and protected interfaces documentation
ObdEmulator::ObdService Class Referenceabstract

A class that defines an OBD-II service based on SAE J1979 standard. More...

#include <obd_service.h>

Public Types

using CallbackType = std::function< void(const std::vector< uint8_t > &, std::vector< uint8_t > &&, uint8_t)>
 Response ready callback type.
 

Public Member Functions

uint8_t GetService () const noexcept
 Get the service. More...
 
void SetCallback (CallbackType &&callback)
 Set the response ready callback. More...
 
virtual bool TryGetResponse (const std::vector< uint8_t > &pid, std::vector< uint8_t > &response) const =0
 Try to get an emulated response based the queried PID. More...
 
virtual bool TryGetResponseAsync (const std::vector< uint8_t > &pid)=0
 Try to get an emulated response asynchronously based the queried PID. More...
 
void ResetCallback () noexcept
 Reset the response ready callback.
 

Protected Types

using InternalCallbackType = std::function< void(const std::vector< uint8_t > &, std::vector< uint8_t > &&)>
 Service specific response ready callback type.
 

Protected Member Functions

 ObdService (uint8_t service) noexcept
 Constructor. More...
 

Protected Attributes

InternalCallbackType Callback
 

Detailed Description

A class that defines an OBD-II service based on SAE J1979 standard.

Constructor & Destructor Documentation

◆ ObdService()

ObdEmulator::ObdService::ObdService ( uint8_t  service)
protectednoexcept

Constructor.

Parameters
serviceOBD-II service (mode)

Member Function Documentation

◆ GetService()

uint8_t ObdEmulator::ObdService::GetService ( ) const
noexcept

Get the service.

Returns
OBD service number

◆ SetCallback()

void ObdEmulator::ObdService::SetCallback ( CallbackType &&  callback)

Set the response ready callback.

Parameters
callbackCallback to be invoked when the response is ready

◆ TryGetResponse()

virtual bool ObdEmulator::ObdService::TryGetResponse ( const std::vector< uint8_t > &  pid,
std::vector< uint8_t > &  response 
) const
pure virtual

Try to get an emulated response based the queried PID.

Parameters
[in]pidQueried PID
[out]responseResponse data byte array
Returns
True, if the service handled the query successfully, otherwise false
Note
The function may be called from a different thread than the main thread.

◆ TryGetResponseAsync()

virtual bool ObdEmulator::ObdService::TryGetResponseAsync ( const std::vector< uint8_t > &  pid)
pure virtual

Try to get an emulated response asynchronously based the queried PID.

Parameters
pidQueried PID
Returns
True, if the query is queued successfully for handling, otherwise false
Note
The function may be called from a different thread than the main thread.