brendan-w / python-OBD

OBD-II serial module for reading engine data
GNU General Public License v2.0
1.07k stars 373 forks source link

Feature: print_discovered() #82

Closed ffries closed 5 years ago

ffries commented 7 years ago

Dear friends,

Python-OBD looks great, but I am new to car-testing software, so it is better to ask before doing!

When connecting to a Renault Espace 4dti, Python-OBD return: "9 commands supported" or something like that. Do you think it would make sense to add a Discover() function to test precisely which ODB codes/sensors are available in a car. This could also help discover custom OBD codes for each brand and then document them. I can handle coding.

I hope not to write nonsense! What do you think of this feature?

ffries commented 7 years ago

Done in my fork.

Now I can use the following script:

import obd
connection = obd.OBD("/dev/pts/2")

print ("A connection was made to the ECU of your car:")
print ("Protocole: " + connection.get_protocol_name())
print ("Port name: " + connection.get_port_name())
print ("Port rate: " + connection.get_port_baudrate())
print ("The ECU support the following commands:")
a=connection.get_supported_commands()
for i in a:
    print(i)

Will see if I can code this into a class or provide the script.

ffries commented 7 years ago

This is easier:

import obd
connection = obd.OBD("/dev/pts/2")
connection.print_discovered()

results in:

