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

serialport-slip

v0.1.0

Published

SLIP protocol implementation for serial communication physical interfaces

Downloads

9

Readme

node-serialport-slip

The node-serialport-slip is an implementation of the Serial Line Internet Protocol (RFC 1055) designed to work over serial ports and modem connections. node-serialport-slip extends node-serialport library which is bult to access serial ports.

Since SLIP is a subclass of SerialPort it's worth to read node-serialport docs first.

For most use cases you can install node-serialport-slip using npm:

  npm install serialport-slip

Usage

Start with instantiating SLIP:

  var SLIP = require("serialport-slip")
  var slip = new SLIP("path-to-port", {
    baudrate: 57600
  }, {
    'endByte': 0xC0
  });

Here you can specify (in this order):

  1. Path to serial port - required.
  2. Options - optional and described in node-serialport docs.
  3. Protocol definition - optional, described below.

In order to transmit message use sendMessage method like so:

  slip.sendMessage(new Buffer([0x10, 0x11, 0x12]), function (err) {
    //error handling routine
  })

Where new Buffer([0x10, 0x11, 0x12]) is data that needs to be sent. serialport-slip adds a special END byte to it , which distinguishes datagram boundaries in the byte stream, also if the END byte occurs in the data to be sent, the two byte sequence ESC, ESC_END is sent instead, if the ESC byte occurs in the data, the two byte sequence ESC, ESC_ESC is sent.

Default END, ESC, ESC_END, ESC_ESC hex values are in the following teble:

|Hex value | Abbreviation | Description| |-----|-----|---------------------------| |0xC0 | END | Frame End| |0xDB | ESC | Frame Escape| |0xDC | ESC_END | Transposed Frame End| |0xDD | ESC_ESC | Transposed Frame Escape|

You are able to extend escaping rules and redefine default hex values, read "Extending protocol" section for details.

Each time incoming message occurs slip object fires 'message' event, so in order to handle messages you can do something like:

  slip.on('message', function (message) {
    console.log('Message recieved', message)
  })

Extending protocol

Default protocol settings are:

  {
    "messageMaxLength": 256,
    "endByte": 0xC0,
    "escapeByte": 0xDB,
    "escapeRules": [
      {
        "initialFragment": 0xC0,
        "replacement": 0xDC
      },
      {
        "initialFragment": 0xDB,
        "replacement": 0xDD
      }
    ]  
  }

You can change settings using third argument while SLIP instantiation like so:

  var slip = new SLIP("path-to-port", {
    baudrate: 57600
  }, {
    'endByte': 0xC3,
    "escapeRules": [
      {
        "initialFragment": 0xC3,
        "replacement": 0xDC
      },
      {
        "initialFragment": 0xDB,
        "replacement": 0xDD
      }
    ]  
  });

This will change default 0xC0 value for END byte to 0xC3, and add new escaping rule.