Skip to content

Instantly share code, notes, and snippets.

@ccwoolf
Last active August 29, 2015 14:16
Show Gist options
  • Save ccwoolf/c17c90cdd180a6786545 to your computer and use it in GitHub Desktop.
Save ccwoolf/c17c90cdd180a6786545 to your computer and use it in GitHub Desktop.
Quick test script for determining OBD reader supported commands
# Usage: obd_test.py DEVICE
# Example: obd_test.py /dev/pts/4
# Prints supported OBD commands to the console, along with their current values.
import sys
import time
import obd
import json
obd.debug.console = True
if len(sys.argv) == 1:
connection = obd.OBD()
else:
connection = obd.OBD(sys.argv[1]) # First arg is the device to connect to
obd.debug.console = False
print("")
print("Supported commands")
print("------------------")
command_names = []
for command in connection.supported_commands:
print("{}: {}".format(command.name, connection.query(command)))
command_names.append(command.name)
with open("supported_commands-{}.json".format(int(time.time())), "w") as outfile:
json.dump(command_names, outfile)
[obd] ========================== Starting python-OBD ==========================
[obd] Using scanSerial to select port
[obd] Available ports: ['/dev/ttyUSB0']
[obd] Opening serial port '/dev/ttyUSB0'
[obd] Serial port successfully opened on /dev/ttyUSB0
[obd] write: 'ATZ\r\n'
[obd] read: '\r\rELM327 v1.5\r\r'
[obd] write: 'ATE0\r\n'
[obd] read: 'ATE0\rOK\r\r'
[obd] write: 'ATH1\r\n'
[obd] read: 'OK\r\r'
[obd] write: 'ATSPA8\r\n'
[obd] read: 'OK\r\r'
[obd] write: '0100\r\n'
[obd] read: 'SEARCHING...\r86 F1 11 41 00 BE 3E B8 11 8E \r\r'
[obd] write: 'ATDPN\r\n'
[obd] read: 'A5\r\r'
[obd] Connection successful
[obd] querying for supported PIDs (commands)...
[obd] Sending command: 0100: Supported PIDs [01-20]
[obd] write: '0100\r\n'
[obd] read: '86 F1 11 41 00 BE 3E B8 11 8E \r\r'
[obd] Sending command: 0120: Supported PIDs [21-40]
[obd] write: '0120\r\n'
[obd] read: '86 F1 11 41 20 80 00 00 00 69 \r\r'
[obd] finished querying with 17 commands supported
[obd] =========================================================================
Supported commands
------------------
STATUS: {'Check_Engine_Light': False, 'Tests': [<obd.utils.Test instance at 0xb69e52d8>, <obd.utils.Test instance at 0xb69e52b0>, <obd.utils.Test instance at 0xb69e5440>, <obd.utils.Test instance at 0xb69e5468>, <obd.utils.Test instance at 0xb69e55d0>, <obd.utils.Test instance at 0xb69e55f8>, <obd.utils.Test instance at 0xb69e55a8>, <obd.utils.Test instance at 0xb69e5580>, <obd.utils.Test instance at 0xb69e5648>, <obd.utils.Test instance at 0xb69e5670>, <obd.utils.Test instance at 0xb69e5698>], 'DTC_Count': 1, 'Ignition_Type': 'Spark'} None
FUEL_STATUS: Open loop due to insufficient engine temperature None
ENGINE_LOAD: 21.9607843137 %
COOLANT_TEMP: 23 C
SHORT_FUEL_TRIM_1: 0.0 %
LONG_FUEL_TRIM_1: 0.0 %
INTAKE_PRESSURE: 40 kPa
RPM: 1058.0 RPM
SPEED: 0 kph
TIMING_ADVANCE: 6.5 Degrees
INTAKE_TEMP: 13 C
THROTTLE_POS: 5.49019607843 %
O2_SENSORS: 03 None
O2_B1S1: 0.125 Volt
O2_B1S2: 0.41 Volt
OBD_COMPLIANCE: EOBD (Europe) None
DISTANCE_W_MIL: 0 km
[obd] ========================== Starting python-OBD ==========================
[obd] Explicit port defined
[obd] Opening serial port '/dev/pts/6'
[obd] Serial port successfully opened on /dev/pts/6
[obd] write: 'ATZ\r\n'
[obd] read: '\r\nELM327 v1.3a OBDGPSLogger\r\n'
[obd] write: 'ATE0\r\n'
[obd] read: 'ATE0\r\n\r\nOK\r\n'
[obd] write: 'ATH1\r\n'
[obd] read: '\r\nOK\r\n'
[obd] write: 'ATSPA8\r\n'
[obd] read: '\r\nOK\r\n'
[obd] write: '0100\r\n'
[obd] read: '\r\n7E8 06 41 00 FF FF FF FF FC\r\n'
[obd] write: 'ATDPN\r\n'
[obd] read: '\r\nA8\r\n'
[obd] Connection successful
[obd] querying for supported PIDs (commands)...
[obd] Sending command: 0100: Supported PIDs [01-20]
[obd] write: '0100\r\n'
[obd] read: '\r\n7E8 06 41 00 FF FF FF FF FC\r\n'
[obd] Receieved more data than expected, trying to parse anyways...
[obd] Sending command: 0120: Supported PIDs [21-40]
[obd] write: '0120\r\n'
[obd] read: '\r\n7E8 06 41 20 FF FF FF FF FC\r\n'
[obd] Receieved more data than expected, trying to parse anyways...
[obd] Sending command: 0140: Supported PIDs [41-60]
[obd] write: '0140\r\n'
[obd] read: '\r\n7E8 06 41 40 FF FF FF FE FB\r\n'
[obd] Receieved more data than expected, trying to parse anyways...
[obd] finished querying with 93 commands supported
[obd] =========================================================================
Supported commands
------------------
STATUS: None None
FREEZE_DTC: None None
FUEL_STATUS: None None
ENGINE_LOAD: 36.862745098 %
COOLANT_TEMP: 56 C
SHORT_FUEL_TRIM_1: -22.65625 %
LONG_FUEL_TRIM_1: -21.09375 %
SHORT_FUEL_TRIM_2: -20.3125 %
LONG_FUEL_TRIM_2: -18.75 %
FUEL_PRESSURE: 765 kPa
INTAKE_PRESSURE: 20 kPa
RPM: 3835.5 RPM
SPEED: 110 kph
TIMING_ADVANCE: -8.0 Degrees
INTAKE_TEMP: 73 C
MAF: 296.83 Grams per Second
THROTTLE_POS: 46.2745098039 %
AIR_STATUS: None None
O2_SENSORS: None None
O2_B1S1: 0.61 Volt
O2_B1S2: 0.62 Volt
O2_B1S3: 0.625 Volt
O2_B1S4: 0.635 Volt
O2_B2S1: 0.645 Volt
O2_B2S2: 0.65 Volt
O2_B2S3: 0.66 Volt
O2_B2S4: 0.67 Volt
OBD_COMPLIANCE: None None
O2_SENSORS_ALT: None None
AUX_INPUT_STATUS: None None
RUN_TIME: 36307 Second
DISTANCE_W_MIL: 36749 km
FUEL_RAIL_PRESSURE_VAC: 2938.089 kPa
FUEL_RAIL_PRESSURE_DIRECT: 376310 kPa
O2_S1_WR_VOLTAGE: 3.06254673075 Volt
O2_S2_WR_VOLTAGE: 0.875013351644 Volt
O2_S3_WR_VOLTAGE: 6.78135347524 Volt
O2_S4_WR_VOLTAGE: 4.56256961929 Volt
O2_S5_WR_VOLTAGE: 2.46878767071 Volt
O2_S6_WR_VOLTAGE: 0.343755245289 Volt
O2_S7_WR_VOLTAGE: 6.25009536889 Volt
O2_S8_WR_VOLTAGE: 4.03131151293 Volt
COMMANDED_EGR: 63.137254902 %
EGR_ERROR: 27.34375 %
EVAPORATIVE_PURGE: 64.7058823529 %
FUEL_LEVEL: 65.4901960784 %
WARMUPS_SINCE_DTC_CLEAR: 168 Count
DISTANCE_SINCE_DTC_CLEAR: 43812 km
EVAP_VAPOR_PRESSURE: -5384.75 Pa
BAROMETRIC_PRESSURE: 173 kPa
O2_S1_WR_CURRENT: -104.0 mA
O2_S2_WR_CURRENT: 84.0 mA
O2_S3_WR_CURRENT: 14.0 mA
O2_S4_WR_CURRENT: -56.0 mA
O2_S5_WR_CURRENT: -124.0 mA
O2_S6_WR_CURRENT: 62.0 mA
O2_S7_WR_CURRENT: -8.0 mA
O2_S8_WR_CURRENT: -76.0 mA
CATALYST_TEMP_B1S1: 4826.3 C
CATALYST_TEMP_B2S1: 4870.5 C
CATALYST_TEMP_B1S2: 4914.5 C
CATALYST_TEMP_B2S2: 4958.8 C
STATUS_DRIVE_CYCLE: None None
CONTROL_MODULE_VOLTAGE: 3083 None
ABSOLUTE_LOAD: C86F None
COMMAND_EQUIV_RATIO: CA46 None
RELATIVE_THROTTLE_POS: 79.6078431373 %
AMBIANT_AIR_TEMP: 164 C
THROTTLE_POS_B: 80.7843137255 %
THROTTLE_POS_C: 81.568627451 %
ACCELERATOR_POS_D: 81.9607843137 %
ACCELERATOR_POS_E: 82.7450980392 %
ACCELERATOR_POS_F: 83.5294117647 %
THROTTLE_ACTUATOR: 84.3137254902 %
RUN_TIME_MIL: 55712 Minute
TIME_SINCE_DTC_CLEARED: 56163 Minute
MAX_VALUES: None None
MAX_MAF: None None
FUEL_TYPE: None None
ETHANOL_PERCENT: 88.2352941176 %
EVAP_VAPOR_PRESSURE_ABS: None None
EVAP_VAPOR_PRESSURE_ALT: None None
SHORT_O2_TRIM_B1: None None
LONG_O2_TRIM_B1: None None
SHORT_O2_TRIM_B2: None None
LONG_O2_TRIM_B2: None None
FUEL_RAIL_PRESSURE_ABS: None None
RELATIVE_ACCEL_POS: None None
HYBRID_BATTERY_REMAINING: None None
OIL_TEMP: None None
FUEL_INJECT_TIMING: None None
FUEL_RATE: None None
EMISSION_REQ: None None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment