0.1.2 • Published 7 years ago

obd-parser-serial-connection v0.1.2

Weekly downloads
7
License
MIT
Repository
-
Last release
7 years ago

obd-parser-serial-connection

Circle CI

Connection module for use with odb-parser.

Install

npm install obd-parser-serial-connection

Usage

The typical usage scenario is described in the obd-parser module docs, but if you want to use this module to get a plain OBD connection you can use the example code below as a start.

var getConnector = require('obd-parser-serial-connection');

// Returns a function that will allow us to connect to the serial port
var connect = getConnector({
  serialPath: '/dev/tty.usbserial',
  serialOpts: {
    baudrate: 38400
  }
});

connect(configureFunction)
  .then(function () {
    console.log('connected to serial port!')
  })
  .catch(function (err) {
    console.error('oh noes');
  });


function configureFunction (connection) {
  return new Promise(function (resolve, reject) {
    // Set up the obd connection etc.
    conn.write('ATZ');
    conn.write('ATE0');
  });
}

CHANGELOG

  • 0.1.2 - Ensure errors result in Promise rejection. Use debug instead of fhlog.

  • 0.1.1 - Patch for serialport 2.1.X changes in autoconnect

  • 0.1.0 - Initial release