brendan-w / python-OBD

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

obd.OBD() requires explicit path for Bluetooth connection #105

Closed E-genin closed 5 years ago

E-genin commented 6 years ago

Hi there, I'm trying to use obd library to connect an ELM327 Bluetooth to a car, I use the very basic script :

import obd connection = obd.OBD() # auto-connects to USB or RF port cmd = obd.commands.SPEED # select an OBD command (sensor) response = connection.query(cmd) # send the command, and parse the response print(response.value) # returns unit-bearing values thanks to Pint print(response.value.to("mph")) # user-friendly unit conversions

The script freezes at this line : connection = obd.OBD() # auto-connects to USB or RF port it seems that it enters in an infinite loop and won't get out from there.

Can you help me with this problem.

Thanks in advance.

GrayBoltWolf commented 6 years ago

Mine takes a good 15-20 seconds with some query items before returning a value. Looks like it is frozen but it isn't.

E-genin commented 6 years ago

Hi, Thank you so much for the reply !!

Does the exact same script I mentioned before work for you ?

GrayBoltWolf commented 6 years ago

I just have a while loop around the response and print lines.

E-genin commented 6 years ago

Can you tell the Environment you are developing in (OS, Python version ...)

Thanks

alistair23 commented 5 years ago

Did you figure out what is going on here?

E-genin commented 5 years ago

Did you figure out what is going on here?

I had to pass the explicit path of the serial port to the obd.OBD() function. It just keeps searching otherwise.

alistair23 commented 5 years ago

Is your serial port a standard /dev/ttyS* port?

E-genin commented 5 years ago

I think it was a /dev/rfcomm port

alistair23 commented 5 years ago

Strange, it does look like that should be searched on Linux: https://github.com/brendan-w/python-OBD/blob/master/obd/utils.py#L170

E-genin commented 5 years ago

After pairing with the dongle, does one have to do something specific before running the script ? Because in my case, I didn't have any results until I "linked" the OBD dongle to the /dev/rfcomm in Linux, or to a COM port in Windows.

alistair23 commented 5 years ago

What do you mean linked?

E-genin commented 5 years ago

I meant binding the rfcomm to the dongle's MAC address

apecone commented 5 years ago

Hi @E-genin

Can you please provide your debug logs? Here's how...

obd.logger.setLevel(obd.logging.DEBUG)

If you provide these logs, I'll take a look :)

E-genin commented 5 years ago

For that, I'll need a new OBD dongle (I lost the one I had). Once that done, I'll make another test. I still remember that it freezes somewhere between the two debugging lines : [obd.obd] Available ports: [] and the next debugging line.