jperkin / node-openzwave

node.js interface to libopenzwave
Other
110 stars 55 forks source link

unable to exit without ctrl-c #25

Closed amccool closed 10 years ago

amccool commented 10 years ago

please forgive my newbie nodejs status. If I call zwave.connect() I find it impossible to exit without a forceful exception or explicitly using Ctrl-C.

with a final statement of zwave.disconnect() I continue processing, but no exit from the script.

2014-02-21 22:11:03.686 ***** 2014-02-21 22:11:03.686 ***** Cumulative Network Statistics ***** 2014-02-21 22:11:03.687 *\ General 2014-02-21 22:11:03.687 Driver run time: . . . 0 days, 0 hours, 0 minutes 2014-02-21 22:11:03.687 Frames processed: . . . . . . . . . . . . . . . . . . . . 1 2014-02-21 22:11:03.687 Total messages successfully received: . . . . . . . . . . 0 2014-02-21 22:11:03.687 Total Messages successfully sent: . . . . . . . . . . . . 1 2014-02-21 22:11:03.687 ACKs received from controller: . . . . . . . . . . . . . 1 2014-02-21 22:11:03.687 * Errors 2014-02-21 22:11:03.687 Unsolicited messages received while waiting for ACK: . . 0 2014-02-21 22:11:03.687 Reads aborted due to timeouts: . . . . . . . . . . . . . 0 2014-02-21 22:11:03.687 Bad checksum errors: . . . . . . . . . . . . . . . . . . 0 2014-02-21 22:11:03.687 CANs received from controller: . . . . . . . . . . . . . 0 2014-02-21 22:11:03.687 NAKs received from controller: . . . . . . . . . . . . . 0 2014-02-21 22:11:03.687 Out of frame data flow errors: . . . . . . . . . . . . . 0 2014-02-21 22:11:03.687 Messages retransmitted: . . . . . . . . . . . . . . . . . 0 2014-02-21 22:11:03.687 Messages dropped and not delivered: . . . . . . . . . . . 0 2014-02-21 22:11:03.687 *** 2014-02-21 22:11:03.687 contrlr, Received: 0x01, 0x10, 0x01, 0x15, 0x5a, 0x2d, 0x57, 0x61, 0x76, 0x65, 0x20, 0x32, 0x2e, 0x33, 0x36, 0x00, 0x01, 0x91 2014-02-21 22:11:03.688 2014-02-21 22:11:03.688 contrlr, Received reply to FUNC_ID_ZW_GET_VERSION: 2014-02-21 22:11:03.688 contrlr, Static Controller library, version Z-Wave 2.36 2014-02-21 22:11:03.688 contrlr, Expected reply was received 2014-02-21 22:11:03.688 contrlr, Message transaction complete 2014-02-21 22:11:03.688 2014-02-21 22:11:03.688 contrlr, Removing current message 2014-02-21 22:11:05.791 mgr, Driver for controller /dev/ttyUSB0 removed -------------this is the final console.log statement before EOF--------------------------------------

amccool commented 10 years ago

I have changed to using process.kill(process.pid, 'SIGINT'); with process.on('SIGINT', function() { console.log('disconnecting...'); zwave.disconnect(); process.exit(); })

and this seems to be working