Kiran
Kiran

Reputation: 119

/dev/rfcommo not giving any data when reading OBD data in raspberry pi via bluetooth

I am trying to connect my raspberry pi to a Bluetooth OBD adapter. I have verified that the OBD device is working by connecting to it from the android phone using Torque lite app.

I am following this tutorial to connect the raspberry pi to the OBD adapter. I am able to pair with the OBD adapter and then trust it. Then I manually create the "/dev/rfcomm0" abstraction. As per the tutorial "screen /dev/rfcomm0" is supposed to print some output. But for me it just says "Screen is terminating" and it exits.

I tried running the "obd_reader.py" script, but it is throwing the following error:

python obd_reader.py 
Ports: 
['/dev/rfcomm0']
[obd.obd] ======================= python-OBD (v0.6.1) =======================
[obd.obd] Explicit port defined
[obd.elm327] Initializing ELM327: PORT=/dev/rfcomm0 BAUD=auto PROTOCOL=auto
Traceback (most recent call last):
  File "obd_reader.py", line 11, in <module>
    connection = obd.OBD(ports[0])
  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 85, in __connect
    self.interface = ELM327(portstr, 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/lib/python2.7/dist-packages/serial/serialposix.py", line 460, in read
    raise SerialException('device reports readiness to read but returned no data (device disconnected?)')
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?)

I tried a suggestion provided here, but there was no change in output. This was the change suggested:

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

I feel that I am creating or configuring the rfcomm device in the wrong way. But not sure how to fix this. Can someone please suggest a solution?

Upvotes: 1

Views: 895

Answers (1)

Med Nour
Med Nour

Reputation: 1

It seems that line 27 of the script you are running you are missing a dot in the query:

res = connection.query(obd.commands[command])

Tt should be like this as far as I know:

res= connection.query(obd.commands.[command])

Upvotes: 0

Related Questions