1.0.0 • Published 9 years ago
watch-serial v1.0.0
watch-serial
watch for new serial devices. stream with plug/unplg events.
var serialport = require('serialport');
var watch = require('watch-serial');
// you must pass the serialport module to watch
// it's no longer a direct dependency dude to native deps sucking
var stream = watch(serialport);
stream.on('data',console.log)
this will output something like this when a device is plugged then unplugged.
{ event: 'plug',
device:
{ comName: '/dev/ttyACM1',
manufacturer: undefined,
pnpId: 'usb-Pinoccio_Pinoccio_95335343036351E07191-if00' },
id: '/dev/ttyACM1|undefined|usb-Pinoccio_Pinoccio_95335343036351E07191-if00' }
{ event: 'unplug',
device:
{ comName: '/dev/ttyACM1',
manufacturer: undefined,
pnpId: 'usb-Pinoccio_Pinoccio_95335343036351E07191-if00' },
id: '/dev/ttyACM1|undefined|usb-Pinoccio_Pinoccio_95335343036351E07191-if00' }
changelog
1.0.0
breaking chages from 0.0.X. serialport must be passed into watch. its no longer a dep