OBD-II Client Stack
OBD-II Client Overview
RAPIDSEA supports ISO15031 protocol as explained in the ISO15031 - OBD Protocol page. This page explains the client architecture and details how the user should interface the stack with their custom logic and realize the Tester implementation quickly. It also provides guidelines on adopting the stack for different systems.
The below diagram captures the block level diagram of the DoCAN OBD-II client and how it interfaces with other modules.
DoCAN Interface
The OBD-II client communicates over the CAN network through the underlying DoCAN stack (ISO15765). This DoCAN stack is also available as part of the RAPIDSEA components. All the functions that are needed are available as part of the DoCAN stack and has to be compiled together.
Mode |
Description |
|---|---|
rs_iso15765_* |
Set of functions called by OBD-II client to perform operation such as initialize, transmit messages etc |
rs_obd_client_docan_callback |
Callback function called by the DoCAN layer to inform of Data Indication, error etc |
These details with respect to the DoCAN interface are covered in detail in the ISO15765 - DoCAN Protocol page.
Application Interface
While the RAPIDSEA OBD-II client stack can handle most of the functionality such as message validation, session management, timing control etc, the business logic has to implement the application functionality. The RAPIDSEA OBD-II client clearly defines API and callback functions that are essential for the user to use/implement.
The below table captures the function that are to be called from the application logic.
Function |
Description |
|---|---|
rs_obd_client_open |
To initialize the OBD-II client stack |
rs_obd_client_process |
To be called periodically to process the incoming/outgoing messages |
rs_obd_client_enable_pos_resp_suppression |
To enable/disable positive response suppression |
There are many functions through which the OBD-II client stack retrieves information from the application logic or indicate actions to be performed. These functions are captured in the below table.
Function |
Description |
|---|---|
rcb_obd_client_01h_current_diagnostic_data_resp |
Called when response for a default session setup request is received |
rcb_obd_client_02h_freeze_frame_data_resp |
Called when response for a freeze frame data request is received |
rcb_obd_client_03h_diag_trouble_code_resp |
Called to read DTC information by various report types |
rcb_obd_client_04h_clear_reset_dtc_resp |
Called when response for clear DTC request is received |
rcb_obd_client_05h_oxygen_sensor_test_results_resp |
Called when response for oxygen sensor test request is received |
rcb_obd_client_06h_on_board_monitoring_results_resp |
Called when response for on board monitoring results request is received |
rcb_obd_client_07h_emission_dtc_current_cycle_resp |
Called when response for emission DTC current cycle request is received |
rcb_obd_client_08h_on_board_system_resp |
Called when response for on board system request is received |
rcb_obd_client_09h_vehicle_information_resp |
Called when vehicle information request is received |
These functions are documented in detail in the below sections. It is important for the client to implement these functions correct for proper operation of the system.
Implementation Guide
This section explains how the OBD-II server can be implemented using the RAPIDSEA stack. Whether the stack is available in source form or in binary form, the steps to be followed are
Implement the Callback functions mentioned above
Implement the underlying rs_can_* functions for DoCAN as per the underlying hardware design as described in the CAN Interface page.
Initialize the buffers necessary for the operation
Initialize the CAN, ISO15765 and SAE ISO15031 stack function for DoCAN and OBD-II.
Periodically call the process functions so that internal timeouts are handled.
If there is a need to send a request to ECU/server, send via rs_obd_client_req_* calls such as rcb_obd_client_04h_clear_reset_dtc_resp etc.
On reception of negative response from server, rcb_obd_client_error_resp function is called.
Up on successful completion of transmission of request or failure to do so, rcb_obd_client_transmit_confirm is called with relevant reason code.
High level flow chart is depicted below for DoCAN:
This can be implemented in a bare-metal system or over RTOS or over full fledged OS such as Linux etc.
Dependency
This stack depends on the below RAPIDSEA interfaces that can be obtained or custom implemented.
Example demo
An example implementation is available along with the release and is described in DoCAN OBD-II Client Demo.
OBD-II Client Header
Documentation from the relevant header as follows:
Warning
doxygenfile: Cannot find file “rs_obd_client.h