Git Product home page Git Product logo

obd2's Introduction

OBD for JAVA

Supported commands

Although any commands can be send with this lib, the list of pure object command does not cover all existing commands.

Some commands are missing, because I didn't find documentation about it or because my car is pretty old and doesn't support many OBD-II commands.

Here are the list of all known command and there status (implemented or not):

Usage

Basic example

import io.github.macfja.obd2.elm327.Commander;
import io.github.macfja.obd2.elm327.command.*;
import io.github.macfja.obd2.command.livedata.*;

public class Example {
    Commander commander = new Commander();

    public static void main(String[] args) {
        new Example();
    }

    public Example() {
        commander.setCommunicationInterface(OBD2.getOutputStream(), OBD2.getInputStream());
        System.out.println(commander.sendCommand(new DeviceDescription()));
        // Should print something like "OBDII to RS232 Interpreter"
        System.out.println(commander.sendCommand(new EngineRPM()));
        // Should print something like "875rpm"
    }
}

Sending custom command

import io.github.macfja.obd2.response.RawResponse;
import io.github.macfja.obd2.Commander;
import io.github.macfja.obd2.Command;
import io.github.macfja.obd2.Response;
import io.github.macfja.obd2.Unit;
import io.github.macfja.obd2.SimpleCommands;

Commander commander;

// Setup the `commander`
// [...]

Command customCommand = new Command() {
    @Override
    public String getRequest() {
        return "MyCode";
    }

    @Override
    public Response getResponse(byte[] rawResult) throws ScriptException {
        return new RawResponse(rawResult) {};
    }
};
commander.sendCommand(customCommand);

// OR

Command customCommand2 = SimpleCommands.create("My Code");
commander.sendCommand(customCommand2);

Installation

From the sources

Clone the project:

git clone https://github.com/MacFJA/OBD2.git

Install the project into your local Maven repository:

cd OBD2/
mvn clean
mvn install

Remove the source:

cd ..
rm -r OBD2/

Add the dependency in your Maven project:

<project>
    <!-- ... -->
    <dependencies>
        <!-- ... -->
        <dependency>
            <groupId>io.github.macfja</groupId>
            <artifactId>obd2</artifactId>
            <version>1.1.0</version>
        </dependency>
        <!-- ... -->
    </dependencies>
    <!-- ... -->
</project>

From a release

Go to the realase page, and download the jar.

Next add the jar in your project classpath.

With JitPack

The library is available online for Gradle, Maven, Sbt and Leiningen with the help of JitPack.

See installation instruction here: (Spoiler: it's easy)

obd2's People

Contributors

macfja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar

obd2's Issues

Add library to Maven Repository

Right now the library is only installable manually (either by downloading the jar and add it to your classpath, or to install it in your local maven repository from the source).

It would be great to have it available from standard Maven (or Gradle, Ivy, etc.) repository.

But I never done it before and I have no idea how it works. Any help/hint/tutorial would be greatly appreciated.

[Help/Suggestion] Documentation help

First of all, thank you for this awesome library. You did a great job. However, I think your documentation needs to be elaborated. The documentation you provided is very basic. I would like to know more about livedata, livedata update duration,DTC, clearing fault codes and other usages. An example project or an elaborated documentation will be appreciated. Thank you @MacFJA

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.