From 08ce2231906df842b23d8a978dcd665299169aec Mon Sep 17 00:00:00 2001 From: Blaine Schmeisser Date: Fri, 2 Jan 2015 12:54:05 -0600 Subject: [PATCH 1/3] Close the button when you can no longer write. --- BigRedButton.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BigRedButton.js b/BigRedButton.js index d8759d6..ca05625 100644 --- a/BigRedButton.js +++ b/BigRedButton.js @@ -55,7 +55,11 @@ function BigRedButton(index) util.inherits(BigRedButton, events.EventEmitter); BigRedButton.prototype.askForStatus = function() { - this.hid.write(cmdStatus); + try { + this.hid.write(cmdStatus); + } catch(e) { + this.close(); + } }; BigRedButton.prototype.interpretData = function(error, data) { From bcf562b699d6e0fd20b8ea0ef75a2bcb58765f17 Mon Sep 17 00:00:00 2001 From: Blaine Schmeisser Date: Fri, 2 Jan 2015 12:54:16 -0600 Subject: [PATCH 2/3] Add package.json file so it can be published to npm. If not published, it can still be included via git. ~~~ "BigRedButtonNodeHID": "git+ssh://git@github.com:codepope/BigRedButtonNodeHID.git#1.0.0" ~~~ --- package.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..5c8485b --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "BigRedButtonNodeHID", + "version": "1.0.0", + "description": "Big red button helper.", + "main": "BigRedButton.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git@github.com:codepope/BigRedButtonNodeHID.git" + }, + "keywords": [ + "big", + "red", + "button", + "helper", + "io", + "usb", + "hid" + ], + "author": "codepope", + "license": "MIT", + "bugs": { + "url": "https://github.com/codepope/BigRedButtonNodeHID/issues" + }, + "homepage": "https://github.com/codepope/BigRedButtonNodeHID" +} From bf89ca34c18074b2027782d9d1197b4074e3bf0a Mon Sep 17 00:00:00 2001 From: Blaine Schmeisser Date: Fri, 2 Jan 2015 19:34:23 -0600 Subject: [PATCH 3/3] Create a `resetDevices()` method to reset the cached devices. --- BigRedButton.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BigRedButton.js b/BigRedButton.js index ca05625..df309b5 100644 --- a/BigRedButton.js +++ b/BigRedButton.js @@ -102,3 +102,7 @@ BigRedButton.prototype.isLidDown = function() { exports.BigRedButton = BigRedButton; exports.deviceCount = function () { return getAllDevices().length; } +exports.resetDevices = function () { + allDevices = null + getAllDevices(); +}