Giter Club home page Giter Club logo

Comments (6)

brendan-w avatar brendan-w commented on September 13, 2024

Thanks for the ticket. Heard about this, but never saw a cause. Fix is on master and will be released in 0.5.1 soon.

from python-obd.

Jean--Michel avatar Jean--Michel commented on September 13, 2024

Hi, I also saw this problem, so I apply the patch you commited on protocol_can.py.

Now I have this problem:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/obd-0.5.0-py2.7.egg/obd/async.py", line 214, in run
    r = super(Async, self).query(c, force=True)
  File "/usr/local/lib/python2.7/dist-packages/obd-0.5.0-py2.7.egg/obd/obd.py", line 240, in query
    messages = self.port.send_and_parse(cmd_string)
  File "/usr/local/lib/python2.7/dist-packages/obd-0.5.0-py2.7.egg/obd/elm327.py", line 312, in send_and_parse
    messages = self.__protocol(lines)
  File "/usr/local/lib/python2.7/dist-packages/obd-0.5.0-py2.7.egg/obd/protocols/protocol.py", line 206, in __call__
    if self.parse_message(message):
  File "/usr/local/lib/python2.7/dist-packages/obd-0.5.0-py2.7.egg/obd/protocols/protocol_can.py", line 249, in parse_message
    mode = message.data[0]
IndexError: bytearray index out of range

The problem appear on real car, not on the OBDII simulator.
It occurs after the following debug events:

[obd] ========================== python-OBD (v0.5.0) ==========================

