add example

This commit is contained in:
Jay 2018-10-26 21:22:34 +08:00
parent 6d5f7faa69
commit 200cf61089

19
index.js Normal file
View File

@ -0,0 +1,19 @@
const DevObj = require('./deviceObject')
;(async function () {
let list = await DevObj.getPorts()
console.log('get port list :::: ', list)
let dev = new DevObj('/dev/tty.SLAB_USBtoUART', null)
dev.on('open', () => {
console.log('dev open')
}).on('close', () => {
console.log('dev close')
})
dev.connect()
}()).then(() => {}).catch(err => {
console.log(err)
})