Wikia

Libobd Wiki

Home

Talk0
1page on
this wiki

Welcome to the Libobd WikiEdit

Libobd is an interface library for communicating with OBD2 ECU's via ELM327 compatible scan tools.

OverviewEdit

The Libobd library consists of several classes, the primary of which is ObdThread. This is a QThread based class, and is the primary interface between a user application and the library. ObdThread runs its own sequential event loop, and provides a group of publicly available functions to add requests and commands to this loop.

InstallationEdit

git clone https://git.gitorious.org/libobd/libobd.git


cd libobd


qmake


make

sudo make install


APIEdit

After installation of libobd, to use it you need only add LIBS += -lobd to your Qt .pro file, and then #include <ObdThread> in your source file.

To initialize ObdThread and prepare it for use, you must call these functions:

ObdThread::start()

This function starts the QThread loop, and is required before anything else.

ObdThread::setPort(QString)

This sets the port that ObdThread will use to connect to a scan tool. On windows, COM1, COM5, or //./COM20. On *nix systems: /dev/ttyUSB0, /dev/ttyS0, etc.

ObdThread::setBaud(int)

This sets the baud rate that ObdThread will use to connect to a scan tool. Most scan tools default to 38400, or more rarely 115200, though some stil use 9600.


Other functions of interest:

ObdThread::addRequest(int mode, int pid, int priority,int wait);

mode - Integer value of mode. Eg: 0x01 for mode 1.

pid - Integer value of pid. Eg: 0x0D for vehicle speed

priority - How many cycles per sample. 1 means request every cycle. 2 means every other cycle, 3 means every third cycle.

wait - This should be set to 1 if, and ONLY if the vehicle only has a single ECU responding the messages. Leave it at 0 unless you know what you're doing, as this does not work on some cheaper scan tools.

Signals of interest:

ObdThread::pidReply(QString pid,QString val,int set,double time);

pid - string representation of the request. Mode 0x01 Pid 0x0D would be "010D".

val - value. This can often be converted directly to a float via val.toFloat();

set - Which "Cycle" the request came from. This is useful for keeping data sets together.

time - epoch time that the response was recieved. Use this for figuring time between requests and the like.

Around Wikia's network

Random Wiki