rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
obd2.h
Go to the documentation of this file.
1/*
2 * @file obd2.h
3 *
4 * @date Jun 9, 2015
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8#pragma once
9#include "can.h"
10
11#define OBD_TEST_REQUEST 0x7DF
12
13#define OBD_TEST_RESPONSE 0x7E8
14
15#define OBD_CURRENT_DATA 1
16#define _OBD_2 2
17#define OBD_STORED_DIAGNOSTIC_TROUBLE_CODES 3
18#define OBD_PENDING_DIAGNOSTIC_TROUBLE_CODES 7
19
20// https://en.wikipedia.org/wiki/OBD-II_PIDs
21
22#define PID_SUPPORTED_PIDS_REQUEST_01_20 0x00
23#define PID_MONITOR_STATUS 0x01
24#define PID_FUEL_SYSTEM_STATUS 0x03
25#define PID_ENGINE_LOAD 0x04
26#define PID_COOLANT_TEMP 0x05
27#define PID_STFT_BANK1 0x06
28#define PID_STFT_BANK2 0x08
29#define PID_FUEL_PRESSURE 0x0A
30#define PID_INTAKE_MAP 0x0B
31#define PID_RPM 0x0C
32#define PID_SPEED 0x0D
33#define PID_TIMING_ADVANCE 0x0E
34#define PID_INTAKE_TEMP 0x0F
35#define PID_INTAKE_MAF 0x10
36#define PID_THROTTLE 0x11
37
38#define PID_SUPPORTED_PIDS_REQUEST_21_40 0x20
39#define PID_FUEL_AIR_RATIO_1 0x24
40
41#define PID_SUPPORTED_PIDS_REQUEST_41_60 0x40
42#define PID_CONTROL_UNIT_VOLTAGE 0x42
43#define PID_ETHANOL 0x52
44#define PID_OIL_TEMPERATURE 0x5C
45#define PID_FUEL_RATE 0x5E
46//todo#define PID_TURBO_RPM 0x74
47
48#if HAS_CAN_FRAME
49void obdSendPacket(int mode, int PID, int numBytes, uint32_t iValue, size_t busIndex);
50void obdWriteSupportedPids(int PID, int bitOffset, const int16_t *supportedPids, size_t busIndex);
51void obdOnCanPacketRx(const CANRxFrame& rx, size_t busIndex);
52void handleGetDataRequest(const CANRxFrame& rx, size_t busIndex);
53#endif /* HAS_CAN_FRAME */
54
55#if EFI_UNIT_TEST
56#include "can_msg_tx.h"
57#endif
58
59#define ODB_RPM_MULT 4
60#define ODB_TEMP_EXTRA 40
61#define ODB_TPS_BYTE_PERCENT 2.55f
void obdSendPacket(int mode, int PID, int numBytes, uint32_t iValue, size_t busIndex)
Definition obd2.cpp:62
void obdWriteSupportedPids(int PID, int bitOffset, const int16_t *supportedPids, size_t busIndex)
Definition obd2.cpp:92
void handleGetDataRequest(const CANRxFrame &rx, size_t busIndex)
Definition obd2.cpp:106
void obdOnCanPacketRx(const CANRxFrame &rx, size_t busIndex)
Definition obd2.cpp:210