From 1df34c0946fc24f2f4565d68541e919b0af01a44 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 16 Aug 2017 22:24:04 +0800 Subject: [PATCH] update close dev --- gdata-characteristic.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gdata-characteristic.js b/gdata-characteristic.js index 8eaa9dc..79e5b1a 100644 --- a/gdata-characteristic.js +++ b/gdata-characteristic.js @@ -74,8 +74,14 @@ function printString(str){ printer.cut(true, 8) } -process.on('SIGINT', ()=>{ - device.close() +process.on('SIGINT', async ()=>{ + await new Promise((resolve, reject) => { + device.close(()=>{ + console.log('serial device close') + resolve(null) + }) + }) + process.exit(0) }) module.exports = DataCharacteristic