# serialport-watch

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

Latest version **1.0.1** (published 2016-09-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install serialport-watch
pnpm add serialport-watch
yarn add serialport-watch
bun add serialport-watch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-09-08 |
| First published | 2016-09-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ali Torabi |
| Maintainers | connexion |

## Links

- npm: https://www.npmjs.com/package/serialport-watch
- npm.io page: https://npm.io/package/serialport-watch

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.15.0
- [asyncawait](https://npm.io/package/asyncawait.md) ^1.0.6
- [serialport](https://npm.io/package/serialport.md) ^3.1.2

## Recent versions

- 1.0.1 (latest) — 2016-09-08
- 1.0.0 — 2016-09-08

## 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:

```javascript
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.

---
_Source: https://npm.io/package/serialport-watch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
