From 593acf9204e3f66d81a5abb96b89762766b27784 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 14 Aug 2017 23:25:32 +0800 Subject: [PATCH] fix error --- gdata-characteristic.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdata-characteristic.js b/gdata-characteristic.js index 1a80861..dc0f9d6 100644 --- a/gdata-characteristic.js +++ b/gdata-characteristic.js @@ -1,8 +1,8 @@ const bleno = require('bleno') const config = require('./config.json') const escpos = require('escpos') -const device = escpos.Serial(config.printer.serial) -const printer = escpos.Printer(device) +const device = new escpos.Serial(config.printer.serial) +const printer = new escpos.Printer(device) let isOpen = false device.open(()=>{ @@ -59,4 +59,8 @@ function printString(str){ printer.cut(true, 8) } +process.on('SIGINT', ()=>{ + device.close() +}) + module.exports = DataCharacteristic