Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on connection #93

Closed
Innercode opened this issue Jul 21, 2017 · 5 comments
Closed

Error on connection #93

Innercode opened this issue Jul 21, 2017 · 5 comments

Comments

@Innercode
Copy link

Hi,
I'm trying to connect a brand new Peugeot 308SW via an ELM-327 over bluetooth.

The code:

import obd
connection = obd.OBD() # auto-connects to USB or RF port
connection = obd.OBD(protocol="6-ISO15765-4(CAN11/500)") # 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 error output without protocol specification:

[obd.obd] ======================= python-OBD (v0.6.1) =======================
[obd.obd] Using scan_serial to select port
[obd.obd] Available ports: ['/dev/rfcomm0']
[obd.obd] Attempting to use port: /dev/rfcomm0
[obd.elm327] Initializing ELM327: PORT=/dev/rfcomm0 BAUD=auto PROTOCOL=auto
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    connection = obd.OBD() # auto-connects to USB or RF port
  File "/usr/local/lib/python2.7/dist-packages/obd/obd.py", line 58, in __init__
    self.__connect(portstr, baudrate, protocol) # initialize by connecting and loading sensors
  File "/usr/local/lib/python2.7/dist-packages/obd/obd.py", line 79, in __connect
    self.interface = ELM327(port, baudrate, protocol)
  File "/usr/local/lib/python2.7/dist-packages/obd/elm327.py", line 137, in __init__
    if not self.set_baudrate(baudrate):
  File "/usr/local/lib/python2.7/dist-packages/obd/elm327.py", line 265, in set_baudrate
    return self.auto_baudrate()
  File "/usr/local/lib/python2.7/dist-packages/obd/elm327.py", line 293, in auto_baudrate
    response = self.__port.read(1024)
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 501, in read
    'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

The output error with protocol specification is almost the same. PROTOCOL is than defined.

What goes wrong here?

Any help is much appriciated!

@rafacpitta
Copy link

rafacpitta commented Sep 6, 2017

I've experiencied this error and the solution I found at least if you're using a Raspberry or Ubuntu:

You need to add the SP profile editing this:

sudo nano /etc/systemd/system/dbus-org.bluez.service

Then add the compatibility flag -C for adding the SP to sdptool. Modify the lines from the file above to:

ExecStart=/usr/lib/bluetooth/bluetoothd -C
ExecStartPost=/usr/bin/sdptool add SP

Save and reboot, then I created the serial port this way (little bit different from the link I posted):

sudo rfcomm bind rfcomm1 AA:BB:CC:DD:EE:FF

Then, on python:

connection = obd.OBD('/dev/rfcomm1')

Try also different rfcomm (rfcomm0, rfcomm1, rfcomm2...) and be sure to release all before binding:

sudo rfcomm release all

@Innercode
Copy link
Author

Thanks @rafacpitta

That did the trick

@hamad12125
Copy link

can i get help same problem i did the trick didn't work

@Paulware
Copy link

I am also having the same trouble after modifying
etc/systemd/system/dbus-org.bluez.service

with a pi-4, 4gb and latest raspbian Feb-2020
thanks for your help

@dmaunder
Copy link

In my case, those lines were already at the suggested values, and changing the rfcomm command and trying different ports didnt help, any other thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants