User Tools

Site Tools


howto:scantool

Diagnose Automobile Problems with ScanTool

Introduction

Since 1996, all cars sold in the United States are required to have an On Board Diagnostics-II interface built into them. Many older cars also have OBD-II interfaces. European cars also have OBD interfaces. OBD systems give the vehicle owner or a repair technician access to state of health information for various vehicle sub-systems. Wikipedia has the basics.

Most people first encounter OBD when the Check Engine light illuminates on their dashboard. Their repair technician plugs a code reader into the OBD port on their car and reads the diagnostic information.

Emissions testing stations in many states in the U.S. also use the OBD port to determine if your car meets emissions standards.

The EeePC makes a perfect portable diagnostic machine. All that is needed is an interface device compatible with your car, and software to run on the EeePC. You can purchase interface devices on the Internet at sites like scantool.net. Most devices are based on the ELM 327 chipset. What you want is one of the USB versions, since that is the port you will use on the EeePC. I purchased a device on Ebay for about 33 US dollars. Just search for Elm327 USB.

Note: Beginning in 2008, all cars sold in the United States are required to use the ISO 15765-4 signaling standard (a variant of the Controller Area Network (CAN) bus). You'll want to acquire an interface that supports this.

Once you have a compatible interface device, if you're a Windows XP user, you've got it made. Chances are the device you purchased comes with software. If not, download the latest ScanTool program from scantool.net. divil2k has customized the ScanTool program to fit the small EeePC 701 screen.

Unfortunately for Linux users, things are not so good. I have yet to find a pre-built binary on the Internet that works. You'll have to build from source using the instructions below.

Getting Started Building ScanTool for Linux

I built the program on eeeXubuntu, but the instructions should work for almost any of the other Linux distros.

Since you'll have to run the program as root, we might as well build the program as root.

sudo -i

You'll need software build tools.

aptitude install build-essential
aptitude install autoconf
aptitude install unzip

The ScanTool program uses a screen interface library called Allegro. For me, installation was as simple as:

aptitude install liballegro4.2 liballegro4.2-dev

If it isn't available in a repository, you'll have to download from the Allegro web site and build from source.

Building and Installing dzcomm Library

ScanTool also uses a serial port library called dzcomm and here's where things start to get harder. When you plug the Elm device into a USB port on the EeePC, an ftdi driver loads and redirects the USB port to a serial port. Most Linux kernels 2.4 and later automatically load this driver. Assuming it does, it shows up as device /dev/ttyUSB0. Unfortunately, dzcomm doesn't get along very well with the USB ftdi redirector, so we're going to have to make some code patches and build it ourselves.

Download the dz099i.zip source code. In a terminal window, unzip it in root's home directory and change into the directory.

cd
unzip dz099i.zip
cd dz099i

The following code patches were provided by Kees Cook.

Open file dz099i/include/dzcomm/dzconfig.h and change the line

#define INLINE          inline

to

#ifndef INLINE
# define INLINE          inline
#endif

Open file dz099i/src/comm.c and change the lines

    /* And call the Machine/OS appropriate installer */
    if (comm_port_funcs->install_handler) {
      if (comm_port_funcs->install_handler(port) == 0) return 0;
     }

so they look like this:

    /* And call the Machine/OS appropriate installer */
    if (comm_port_funcs->install_handler) {
      if (comm_port_funcs->install_handler(port) == 0) {
        dz_make_comm_err("OS handler failed.");
        return 0;
       }
     }

Change these lines

  /* Make sure it is being sent in a machine/OS correct way */
  c = comm_port_funcs->out(port, s);
  for (i=1; ((s[i]!=0) && (c==i)); i++) c += comm_port_funcs->out(port, &s[i]);

to

  /* Make sure it is being sent in a machine/OS correct way */
  c = comm_port_funcs->out(port, (unsigned char *)s);
  for (i=1; ((s[i]!=0) && (c==i)); i++) c += comm_port_funcs->out(port, (unsigned char *)&s[i]);