The following settings were used to connect to the ECU:
Protocole: ISO 15765-4 (CAN 11/500)
Port name: /dev/pts/2
Port rate: 9600
The following OBD commands are supported:
0134: 02 Sensor 1 WR Lambda Current
0135: 02 Sensor 2 WR Lambda Current
0136: 02 Sensor 3 WR Lambda Current
0137: 02 Sensor 4 WR Lambda Current
0130: Number of warm-ups since codes cleared
0131: Distance traveled since codes cleared
0132: Evaporative system vapor pressure
0133: Barometric Pressure
0233: DTC Barometric Pressure
0232: DTC Evaporative system vapor pressure
0231: DTC Distance traveled since codes cleared
0230: DTC Number of warm-ups since codes cleared
0237: DTC 02 Sensor 4 WR Lambda Current
0236: DTC 02 Sensor 3 WR Lambda Current
0235: DTC 02 Sensor 2 WR Lambda Current
0234: DTC 02 Sensor 1 WR Lambda Current
0238: DTC 02 Sensor 5 WR Lambda Current
013A: 02 Sensor 7 WR Lambda Current
0141: Monitor status this drive cycle
012F: Fuel Level Input
012E: Commanded Evaporative Purge
012D: EGR Error
012C: Commanded EGR
012B: 02 Sensor 8 WR Lambda Voltage
012A: 02 Sensor 7 WR Lambda Voltage
0146: Ambient air temperature
0149: Accelerator pedal position D
0148: Absolute throttle position C
0127: 02 Sensor 4 WR Lambda Voltage
0126: 02 Sensor 3 WR Lambda Voltage
0125: 02 Sensor 2 WR Lambda Voltage
0124: 02 Sensor 1 WR Lambda Voltage
0123: Fuel Rail Pressure (direct inject)
0122: Fuel Rail Pressure (relative to vacuum)
0121: Distance Traveled with MIL on
0120: Supported PIDs [21-40]
025C: DTC Engine oil temperature
0138: 02 Sensor 5 WR Lambda Current
015B: Hybrid battery pack remaining life
0129: 02 Sensor 6 WR Lambda Voltage
0128: 02 Sensor 5 WR Lambda Voltage
022A: DTC 02 Sensor 7 WR Lambda Voltage
015C: Engine oil temperature
013D: Catalyst Temperature: Bank 2 - Sensor 1
013E: Catalyst Temperature: Bank 1 - Sensor 2
0600: Supported MIDs [01-20]
010C: Engine RPM
013B: 02 Sensor 8 WR Lambda Current
013C: Catalyst Temperature: Bank 1 - Sensor 1
023C: DTC Catalyst Temperature: Bank 1 - Sensor 1
023B: DTC 02 Sensor 8 WR Lambda Current
023A: DTC 02 Sensor 7 WR Lambda Current
010B: Intake Manifold Pressure
023F: DTC Catalyst Temperature: Bank 2 - Sensor 2
023E: DTC Catalyst Temperature: Bank 1 - Sensor 2
023D: DTC Catalyst Temperature: Bank 2 - Sensor 1
0112: Secondary Air Status
0113: O2 Sensors Present
0110: Air Flow Rate (MAF)
0111: Throttle Position
0116: O2: Bank 1 - Sensor 3 Voltage
0117: O2: Bank 1 - Sensor 4 Voltage
0114: O2: Bank 1 - Sensor 1 Voltage
0115: O2: Bank 1 - Sensor 2 Voltage
0118: O2: Bank 2 - Sensor 1 Voltage
0119: O2: Bank 2 - Sensor 2 Voltage
0109: Long Term Fuel Trim - Bank 2
0108: Short Term Fuel Trim - Bank 2
03: Get DTCs
07: Get DTCs from the current/last driving cycle
04: Clear DTCs and Freeze data
013F: Catalyst Temperature: Bank 2 - Sensor 2
0206: DTC Short Term Fuel Trim - Bank 1
0207: DTC Long Term Fuel Trim - Bank 1
0204: DTC Calculated Engine Load
0205: DTC Engine Coolant Temperature
0202: DTC DTC that triggered the freeze frame
0203: DTC Fuel System Status
0201: DTC Status since DTCs cleared
010E: Timing Advance
010D: Vehicle Speed
010F: Intake Air Temp
010A: Fuel Pressure
0208: DTC Short Term Fuel Trim - Bank 2
0209: DTC Long Term Fuel Trim - Bank 2
020F: DTC Intake Air Temp
020D: DTC Vehicle Speed
020E: DTC Timing Advance
020B: DTC Intake Manifold Pressure
020C: DTC Engine RPM
020A: DTC Fuel Pressure
0105: Engine Coolant Temperature
0104: Calculated Engine Load
0107: Long Term Fuel Trim - Bank 1
0106: Short Term Fuel Trim - Bank 1
0101: Status since DTCs cleared
0100: Supported PIDs [01-20]
0103: Fuel System Status
0102: DTC that triggered the freeze frame
011B: O2: Bank 2 - Sensor 4 Voltage
011C: OBD Standards Compliance
0213: DTC O2 Sensors Present
011A: O2: Bank 2 - Sensor 3 Voltage
0215: DTC O2: Bank 1 - Sensor 2 Voltage
0214: DTC O2: Bank 1 - Sensor 1 Voltage
011D: O2 Sensors Present (alternate)
0216: DTC O2: Bank 1 - Sensor 3 Voltage
0219: DTC O2: Bank 2 - Sensor 2 Voltage
0218: DTC O2: Bank 2 - Sensor 1 Voltage
014D: Time run with MIL on
021A: DTC O2: Bank 2 - Sensor 3 Voltage
021C: DTC OBD Standards Compliance
ATI: ELM327 version string
021B: DTC O2: Bank 2 - Sensor 4 Voltage
024A: DTC Accelerator pedal position E
021E: DTC Auxiliary input status (power take off)
021D: DTC O2 Sensors Present (alternate)
0140: Supported PIDs [41-60]
021F: DTC Engine Run Time
0143: Absolute load value
024B: DTC Accelerator pedal position F
024C: DTC Commanded throttle actuator
0142: Control module voltage
024F: DTC Various Max values
024D: DTC Time run with MIL on
024E: DTC Time since trouble codes cleared
0145: Relative throttle position
0144: Commanded equivalence ratio
0242: DTC Control module voltage
0243: DTC Absolute load value
0240: DTC Supported PIDs [41-60]
0241: DTC Monitor status this drive cycle
0246: DTC Ambient air temperature
0147: Absolute throttle position B
0244: DTC Commanded equivalence ratio
0245: DTC Relative throttle position
0248: DTC Absolute throttle position C
0249: DTC Accelerator pedal position D
0250: DTC Maximum value for mass air flow sensor
ATRV: Voltage detected by OBD-II adapter
011E: Auxiliary input status (power take off)
015F: Designed emission requirements
014A: Accelerator pedal position E
015D: Fuel injection timing
015E: Engine fuel rate
0259: DTC Fuel rail pressure (absolute)
0258: DTC Long term secondary O2 trim - Bank 2
015A: Relative accelerator pedal position
0255: DTC Short term secondary O2 trim - Bank 1
0254: DTC Evap system vapor pressure
0257: DTC Short term secondary O2 trim - Bank 2
0256: DTC Long term secondary O2 trim - Bank 1
0251: DTC Fuel Type
014C: Commanded throttle actuator
0253: DTC Absolute Evap system Vapor Pressure
0252: DTC Ethanol Fuel Percent
014B: Accelerator pedal position F
014E: Time since trouble codes cleared
0247: DTC Absolute throttle position B
0211: DTC Throttle Position
0210: DTC Air Flow Rate (MAF)
014F: Various Max values
0239: DTC 02 Sensor 6 WR Lambda Current
0212: DTC Secondary Air Status
011F: Engine Run Time
022B: DTC 02 Sensor 8 WR Lambda Voltage
022C: DTC Commanded EGR
022D: DTC EGR Error
022E: DTC Commanded Evaporative Purge
022F: DTC Fuel Level Input
0228: DTC 02 Sensor 5 WR Lambda Voltage
0229: DTC 02 Sensor 6 WR Lambda Voltage
0217: DTC O2: Bank 1 - Sensor 4 Voltage
0220: DTC Supported PIDs [21-40]
0221: DTC Distance Traveled with MIL on
0222: DTC Fuel Rail Pressure (relative to vacuum)
0223: DTC Fuel Rail Pressure (direct inject)
0224: DTC 02 Sensor 1 WR Lambda Voltage
0225: DTC 02 Sensor 2 WR Lambda Voltage
0226: DTC 02 Sensor 3 WR Lambda Voltage
0227: DTC 02 Sensor 4 WR Lambda Voltage
025F: DTC Designed emission requirements
0139: 02 Sensor 6 WR Lambda Current
0156: Long term secondary O2 trim - Bank 1
0157: Short term secondary O2 trim - Bank 2
0154: Evap system vapor pressure
0155: Short term secondary O2 trim - Bank 1
0152: Ethanol Fuel Percent
0153: Absolute Evap system Vapor Pressure
0150: Maximum value for mass air flow sensor
0151: Fuel Type
025E: DTC Engine fuel rate
025D: DTC Fuel injection timing
025B: DTC Hybrid battery pack remaining life
025A: DTC Relative accelerator pedal position
0158: Long term secondary O2 trim - Bank 2
0159: Fuel rail pressure (absolute)
ffries commented 7 years ago

