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-watch

v1.0.1

Published

A simple package on top of serialport for watching COM port connect/disconnect device

Downloads

7

Readme

Serialport-watch, detect connect/disconnect

This module will watch computer SerialPorts, and will fire connect/disconnect events.

Installing

You can install this package via npm:

npm install serialport-watch --save

Important: This package tested with serialport @ 3.1.2 on ubuntu 16.

Basic usage

You can find latest examples in test.js file. Here is simple usage:

var $watch = require("serialport-watch");

$watch.watch();
$watch.events.on("connect" , function (port , x) {
    console.log("port connected: " , port , x);
});

$watch.events.on("disconnect" , function (port , x) {
    console.log("port disconnected: " , port , x);
});

It will result:

port connected:  /dev/ttyUSB0 { comName: '/dev/ttyUSB0',
  manufacturer: 'FTDI',
  serialNumber: 'FTDI_FT232R_USB_UART_AJ03JBD7',
  pnpId: 'usb-FTDI_FT232R_USB_UART_AJ03JBD7-if00-port0',
  vendorId: '0x0403',
  productId: '0x6001' }
port connected:  /dev/ttyUSB1 { comName: '/dev/ttyUSB1',
  manufacturer: 'FTDI',
  serialNumber: 'FTDI_FT232R_USB_UART_AJ03JBD3',
  pnpId: 'usb-FTDI_FT232R_USB_UART_AJ03JBD3-if00-port0',
  vendorId: '0x0403',
  productId: '0x6001' }

Methods reference

There are some functions to work more with this module, here we list them. If something is missing, you can open index.js to see if something is missed here.

void watch()

Starts watching ports. Before calling this function connect/disconnect events won't be triggered

void stop()

Will stop watching ports. Can be called after watch() is called

EventEmitter events

The event emitter object that component works with. Can be used for setting handlers

boolean watching()

Returns if ports are watching or not.

Promise getPorts()

Gets the all ports, event if nothing is connected.