From c6298a18a0280bbc692d68aff8fb856729c7147c Mon Sep 17 00:00:00 2001 From: cactrot Date: Thu, 17 Sep 2015 19:13:51 -0700 Subject: [PATCH 1/3] Fix race condition and relaxed presence detect ping timings --- arduino_extension.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arduino_extension.js b/arduino_extension.js index 20e3726..2719565 100644 --- a/arduino_extension.js +++ b/arduino_extension.js @@ -133,7 +133,7 @@ queryFirmware(); pinging = true; } - }, 100); + }, 2000); } function hasCapability(pin, mode) { @@ -180,7 +180,11 @@ case CAPABILITY_RESPONSE: for (var i = 1, pin = 0; pin < MAX_PINS; pin++) { while (storedInputData[i++] != 0x7F) { - pinModes[storedInputData[i-1]].push(pin); + // This helped reduce error over a noisy wireless serial connection + if ( storedInputData[i-1] <= MAX_PINS ) + { + pinModes[storedInputData[i-1]].push(pin); + } i++; //Skip mode resolution } if (i == sysexBytesRead) break; @@ -502,11 +506,13 @@ device = potentialDevices.shift(); if (!device) return; - device.open({ stopBits: 0, bitRate: 57600, ctsFlowControl: 0 }); + // Moved set_receive_handler to the ready callback for open to fix a race condition. console.log('Attempting connection with ' + device.id); - device.set_receive_handler(function(data) { - var inputData = new Uint8Array(data); - processInput(inputData); + device.open({ stopBits: 0, bitRate: 57600, ctsFlowControl: 0 }, function() { + device.set_receive_handler(function(data) { + var inputData = new Uint8Array(data); + processInput(inputData); + }); }); poller = setInterval(function() { From 9b5ed3ed92d8ed75f06ecf45f61330071bfcf435 Mon Sep 17 00:00:00 2001 From: cactrot Date: Thu, 17 Sep 2015 19:57:44 -0700 Subject: [PATCH 2/3] Create index.html --- index.html | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..1252a09 --- /dev/null +++ b/index.html @@ -0,0 +1,7 @@ + + + + + Hello world + + From 83959ecf92c2e5afbec12d93f0c3287da5f23535 Mon Sep 17 00:00:00 2001 From: cactrot Date: Thu, 17 Sep 2015 19:58:46 -0700 Subject: [PATCH 3/3] Delete index.html --- index.html | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 index.html diff --git a/index.html b/index.html deleted file mode 100644 index 1252a09..0000000 --- a/index.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Hello world - -