I will add voltage control, ELM version control, VIN decoding today. Maybe it is better to quit after discovery, as it is only a utility.

E-genin commented 6 years ago

Hi, Are you using an ELM327 Bluetooth or USB adapter ?

alistair23 commented 5 years ago

Closing as this isn't an issue and there is still a pull request open for the feature.

guruvishnuvardan commented 3 years ago

Hello Folks,

@alistair23 @brendan-w @ajman1101

I am using USB OB2 Connector, my objective is to get the speed of the Car(Honda City 2015 Model India)

Please find the following Code:

**import obd

connection = obd.OBD("/dev/ttyUSB0") ports = obd.scan_serial() print(ports)

cmd = obd.commands.SPEED r = connection.query(cmd) print(r.value)

OutPut: ['/dev/ttyUSB0'] [obd.obd] 'b'010D': Vehicle Speed' is not supported None**

I have made an attempt to print using connection.print_discovered(), Please find the output

**connection.print_discovered()

AttributeError: 'OBD' object has no attribute 'print_discovered'**

import obd

connection = obd.OBD("/dev/ttyUSB0") connection = obd.OBD("/dev/ttyUSB0") a = connection.get_supported_commands() Traceback (most recent call last): File "", line 1, in AttributeError: 'OBD' object has no attribute 'get_supported_commands'

Can you please help me resolve this issue

Note: I have attached the USB OBD Connector Picture PXL_20210813_131702193

Hardware Used

Raspberry Pi 4 OS - Raspbian OS Python Version 3 Pyobd

Thanks Guru