npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serial-obd

v0.2.2

Published

Package for communicating with a serial/usb OBD-II reader.

Downloads

20

Readme

serial-obd 0.2.2

This version will only receive updates that were done in bluetooth-obd. On request I will update/sync this module with bluetooth-obd as this version is less-used.

Serial communication for OBD-II ELM327 devices.

This node module lets you communicate over a serial port with OBD-II ELM327 Connectors using Node.js.

Limitations

  • Only tested on Ubuntu
  • Only tested with rfcomm, and not with actual serial port yet.
  • Only tested on ELM327 devices.
  • Not all OBD-II Commands are implemented yet.

Use bluetooth-obd if you use a bluetooth OBD-II Connector!

Pre-requests

  • If it's a Bluetooth ELM327, then it should already be paired and connected with rfcomm connect!
  • You might need to run it with SUDO! (If it says: serial port X is not ready!)

Install

npm install serial-obd

Documentation

Basic usage

var OBDReader = require('serial-obd');
var options = {};
options.baudRate = 115200;
var serialOBDReader = new OBDReader("/dev/rfcomm0", options);
var dataReceivedMarker = {};

serialOBDReader.on('dataReceived', function (data) {
    console.log(data);
    dataReceivedMarker = data;
});

serialOBDReader.on('connected', function (data) {
    this.addPoller("vss");
    this.addPoller("rpm");
    this.addPoller("temp");
    this.addPoller("load_pct");
    this.addPoller("map");
    this.addPoller("frp");

    this.startPolling(2000); //Polls all added pollers each 2000 ms.
});

serialOBDReader.connect();

API

###OBDReader

Event: ('dataReceived', data)

Emitted when data is read from the OBD-II connector.

  • data - the data that was read and parsed to a reply object

Event: ('connected')

Emitted when the connection is set up (port is open).

  • data - the data that was read and parsed to a reply object

OBDReader(portName, options)

Creates an instance of OBDReader.

Params:
  • string portName Port that will be connected to. For example: "/dev/rfcomm0"

  • Object options Object that contains options, e.g.: baudrate, databits, stopbits, flowcontrol. Same options serialport module uses.

getPIDByName(Name)

Find a PID-value by name.

Params:
  • name Name of the PID you want the hexadecimal (in ASCII text) value of.
Return:
  • string PID in hexadecimal ASCII

parseOBDCommand(hexString)

Parses a hexadecimal string to a reply object. Uses PIDS. (obdInfo.js)

Params:
  • string hexString Hexadecimal value in string that is received over the serialport.
Return:
  • Object reply - The reply.

  • string reply.value - The value that is already converted. This can be a PID converted answer or "OK" or "NO DATA".

  • string reply.name - The name. --! Only if the reply is a PID.

  • string reply.mode - The mode of the PID. --! Only if the reply is a PID.

  • string reply.pid - The PID. --! Only if the reply is a PID.

connect()

Connect/Open the serial port and add events to serialport. Also starts the intervalWriter that is used to write the queue.

disconnect()

Disconnects/closes the port.

write(message, replies)

Writes a message to the port. (Queued!) All write functions call this function.

Params:
  • string message The PID or AT Command you want to send. Without \r or \n!
  • number replies The number of replies that are expected. Default = 0. 0 --> infinite

requestValueByName(name)

Writes a PID value by entering a pid supported name.

Params:
  • string name Look into obdInfo.js for all PIDS.

addPoller(name)

Adds a poller to the poller-array.

Params:
  • string name Name of the poller you want to add.

removePoller(name)

Removes an poller.

Params:
  • string name Name of the poller you want to remove.

removeAllPollers()

Removes all pollers.

writePollers()

Writes all active pollers.

startPolling()

Starts polling. Lower interval than activePollers * 50 will probably give buffer overflows.

Params:
  • number interval Frequency how often all variables should be polled. (in ms) If no value is given, then for each activePoller 75ms will be added.

stopPolling()

Stops polling.

LICENSE

This module is available under a Apache 2.0 license, see also the LICENSE file for details.