I've set up an Adroid application doing just that through bluetooth. You can find the source code here: https://github.com/eiannone/CBT-Diagnostic (see also here: http://forum.canb.us/discussion/comment/580/#Comment_580)
I would like to port it to a desktop app using serial port. It shouldn't be too difficult.
I got all information about OBDII protocol on wikipedia page: https://en.wikipedia.org/wiki/OBD-II_PIDs
Basically you have to send a broadcast CAN request using msgId/address 07DF and then listen for responses from id 07E0 - 07E7 .
The first byte of the CAN packet data is the "command mode", the second is the PID command, and the others are command data.
For example, to get all supported OBDII PIDs you must use mode 01 - "Show current data", and then command 00 - "Show supported pids".
The CAN packet request is the following:
07DF 02 01 00 0000000000
07DF is the broadcast address
02 is the number of data bytes
01 is the OBD mode (Show current data)
00 is the command PID "Show supported PIDS"
The rest of 0s are unused data bytes
To send this command with CBT you have to send the following serial port command:
02 01 07 DF 02 01 00 00 00 00 00 00 08
On my Mazda 3 I receive this CAN response:
07E8 06 41 00 98 3B 80 11 00
07E8 is the device id
06 is the number of additional data bytes
41 is the OBD mode, same as request mode (01h) with 40h added
00 is the PID code (same as request)
98 3B 80 11 is hex string with supported PIDs encoded, which translates to PID supported: 01, 04, 05, 0B, 0C, 0D, 0F, 10, 11, 1C, 20 (see Wikipedia for decoding)
To ease dealing with OBD protocol I implemented mask filtering on firmware for CAN messages id. That's because ODB II CAN messages id are only in the range from 0x7E8 to 0x7EF.
The "-flto" flag activates the GCC linker plugin for Link-Time-Optimization (LTO), but some windows versions of Arduino IDE don't include this plugin.
Since version 1.6.4 the plugin was permanently removed as it is not correctly delivered in the AVR GCC tool chain for Arduino.
See here: http://couponsmeup.appspot.com/github.com/mikaelpatel/Cosa/issues/338
I have the same problem compiling on windows. It seems related to a "-flto" compile option added to platform.txt file with last code commit.
To solve the problem just edit file CANBus-Triple\avr\platform.txt and remove all occurencies of "-flto" string. There are three of them, on lines 11, 14 and 18.
If you are on windows and have .net framework installed you can try this console application written in C#: http://goo.gl/2iY4mb
I've created it using my <a href="https://github.com/eiannone/CANBus-Triple-Dll">windows dll</a>. It's built on .net framework v 4.5.2
<code>CBTConsole.exe [COM port name] [bus] [output file]</code>
Here is the source code for my app: https://github.com/eiannone/CBT-Diagnostic
To ease dealing with OBD protocol I implemented mask filtering on firmware for CAN messages id. That's because ODB II CAN messages id are only in the range from 0x7E8 to 0x7EF. You can find it in my <a href="https://github.com/eiannone/CANBus-Triple/tree/can-mask">v0.5.1 can-mask branch</a>.
I suggest also to disable bluetooth rate limiting, in order to avoid missing some CAN packets when you receive quick responses from the car.
The apk is here: https://github.com/eiannone/CBT-Diagnostic/releases/download/0.1alpha/android-debug.apk
@jamesatfish, serial communication service UUID is 7a1fb359-735c-4983-8082-bdd7674c74d2
I subscribed to its characteristic b0d6c9fe-e38a-4d31-9272-b8b3e93d8657 (with indicate method), and send commands to its other characteristic b0d6c9fe-e38a-4d31-9272-b8b3e93d8658 (with notify method).
But they are interchangeable. You can also use the same characteristic to write and receive data (subscribe).
My app is working quite well now. I am implementing some OBD II communication through CAN messages, following Wikipedia Article on OBD II (https://en.wikipedia.org/wiki/OBD-II_PIDs).
If I've time I will publish the code during this weekend.
I used this library (Cordova plugin) for BLE: https://github.com/randdusing/BluetoothLE
I'm trying to implement bluetooth communication with CBT on Android, too.
I'm developing an OBD diagnostic app with <a href="http://www.ionicframework.com/">Ionic framework</a> (borrowing the idea and structure from @Derek offical app) and currently I'm able to connect to CBT, and successfully send / receive data with an Android smartphone. I can share the code if anyone is interested.
I'm also able to activate DFU mode on BLE chip (writing to the specific characteristic).
The app can send log commands and CAN packets but sometimes it gets corrupted data.
One thing that seems strange to me, and could be the cause of corrupted data, is the timer event in BLE code, which is responsible to take data received on UART from MCU and send it over bluetooth (see <a href="https://github.com/CANBus-Triple/CBT-BLE112-Firmware/blob/master/script.bgs#L155">hardware_soft_timer event</a> in BLE firmware script).
This timer is activated when a device is connected via bluetooth, on <a href="https://github.com/CANBus-Triple/CBT-BLE112-Firmware/blob/master/script.bgs#L207">line 207 of the bgscript</a>:
<blockquote>call hardware_set_soft_timer((32768/1000) * conn_interval / 4, 2, 0)</blockquote>
The first argument is the time interval (expressed in 1/32768 seconds) on which the timer event will be fired.
Its value depends on <i>conn_interval</i> variable, which is set by the connected device. Android set this value to 7.5ms (see http://stackoverflow.com/questions/21398766/android-ble-connection-time-interval), so the resulting interval will be less than 2ms!
So apparently the <i>hardware_soft_timer</i> event may be firing too fast.
I will try to change its value, but until now I was not able to update firmware to BLE chip.
Hi, I've published the source code of my windows application which logs CBT packets through serial port.
You can find it here: https://github.com/eiannone/CANBus-Triple-Logger
It's written in C# using WPF.
You can download windows binaries directly here: https://github.com/eiannone/CANBus-Triple-Logger/releases/download/1.0/CanLogger.zip
Note that for filtering can messages using mask, you need my specific firmware version, wchich you can find here: https://github.com/eiannone/CANBus-Triple/tree/can-mask
I've set up a separate project for the core .dll (<a href="https://github.com/eiannone/CANBus-Triple-Dll">CANBus-Triple-Dll</a>), which you can reuse in other projects.
It contains a CBTController class, which you can instantiate passing serial port name, and then call methods, for example:
var cbt = new CBTController("COM1");
var info = await cbt.GetSystemInfo();
Console.Writeln("Device: " + info["name"]);
Hi, I would like to connect my CAN Bus Triple to both HS (High Speed) and MS (Medium Speed) buses on my Mazda 3 (2007).
I can hook to MS CAN bus through stereo or LCD harness, I know they both have the CAN pins for that bus.
Now I'm searching for a convenient location to connect to HS bus.
Obviously I could use the standard OBD2/J1962 external diagnostic connector, but I dont't want to expose wirings so I prefer to use an internal cable.
Can anyone suggest me how can I hook to HS bus?
Figured out what caused my error. Solved creating a "hardware" subfolder in my Arduino sketchbook folder and putting CANBus-Triple folder into it. Then in the Arduino IDE I selected "CANBus Triple" from "Tools" -> "Board".
Previously I had selected "Arduino Leonardo" as board, and "CANBus Triple" was not in the list.