brendan-w / python-OBD

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

Cannot connect to car without debug mode #186

Open michaelhku2002 opened 4 years ago

michaelhku2002 commented 4 years ago

Hi!

I'm now facing a problem when developing project for getting OBD data and camera stream from the car and then sending back to server through 4G mobile communication. When enabling the debug mode, the OBD can get protocol and then the values of RPM and speed can be obtained, but the video capture cannot be got properly and then sent back to server. Then I tried to disable the debug mode of OBD, but it always said that the car cannot be connected and thus, no protocol can be retrieved. So is there any workaround for this? My program code is here for reference. Thanks!

import obd

obd.logger.setLevel(obd.logging.DEBUG)
ports=obd.scan_serial()
print("port for bluetooth OBD={}".format(ports))
connection=obd.OBD(portstr=ports[0],baudrate=115200,fast=False,timeout=60)
#connection=obd.OBD(portstr='/dev/rfcomm0',baudrate=115200,fast=False,timeout=60)
print("connection.status()={}".format(connection.status()))
print("protocol name={}".format(connection.protocol_name()))

resp_rpm=connection.query(obd.commands.RPM,force=True)
print("resp_rpm: {}".format(resp_rpm.value.magnitude))
resp_speed=connection.query(obd.commands.SPEED,force=True)
print("resp_speed: {}".format(resp_speed.value.magnitude))
alistair23 commented 3 years ago

It sounds like a timing issue with your Bluetooth adaptor