[obd] Using scan_serial to select port
[obd] Available ports: ['/dev/rfcomm0']
[obd] Attempting to use port: /dev/rfcomm0
[obd] Opening serial port '/dev/rfcomm0'
[obd] Serial port successfully opened on /dev/rfcomm0
[obd] write: 'ATZ\r\n'
[obd] wait: 1 seconds
[obd] read: '\r\rELM327 v2.1\r\r'
[obd] write: 'ATE0\r\n'
[obd] read: 'OK\r\r'
[obd] write: 'ATH1\r\n'
[obd] read: 'OK\r\r'
[obd] write: 'ATL0\r\n'
[obd] read: 'OK\r\r'
[obd] write: 'ATSP0\r\n'
[obd] read: 'OK\r\r'
[obd] write: '0100\r\n'
[obd] read: 'SEARCHING...\r7E9 06 41 00 80 00 00 11 \r7E8 06 41 00 98 3B 40 11 \r\r'
[obd] write: 'ATDPN\r\n'
[obd] read: '6\r\r'
[obd] Connection successful
[obd] querying for supported PIDs (commands)...
[obd] Sending command: 0100: Supported PIDs [01-20]
[obd] write: '01002\r\n'
[obd] read: '7E9 06 41 00 80 00 00 11 \r7E8 06 41 00 98 3B 40 11 \r\r'
[obd] Sending command: 0120: Supported PIDs [21-40]
[obd] write: '01202\r\n'
[obd] read: '7E9 06 41 20 00 00 00 00 \r7E8 06 41 20 A0 00 00 00 \r\r'
[obd] Sending command: 0220: DTC Supported PIDs [21-40]
[obd] write: '02202\r\n'
[obd] read: 'NO DATA\r\r'
[obd] finished querying with 32 commands supported
[obd] =========================================================================
[obd] '0102: Freeze DTC' is not supported
[obd] Watching command: 0104: Calculated Engine Load
[obd] subscribing callback for command: 0104: Calculated Engine Load
[obd] Watching command: 0105: Engine Coolant Temperature
[obd] subscribing callback for command: 0105: Engine Coolant Temperature
[obd] '0106: Short Term Fuel Trim - Bank 1' is not supported
[obd] '0107: Long Term Fuel Trim - Bank 1' is not supported
[obd] '0108: Short Term Fuel Trim - Bank 2' is not supported
[obd] '0109: Long Term Fuel Trim - Bank 2' is not supported
[obd] '010A: Fuel Pressure' is not supported
[obd] Watching command: 010B: Intake Manifold Pressure
[obd] subscribing callback for command: 010B: Intake Manifold Pressure
[obd] Watching command: 010C: Engine RPM
[obd] subscribing callback for command: 010C: Engine RPM
[obd] Watching command: 010D: Vehicle Speed
[obd] subscribing callback for command: 010D: Vehicle Speed
[obd] '010E: Timing Advance' is not supported
[obd] Watching command: 010F: Intake Air Temp
[obd] subscribing callback for command: 010F: Intake Air Temp
[obd] Watching command: 0110: Air Flow Rate (MAF)
[obd] subscribing callback for command: 0110: Air Flow Rate (MAF)
[obd] '0111: Throttle Position' is not supported
[obd] Watching command: 0112: Secondary Air Status
[obd] subscribing callback for command: 0112: Secondary Air Status
[obd] '0114: O2: Bank 1 - Sensor 1 Voltage' is not supported
[obd] '0115: O2: Bank 1 - Sensor 2 Voltage' is not supported
[obd] '0116: O2: Bank 1 - Sensor 3 Voltage' is not supported
[obd] '0117: O2: Bank 1 - Sensor 4 Voltage' is not supported
[obd] '0118: O2: Bank 2 - Sensor 1 Voltage' is not supported
[obd] '0119: O2: Bank 2 - Sensor 2 Voltage' is not supported
[obd] '011A: O2: Bank 2 - Sensor 3 Voltage' is not supported
[obd] '011B: O2: Bank 2 - Sensor 4 Voltage' is not supported
[obd] '011D: O2 Sensors Present (alternate)' is not supported
[obd] '011E: Auxiliary input status' is not supported
[obd] '011F: Engine Run Time' is not supported
[obd] Watching command: 0121: Distance Traveled with MIL on
[obd] subscribing callback for command: 0121: Distance Traveled with MIL on
[obd] '0122: Fuel Rail Pressure (relative to vacuum)' is not supported
[obd] Watching command: 0123: Fuel Rail Pressure (direct inject)
[obd] subscribing callback for command: 0123: Fuel Rail Pressure (direct inject)
[obd] '0124: 02 Sensor 1 WR Lambda Voltage' is not supported
[obd] '0125: 02 Sensor 2 WR Lambda Voltage' is not supported
[obd] '0126: 02 Sensor 3 WR Lambda Voltage' is not supported
[obd] '0127: 02 Sensor 4 WR Lambda Voltage' is not supported
[obd] '0128: 02 Sensor 5 WR Lambda Voltage' is not supported
[obd] '0129: 02 Sensor 6 WR Lambda Voltage' is not supported
[obd] '012A: 02 Sensor 7 WR Lambda Voltage' is not supported
[obd] '012B: 02 Sensor 8 WR Lambda Voltage' is not supported
[obd] '012C: Commanded EGR' is not supported
[obd] '012D: EGR Error' is not supported
[obd] '012E: Commanded Evaporative Purge' is not supported
[obd] '012F: Fuel Level Input' is not supported
[obd] '0133: Barometric Pressure' is not supported
[obd] '0134: 02 Sensor 1 WR Lambda Current' is not supported
[obd] '0135: 02 Sensor 2 WR Lambda Current' is not supported
[obd] '0136: 02 Sensor 3 WR Lambda Current' is not supported
[obd] '0137: 02 Sensor 4 WR Lambda Current' is not supported
[obd] '0138: 02 Sensor 5 WR Lambda Current' is not supported
[obd] '0139: 02 Sensor 6 WR Lambda Current' is not supported
[obd] '013A: 02 Sensor 7 WR Lambda Current' is not supported
[obd] '013B: 02 Sensor 8 WR Lambda Current' is not supported
[obd] '013C: Catalyst Temperature: Bank 1 - Sensor 1' is not supported
[obd] '013D: Catalyst Temperature: Bank 2 - Sensor 1' is not supported
[obd] '013E: Catalyst Temperature: Bank 1 - Sensor 2' is not supported
[obd] '013F: Catalyst Temperature: Bank 2 - Sensor 2' is not supported
[obd] '0140: Supported PIDs [41-60]' is not supported
[obd] '0141: Monitor status this drive cycle' is not supported
[obd] '0142: Control module voltage' is not supported
[obd] '0143: Absolute load value' is not supported
[obd] '0144: Command equivalence ratio' is not supported
[obd] '0145: Relative throttle position' is not supported
[obd] '0146: Ambient air temperature' is not supported
[obd] '0147: Absolute throttle position B' is not supported
[obd] '0148: Absolute throttle position C' is not supported
[obd] '0149: Accelerator pedal position D' is not supported
[obd] '014A: Accelerator pedal position E' is not supported
[obd] '014B: Accelerator pedal position F' is not supported
[obd] '014C: Commanded throttle actuator' is not supported
[obd] '014D: Time run with MIL on' is not supported
[obd] '014E: Time since trouble codes cleared' is not supported
[obd] '014F: Various Max values' is not supported
[obd] '0150: Maximum value for mass air flow sensor' is not supported
[obd] '0152: Ethanol Fuel Percent' is not supported
[obd] '0153: Absolute Evap system Vapor Pressure' is not supported
[obd] '0154: Evap system vapor pressure' is not supported
[obd] '0155: Short term secondary O2 trim - Bank 1' is not supported
[obd] '0156: Long term secondary O2 trim - Bank 1' is not supported
[obd] '0157: Short term secondary O2 trim - Bank 2' is not supported
[obd] '0158: Long term secondary O2 trim - Bank 2' is not supported
[obd] '0159: Fuel rail pressure (absolute)' is not supported
[obd] '015A: Relative accelerator pedal position' is not supported
[obd] '015B: Hybrid battery pack remaining life' is not supported
[obd] '015C: Engine oil temperature' is not supported
[obd] '015D: Fuel injection timing' is not supported
[obd] '015E: Engine fuel rate' is not supported
[obd] '015F: Designed emission requirements' is not supported
[obd] Starting async thread
[obd] Sending command: 0112: Secondary Air Status
Started
[obd] write: '01122\r\n'
[obd] read: '7E8 03 41 12 04 \r\r'
1466295130.81   AIR_STATUS : From the outside atmosphere or off
[obd] Sending command: 0110: Air Flow Rate (MAF)
[obd] write: '01102\r\n'
[obd] read: '7E8 04 41 10 00 00 \r00 \r\r'
[obd] Dropping frame for being odd
1466295130.85   MAF : 0.0
[obd] Sending command: 0123: Fuel Rail Pressure (direct inject)
[obd] write: '01232\r\n'
[obd] read: '788 00 \r41 10 00 \r\r'
[obd] Dropping frame for being odd
[obd] Stopping async thread...
[obd] Async thread stopped

