scratch-arduino-extension
scratch-arduino-extension copied to clipboard
Race condition
Chrome 45 windows 8.1 probably affects others using a HC-06 bluetoooth to serial adapter
With my setup line: 507 "set_receive_handler" callback would be processed before line: 506
"device.open" would finish, so the device was not set when it was called and it would return without
setting the receive handler.
So I tried moving the "set_receive_handler" call to the ready callback for "device.open".
I was able to connect and set the LED pins. Although the readback was a little spotty.
I think the polling function might need some fine turning for the high latency.
console.log('Attempting connection with ' + device.id);
device.open({ stopBits: 0, bitRate: 57600, ctsFlowControl: 0 }, function() {
device.set_receive_handler(function(data) {
var inputData = new Uint8Array(data);
processInput(inputData);
});
});
Ah yes, I see this too. I started writing a bit of a Firmata port for Microbit and hit the same issue.