Genericobd2

From eLinux.org
Jump to: navigation, search

nobdy provider: GenericOBD2 - This allows nobdy to gather data from ELM327 compatible scantools

Setup

From Source

 git clone git://gitorious.org/nobdy/genericobd2.git

Also grab libobd:

 git clone git://gitorious.org/libobd/libobd.git
 cd libobd
 qmake
 make
 sudo make install
 cd ../genericobd2
 qmake
 make
 sudo make install

Binary Packages

See [instructions] on main nobdy page.

Configuration

To enable the genericobd2 plugin, edit your nobdy config (/etc/nobdy/plugins.xml or ~/.nobdy/plugins.xml) with the following:

NOTE: you can find up to date example configurations are installed in /etc/nobdy/providers/*.xml.

 <provider path="/usr/lib/nobdy/libgenericobd2.so">
  <device>/dev/pts/2</device>
  <baud>115200</baud>
 </provider>

Put the path to your scantool (usually /dev/ttyUSB0) inside the <device> element, replacing /dev/pts/2. 115200 is a typical BAUD rate for newer scantools, although older devices may run at 19200 baud or even 9600.

Bluetooth

For bluetooth scantools such as OBDKey or OBDLink MX, specify the MAC address of the paired bluetooth scantool rather than the path name:

 <provider path="/usr/lib/nobdy/libgenericobd2.so">
  <device>00:00:00:00:00:00</device>
  <baud>9600</baud>
 </provider>

Paired bluetooth device addresses of format 00:00:00:00:00:00 are listed (in Ubuntu and Debian at least) in /var/lib/bluetooth/<host bluetooth device>/trusts. On most Linux distros, the easiest way to pair a Bluetooth device is with a panel applet.

After configuring the plugin with the bluetooth address of your scantool, you should be able to run nobdy and get obd2 data.

Advanced Bluetooth Hacking: (here be dragons)

Bring the Bluetooth connection up after pairing with;

  prompt ;-) sudo hciconfig hci0 up
  prompt ;-) hciconfig
  hci0:   Type: BR/EDR  Bus: USB
       BD Address: <host bluetooth address>  ACL MTU: 1021:8  SCO MTU: 64:1
       UP RUNNING PSCAN ISCAN 
       RX bytes:6259 acl:7 sco:0 events:199 errors:0
       TX bytes:1655 acl:7 sco:0 commands:137 errors:0

Ping the attached scantool:

 prompt ;-) sudo l2ping <scantool bluetooth address>
 Ping: <scantool bluetooth address> from <host bluetooth address> (data size 44) ...
 44 bytes from <scantool bluetooth address> id 0 time 8.57ms
 44 bytes from <scantool bluetooth address> id 1 time 6.18ms
 44 bytes from <scantool bluetooth address> id 2 time 6.20ms
 ^C3 sent, 3 received, 0% loss

Now connect to the device:

 prompt ;-) sudo hcitool cc --role=m <scantool bluetooth address>

Create /dev/rfcomm0 to talk to the device:

 prompt ;-) sudo rfcomm bind rfcomm0
 Can't create device: Address already in use
 prompt ;-) ll /dev/rfcomm0
 0 crw-rw---T 1 dialout 216, 0 Apr  6 19:33 /dev/rfcomm0

Once a device exists and a connection is established, minicom or screen commands can be used to communicate directly as a test. First use "sudo minicom -s /dev/rfcomm0" to configure the communications and save the resulting params to a file. Then talk to the Bluetooth scantool directly using the ELM327's command set :

 prompt ;-) minicom /dev/rfcomm0
 >ATZ
 ELM327 v1.3a
 >AT@1
 SCANTOOL.NET LLC
 >01 00
 CAN ERROR

With a USB scantool, users can now proceed directly to issue OBDII or CAN requests. With the OBDLink MX, one additional protocol command is needed, which is why "01 00" causes an error. After setting "AT SP0" normal OBDII and CAN requests are possible:

 >AT SP0    
 OK
 >01 00
 SEARCHING...
 41 00 BE 1B 30 13 
 41 00 88 18 00 10 
 41 00 00 08 00 10

Future bluetooth communication can be made easier by editing /etc/bluetooth/rfcomm.conf like so:

 rfcomm0 {
   # Automatically bind the device at startup
   bind yes;
   # Bluetooth address of the device
   device 00:00:00:00:00:00;
   # RFCOMM channel for the connection
   channel	1;
   # Description of the connection
   comment "OBDLink MX";
 }

Supported Devices

Supported Parameter IDs

Eventually support should be added for a standard list of PIDs.