Regards,
jml

from python-obd.

brendan-w avatar brendan-w commented on September 13, 2024

Hi @Jean--Michel, thanks for the debug data. I implemented a fix on master (same cause, different problem). Turns out there was no length checking being done.

from python-obd.

Jean--Michel avatar Jean--Michel commented on September 13, 2024

Hi @brendan-w ,

Thank you.
I saw a similar problem line 115 of the last revision of protocol_can.py, so i add length check:

frame.data = raw_bytes[4:]

# <BEGIN PATCH>
if len(frame.data) == 0:
            return False
# <END PATCH>

# read PCI byte (always first byte in the data section)
#             v
# 00 00 07 E8 06 41 00 BE 7F B8 13
frame.type = frame.data[0] & 0xF0

Not sure if my patch is correct, but there no more exception. Just ask me if you want debug messages about that.

Regards,
jm.

from python-obd.

brendan-w avatar brendan-w commented on September 13, 2024

This happens at fe5740d? The length checks/tests that I added in those commits should guarantee at least one data byte (the lower bound is set for 5 bytes, which should be fine for the slice). Unless I messed up the code, and the tests... Yup, when you get around to it, could you send me the debug data so I have something to test with?

from python-obd.

Jean--Michel avatar Jean--Michel commented on September 13, 2024

Hi @brendan-w,

I probably made a mistake with my previous test.
I just use your last "protocol_can.py" and there is no more exception. It works fine except a lot of "None" values I don't understand.

Thank you very much for this software.

Cheers,
jm

from python-obd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.