Score:0

How to read elm327 obd2 raw data over bt using rfcomm?

cn flag
sgt

I am trying to read my car data, i have hooked a cheap elm327 bt obd2 connector to it, and using lubuntu.

Basically this is what i have done, but its not fully working i end up with a sort of buggy terminal where i can only see one charterer at a time and don't get any response back

First i pair it and trust it:

[bluetooth]# pair 00:10:CC:4F:36:03
Attempting to pair with 00:10:CC:4F:36:03
[CHG] Device 00:10:CC:4F:36:03 Connected: yes
Request PIN code
[agent] Enter PIN code: 1234
[CHG] Device 00:10:CC:4F:36:03 UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device 00:10:CC:4F:36:03 ServicesResolved: yes
[CHG] Device 00:10:CC:4F:36:03 Paired: yes
Pairing successful
[CHG] Device 00:10:CC:4F:36:03 ServicesResolved: no
[CHG] Device 00:10:CC:4F:36:03 Connected: no
[CHG] Device 00:10:CC:4F:36:03 Connected: yes
[CHG] Device 00:10:CC:4F:36:03 Connected: no
[CHG] Device 00:10:CC:4F:36:03 Connected: yes
[CHG] Device 00:10:CC:4F:36:03 Connected: no
[CHG] Device 00:10:CC:4F:36:03 Connected: yes
[CHG] Device 00:10:CC:4F:36:03 Connected: no
[CHG] Device 00:10:CC:4F:36:03 Connected: yes
[CHG] Device 00:10:CC:4F:36:03 Connected: no
[CHG] Device 00:10:CC:4F:36:03 Connected: yes
[CHG] Device 00:10:CC:4F:36:03 Connected: no
[NEW] Device 3C:5D:2A:64:34:DD 3C-5D-2A-64-34-DD
[CHG] Device 00:10:CC:4F:36:03 Connected: yes
[CHG] Device 00:10:CC:4F:36:03 Connected: no
[NEW] Device 48:CA:AB:30:69:81 48-CA-AB-30-69-81
[CHG] Device 00:10:CC:4F:36:03 RSSI: -51
[CHG] Device 00:10:CC:4F:36:03 RSSI: -40
[DEL] Device 48:CA:AB:30:69:81 48-CA-AB-30-69-81
[CHG] Device 00:10:CC:4F:36:03 Connected: yes
[CHG] Device 00:10:CC:4F:36:03 Connected: no
[DEL] Device 3C:5D:2A:64:34:DD 3C-5D-2A-64-34-DD
[CHG] Device 00:10:CC:4F:36:03 RSSI: -54
[bluetooth]# info 00:10:CC:4F:36:03
Device 00:10:CC:4F:36:03 (public)
        Name: OBDII
        Alias: OBDII
        Paired: yes
        Trusted: no
        Blocked: no
        Connected: no
        LegacyPairing: no
        UUID: Serial Port               (00001101-0000-1000-8000-00805f9b34fb)
        ManufacturerData Key: 0x0100
        ManufacturerData Value:
  03 36 4f cc 10 00                                .6O...          
        ManufacturerData Key: 0x7262
        ManufacturerData Value:
  32 32 78 78 11 22 33 44 55 66 aa bb 00 00        22xx."3DUf....  
        RSSI: -54
[bluetooth]# trust 00:10:CC:4F:36:03
[CHG] Device 00:10:CC:4F:36:03 Trusted: yes
Changing 00:10:CC:4F:36:03 trust succeeded

then i use rfcomm to establish serial connection, i ran sdptool to know which channel its on and so i run:

user@user-20n20009pg:~$ sdptool records 00:10:CC:4F:36:03
Service Name: JL_SPP
Service RecHandle: 0x10004
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 2
Profile Descriptor List:
  "Serial Port" (0x1101)
    Version: 0x0102

user@user-20n20009pg:~$ sudo rfcomm connect /dev/rfcomm0 00:10:CC:4F:36:03 2 &
[1] 1583
user@user-20n20009pg:~$ Connected /dev/rfcomm0 to 00:10:CC:4F:36:03 on channel 2
Press CTRL-C for hangup

when i use screen to connect it kinda looks like its working but it only shows one char

user@user-20n20009pg:~$ sudo screen /dev/rfcomm0 38400

then it opens on another terminal and :

>a

and it seems i cant write the full atz command and it only shows one char at the time.

I have tried other baud rates such as 9600, 38400, 115200 but nothing so far

Do you know what i am missing ?

uz flag
Jos
I'm not familiar with rfcomm, but does `cat /dev/rfcomm0` do anything?
sgt avatar
cn flag
sgt
it just stays there, nothing happens, no data seem to be sent or received :/
waltinator avatar
it flag
The OBD2 protocol is NOT ASCII text. It's a binary, proprietary, deduced protocol. See https://learn.sparkfun.com/tutorials/getting-started-with-obd-ii/all
sgt avatar
cn flag
sgt
@waltinatorthanks, but i am still not sure how to proceed further ?
Score:0
cc flag

Here's the script I used to connect a bluetooth gps via rfcomm, might give you some ideas:

#!/bin/bash
# Start a gps receiver with bluetooth output
# Then determine if the gps daemon is already running
xxx=`ps -eo pid,comm |grep [g]psd`
if [ -n "$xxx" ]; then 
  set `echo $xxx`
  pidgpsd=$1
fi

MYGPS=`grep "^[^#].*device.*;" /etc/bluetooth/rfcomm.conf |cut -f2 -d" "|cut -f1 -d";"`

#Determine if the rfcomm0 device has been created
if [ ! -e /dev/rfcomm0 ]; then
  # kill the old gpsd
  if [ -n "$pidgpsd" ]; then
    # for icon invocation, use gksudo
    pkexec kill $pidgpsd
    unset pidgpsd
  fi
  sdptool add --channel=1 OPUSH
  #gksudo rfcomm bind /dev/rfcomm0 00:0A:3A:2C:BC:44
  pkexec rfcomm bind /dev/rfcomm0 $MYGPS
  sleep 5
fi

# Start the new gpsd if necessary
if [ ! -n "$pidgpsd" ]; then
  #sudo gpsd -n -N -D2 /dev/rfcomm0
  pkexec -- gpsd -n -D2 /dev/rfcomm0
  echo "gpsd started"
  sleep 5
fi

# Create a ttyUSB0 link for broken viking
if [ ! -e /dev/ttyUSB0 ]; then
  sudo ln -s /dev/rfcomm0 /dev/ttyUSB0
fi

#/usr/local/bin/gpsdrive
#$HOME/work/gps/gpsdrive-2.11/build/src/gpsdrive
sudo viking

It's been 10 years since I've played around with the Delorme Earthmate GPS, but the man page for sdptool offers two dozen services, besides the OPUSH -- you might try one of those. Unfortunately, the man page does not really specify what each service offers.

sgt avatar
cn flag
sgt
thanks i see i am missing this line, "sdptool add --channel=1", but would it make a difference if i already specify the channel by using "sudo rfcomm connect /dev/rfcomm0 00:10:CC:4F:36:03 2 &" ?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.