Update PicoBoard + WeDo extensions from main site

This includes sync compatibility changes
This commit is contained in:
Chris Willis-Ford 2015-07-24 17:18:51 +00:00
parent 374a4c5baf
commit 6c8387da72
2 changed files with 16 additions and 5 deletions

View file

@ -127,15 +127,24 @@
} }
} }
var poller = null;
var watchdog = null;
function tryNextDevice() { function tryNextDevice() {
// If potentialDevices is empty, device will be undefined. // If potentialDevices is empty, device will be undefined.
// That will get us back here next time a device is connected. // That will get us back here next time a device is connected.
device = potentialDevices.shift(); device = potentialDevices.shift();
if (!device) return;
device.open({ stopBits: 0, bitRate: 38400, ctsFlowControl: 0 }); if (device) {
device.open({ stopBits: 0, bitRate: 38400, ctsFlowControl: 0 }, deviceOpened);
}
}
var poller = null;
var watchdog = null;
function deviceOpened(dev) {
if (!dev) {
// Opening the port failed.
tryNextDevice();
return;
}
device.set_receive_handler(function(data) { device.set_receive_handler(function(data) {
//console.log('Received: ' + data.byteLength); //console.log('Received: ' + data.byteLength);
if(!rawData || rawData.byteLength == 18) rawData = new Uint8Array(data); if(!rawData || rawData.byteLength == 18) rawData = new Uint8Array(data);

View file

@ -285,7 +285,9 @@
device = dev; device = dev;
device.open(); device.open();
poller = setInterval(function() { poller = setInterval(function() {
rawData = device.read(); device.read(function(data) {
rawData = data;
});
}, 20); }, 20);
}; };