Code Monkey home page Code Monkey logo

obd-parser-cli's Introduction

obd-parser-cli

A CLI tool that can interface with On Board Diagnostics (OBD II) of vehicles.

Compatibility and Testing

This software has only been tested with a Volkswagen MK6 GTI. Your success in using this software with your vehicle might vary.

Using this software and related libraries is done so at your own risk.

Install

npm install obd-parser-cli -g

NOTE: This module has a native dependency (serialport) that must be compiled during install. Please ensure you have the relevant tools for compiling C/C++ installed on your machine - typically this is Python v2.7 and developer tools such as GCC, Visual Studio, or XCode. More details can be found here

Connecting to OBD via USB

Connecting to your vehicle's OBD system is relatively simple, you just need a USB ELM327 cable like these. You might need to install drivers to get the cable working with your laptop, such as the macOS drivers at this link.

After purchasing a cable and installing any required drivers you can connect your ELM327 cable to your laptop via USB and plug the other end into the cars OBD port. The OBD port is usually above your gas/break pedal area.

Once you've plugged in your cable to both the laptop and vehicle you can run the command ls /dev/tty.* to verify the connection is detected. On macOS this will print something like the following:

$ ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbserial

The existence of /dev/tty.usbserial tells us that the connection is detected and available for use by this CLI. You can use it like so:

$ obd poll -c serial -b 38400 -i /dev/tty.serialusb "Engine RPM"

The -c serial tells us that we want to use a serial connection, -b specifies the baudrate (this might vary based on vehicle) ,and -i specifies the interface that the serial connection is running at.

Usage

Once installed you can run the program from a terminal. Here's how to load the help menu:

$ obd --help

๐Ÿš”  OBD CLI ๐Ÿš˜

  Usage: index [options] [command]


  Commands:

    list                                      list supported pids that can be passed to "poll" commands
    poll <pid> [pids...]                      poll for an OBD value(s) specified by <pid> or a list of pids
    monitor <pid:interval> [pid:interval...]  similar to poll, but continously checks PID values every n milliseconds,
        e.g 0C:1000 will get RPM every 1000 milliseconds

  Options:

    -h, --help                 output usage information
    -V, --version              output the version number
    -c, --connection <string>  type of connection, valid options are "fake" or "serial"
    -b, --baudrate <number>    control connection baudrate, e.g 38400
    -o, --outdir <string>      loation to create folder containing monitor results
    -i, --interface <name>     the interface to use for connection, e.g /dev/tty.serialusb

Listing PIDs (list)

Use the list command to view PIDs that can be read from vehicles. Currently only a handful are supported by this module and certain vehicles will not support all PIDS either.

Here's how you can view them:

$ obd list

๐Ÿš” OBD CLI ๐Ÿš˜

Available PIDs for "poll" commands are:

2F - Fuel Level Input
0C - Engine RPM
05 - Engine Coolant Temperature
0D - Vehicle Speed
04 - Calculated Engine Load
0A - Fuel Pressure
0B - Intake Manifold Absolute Pressure
0F - Intake Air Temperature
10 - MAF Air Flow Rate
11 - Throttle Position
1C - OBD Standard
03 - Fuel System Status
20 - Supported PIDs

Example command usage: "obd poll 2F"

It's also valid to supply the name, e.g "Fuel Level Input"

Polling (poll)

Use the poll command to read (poll) values from a vehicle. You must pass the connection option using "-c" or "--connection". Here we use the "fake" connection type since we are just testing, but you can also pass "serial" as explained in the help output.

Once you've entered connection options you can then list the PIDs by name, or code that you need to read like so:

$ obd poll -c fake "Engine RPM" 2f

๐Ÿš”  OBD CLI ๐Ÿš˜

Connecting via "fake" type...
OBD module intialised...

Results:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Engine RPM       โ”‚ 4989.00 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Fuel Level Input โ”‚ 37.65   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The above example uses the "fake" connection type and therefore returns randomised values for the PIDs you requested. If you'd like to connect via a serial conncetion you can try the following (macOS tested) example:

$ obd poll -c serial -b 38400 -i /dev/tty.serialusb "Engine RPM"

๐Ÿš”  OBD CLI ๐Ÿš˜

Connecting via "serial" type...
OBD module intialised...

Results:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Engine RPM โ”‚ 835.50 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Monitor

The monitor command is similar to poll, but instead it prints lines of JSON continuously until the process is killed. You can use the --output option to specify a directory to write JSON files to that will contain this data. This creates a folder in the specified output directory with the current date, and then writes the JSON to folders that represent each trip taken. Inside each folder a JSON file is created. The name of the file will be 0.json by default. Once this file reaches ~128KB in size a new file, 1.json will be created, and so on until the process is killed.

Here's a sample command and output data:

$ obd monitor 0d:100 0c:1000 05:5000 -c serial -i /dev/tty.usbserial -b 38400

๐Ÿš”  OBD CLI ๐Ÿš˜

Connecting via "fake" type...
OBD module intialised...

{"ts":"2017-03-15T16:57:18.296Z","bytes":"410D26","value":38,"counter":715,"pretty":"38km/h","name":"Vehicle Speed","pid":"0D"}
{"ts":"2017-03-15T16:57:18.318Z","bytes":"410C16CA","value":1458.5,"counter":716,"pretty":"1458.5rpm","name":"Engine RPM","pid":"0C"}
{"ts":"2017-03-15T16:57:18.946Z","bytes":"410F43","value":27,"counter":717,"pretty":"27ยฐC","name":"Intake Air Temperature","pid":"0F"}
{"ts":"2017-03-15T16:57:19.295Z","bytes":"410D26","value":38,"counter":718,"pretty":"38km/h","name":"Vehicle Speed","pid":"0D"}
{"ts":"2017-03-15T16:57:19.316Z","bytes":"410C1684","value":1441,"counter":719,"pretty":"1441rpm","name":"Engine RPM","pid":"0C"}
{"ts":"2017-03-15T16:57:20.296Z","bytes":"410D22","value":34,"counter":720,"pretty":"34km/h","name":"Vehicle Speed","pid":"0D"}
{"ts":"2017-03-15T16:57:21.235Z","bytes":"410572","value":74,"counter":722,"pretty":"74ยฐC","name":"Engine Coolant Temperature","pid":"05"}

If using the --output option, then the created folder structure might look as follows if you had two trips in a given day:

| |____
| | |____2017-03-12
| | | |____2ee5ff94-a02d-4791-9cd8-8b0d9770c34f
| | | | |____0.json
| | | |____599d7463-c568-441d-b6f7-86ea92ea3e59
| | | | |____0.json
| | | | |____1.json
| | | | |____2.json
| | | | |____3.json

obd-parser-cli's People

Contributors

evanshortiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

obd-parser-cli's Issues

Install errors

Hi!! Thanks for this project!!

When I try to install I get this errors, any ideas?

What nodejs version you are using?

thanks

node-pre-gyp http Pre-built binary not available for your system, looked for https://github.com/voodootikigod/node-serialport/releases/download/2.1.2/serialport-v2.1.2-node-v79-darwin-x64.tar.gz (falling back to source compile with node-gyp)
node-pre-gyp verb command build [ 'rebuild' ]
node-pre-gyp http Connection closed while downloading tarball file (falling back to source compile with node-gyp)
node-pre-gyp verb command build [ 'rebuild' ]
CXX(target) Release/obj.target/serialport/src/serialport.o
CXX(target) Release/obj.target/serialport/src/serialport.o

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.