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