Coder Social home page Coder Social logo

apearson / insteon-packet-parser Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 147 KB

A simple Insteon packet parser to be used by Node Serialport and a PowerLinc Modem (PLM) library or program

License: BSD 3-Clause "New" or "Revised" License

TypeScript 100.00%

insteon-packet-parser's Introduction

InsteonPacketParser

A simple Insteon packet parser to be used by Node Serialport and a PowerLinc Modem (PLM) library or program.

If you see any problems, have any advice, or want to help out please open an issue.

Examples

Send Command and read replies

const SerialPort = require('serialport');
const {InsteonParser} = require('../dist/main');

/* Open serial port */
const port = new SerialPort('/dev/tty.usbserial-A60336ZZ', {
  baudRate: 19200,
  dataBits: 8,
  stopBits: 1,
  parity: 'none'
});

/* Creating new parser */
const parser = new InsteonParser();

/* Porting serial port to parser */
port.pipe(parser);

/* On data */
parser.on('data', (data)=> console.info(data));

/* Result
  {
    id: 0x73,
    type: 'Get IM Configuration',
    autoLinking: true,
    monitorMode: true,
    autoLED: true,
    deadman: true,
    success: true
  }
*/

/* On serial port opened send command */
port.on('open', () => {
  const buf = Buffer.alloc(2);
        buf.writeUInt8(0x02, 0);
        buf.writeUInt8(0x73,1);

  port.write(buf, (error) => {
    if(error){
      console.error(`Error: ${error}`);
    }
  });
});

insteon-packet-parser's People

Contributors

apearson avatar dependabot[bot] avatar paulwieland avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

paulwieland

insteon-packet-parser's Issues

All exceptions should be caught

All exceptions should be caught, sent as an .on('error'), and the parsing should be reset (throwing away any garbage data)

[โ†’][13.33.B8][S]: Cmd: 0x20 0x12
(node:29) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Parsers_1.Parsers[byte] is not a constructor
(node:29) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Unit Testing

Need to write unit testing or at least a plan for unit testing these parsers.
Prefer the mocha testing framework

Raw Data vs Parsed Data

Use lowercase variables for raw data and CamelCase for parsed data.

Example:

flags: 0x1f
Flags: {
hops: 3,
remaining: 2,
etc....
}

Need to parse flag data

Currently flag data is being passed back as a byte, this is not the best approach and could be parsed

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.