Change these lines

   /* Make sure it is being sent in a machine/OS correct way */
   c = comm_port_funcs->out(port, s);
   for (i=1; ((s[i]!=0) && (c==i)); i++) c += comm_port_funcs->out(port, &s[i]);
   if (c==i) c += comm_port_funcs->out(port, &r);

to

   /* Make sure it is being sent in a machine/OS correct way */
   c = comm_port_funcs->out(port, (unsigned char *)s);
   for (i=1; ((s[i]!=0) && (c==i)); i++) c += comm_port_funcs->out(port, (unsigned char *)&s[i]);
   if (c==i) c += comm_port_funcs->out(port, (unsigned char *)&r);

Open file dz099i/src/linux/lcomm.c. At around line 188, you'll find this code.

int linux_comm_port_install_handler(comm_port *port)
{ /* The setserial man page and source has provided a lot of the inspiration for this */
    struct serial_struct sio;
    struct termios       tio;
    speed_t              speed;

Add the following code below the speed_t line:

   int                  sio_avail = 0;

   /* USB serial ports don't have this information */
   if (ioctl(port->fd, TIOCGSERIAL, &sio) < 0) sio_avail = 0;

A little bit farther down, change the following code

   if (ioctl(port->fd, TIOCSSERIAL, &sio) < 0) return 0;
   if (ioctl(port->fd, TIOCSERCONFIG) < 0) return 0;

to

   if (sio_avail) {
      if (ioctl(port->fd, TIOCSSERIAL, &sio) < 0) return 0;
      if (ioctl(port->fd, TIOCSERCONFIG) < 0) return 0;
   }

Note: In Kees' original patch, he intialized the sio_avail variable to 1 (true), but I found that the code still did not work, at least on the EeePC. My understanding is that this code is attempting to “autoconfigure” the serial port. The ftdi redirector does not support autoconfiguration. But autoconfigure isn't really needed anyway. Maybe someone else can figure out a proper patch.

Near the bottom of the file, change

int linux_comm_set_line_status(comm_port *port, dzcomm_line line, int value)
{
   int flag;

to

int linux_comm_set_line_status(comm_port *port, dzcomm_line line, int value)
{
   int flag=0;

Change to the dz099i directory and build and install dzcomm.

chmod u+x fixunix.sh
./fixunix.sh
./configure
make depend
make
make install

Building ScanTool

Now we're ready to build ScanTool. Download devil2k's patched code for the EeePC. Be sure to get the latest version, which on 4 July 2008 is ScanTool for EEE PC Build 1.zip. Unzip it to a suitable location.

cd
unzip "ScanTool for EEE PC Build 1.zip"

Change into the source directory.

cd scantool
cd source

Open file makefile in an editor. Change each of the 3 lines near the top that begin with

  AL_LIBS =

to

  AL_LIBS = `allegro-config --libs`

IMPORTANT: Those are backtick characters; not single quotes. On the EeePC 701, its the key in the upper left corner next to Esc.

Change the line that says

BIN = ScanTool.exe

to

BIN = ScanTool

Build the program. You don't need to install it.

make

Using ScanTool

Plug your device into any USB port and verify that the ftdi driver loads and creates the serial device.

ls -l /dev/ttyUSB0

In root's home directory, create a small shell file called st.

#!/bin/sh

rm /dev/ttyS7
ln -s /dev/ttyUSB0 /dev/ttyS7
cd /root/scantool/source
./ScanTool

Make it executable.

chmod u+x st

Plug the device into the OBD-II port in your car and turn the ignition on (but do not start the engine). Run ScanTool.

./st

ScanTool will default to /dev/ttyS0 (COM1). Change it to /dev/ttyS7 (COM8). 9600 for the speed should work. Also change to Windowed interface.

You'll probably find that you need to autohide the panel at the bottom of the screen. For eeXubuntu, go to Start menu –> Settings –> Panel Manager and check Autohide.

See the following forum messages for additional information:

Enjoy.

Authors

This page written by PhantomsDad.

rio b and you numero rio

howto/scantool.txt · Last modified: 2012/01/28 09:49 by hello