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

chrome-apps-serialport

v1.0.9

Published

A Chrome Apps-compatible implementation of the node-serialport module

Downloads

22

Readme

chrome-apps-serialport

The chrome-apps-serialport JavaScript module is a Chrome Apps-compatible implementation of the node-serialport module used for serial communication.

This library was created to provide Chrome Apps (including NW.js) interoperability for libraries already depending on the node-serialport module for serial communication (e.g. johnny-five, firmata, etc.).

NW.js Support

The main use case for this library is to simplify usage of Johnny-Five and Firmata inside NW.js. While node-serialport can be used within NW.js, it needs to be specifically recompiled. This can prove to be troublesome. This library bypasses this problem by using the chrome.serial API which is already available in NW.js (via the builtin support for the Chrome Apps APIs).

The chrome-apps-serialport module also fixes a long-standing issue in NW.js that must be dealt with in order to successfully use the serial port. This means that, if you use this module, you do not need to bother importing the nwjs-j5-fix module. It will be taken care of for you.

Installation

npm install chrome-apps-serialport

Basic Usage

const SerialPort = require("chrome-apps-serialport").SerialPort;

let port = new SerialPort("/dev/tty-usbserial1", {
  baudrate: 57600
});

Using the module with Johnny-Five

const SerialPort = require("chrome-apps-serialport").SerialPort;
const Firmata = require("firmata-io")(SerialPort);
const five = require("johnny-five");

SerialPort.list().then(ports => {

  const device = ports.find(port => {
    return port.manufacturer && port.manufacturer.startsWith("Arduino")
  });

  const board = new five.Board({
    io: new Firmata(device.path)
  });

  board.on("ready", () => {
    console.log("Johnny-Five is ready!");
    const led = new five.Led(13);
    led.blink(500);
  });

  board.on("close", () => console.log("Closed!"));

});

History

The chrome-apps-serialport module is a repackaging of browser-serialport (created by Glen Arrowsmith). This module was working great until API changes were introduced in version 8 of node-serialport. These changes forced dependent projects to update which, in turnm broke compatibility with browser-serialport. Since browser-serialport has not been updated in many years, I packaged chrome-apps-serialport to insure compatibility with the latest version of node-serialport.

Compatibility

Unless you are using very specialized functionalities (see below), you should be able to use chrome-apps-serialport wherever node-serialport v8.x+ is used. Obviously, this is only true if you are executing the code within a Chrome App or NW.js.

Due to the underlying architecture (chrome.serial), there are a few differences that should be noted:

  • The connection options are a little bit different:

    • dataBits: 7, 8
    • stopBits: 1, 2
    • parity: 'none', 'even', 'mark', 'odd', 'space'
    • flowControl: 'RTSCTS'
    • highWaterMark: ignored
    • lock: ignored
    • xon, xoff, xany: ignored
  • Parsers are not implemented.

  • The read() method is not implemented.

  • The drain() method can be called but will not do anything. This also means that no drain events are ever dispatched.

  • Only UTF8 is supported when passing strings to the write() method.

  • Error messages differ.