From 200cf61089f26c7cafcf991b536a121a1697ca3a Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 26 Oct 2018 21:22:34 +0800 Subject: [PATCH] add example --- index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..06cf3f5 --- /dev/null +++ b/index.js @@ -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) +}) \ No newline at end of file