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 = ; $watch;$watchevents; $watchevents;
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.