Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<td>Verbose Logging:</td>
<td colspan="2"><input type="checkbox" id="bpc-trace"/></td>
</tr>
<tr>
<td>Experimental Timing:</td>
<td colspan="2"><input type="checkbox" id="exp-timing"/></td>
</tr>
<tr>
<td colspan="3"><div id="log" class="con"></div></td>
</tr>
Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ var portLister = [];
// Is verbose loggin turned on?
var verboseLogging = false;

// Is experimental timing turned on?
var experimentalTiming = false;

document.addEventListener('DOMContentLoaded', function() {

Expand Down Expand Up @@ -182,7 +184,11 @@ document.addEventListener('DOMContentLoaded', function() {
$('bpc-trace').onclick = function() {
verboseLogging = $('bpc-trace').checked;
};


$('exp-timing').onclick = function() {
experimentalTiming = $('exp-timing').checked;
};

$('wx-allow').onclick = function() {
var wx_enabled = $('wx-allow').checked;
if(wx_enabled) {
Expand Down
36 changes: 24 additions & 12 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,12 @@ function loadPropeller(sock, portPath, action, payload, debug) {

if (port.isWired) {
//Set postResetDelay based on platform; ideal Post-Reset Delay = 100 ms; adjust downward according to typically-busy operating systems
postResetDelay = (platform === pfWin) ? 60 : 100;
postResetDelay = ((platform === pfWin) && (!experimentalTiming)) ? 60 : 100;
if (port.connId) {
// Connection exists, prep to close it first (to reset it), then open it (fresh)
originalBaudrate = initialBaudrate;
connect = function() {return closePort(port).then(function() {return openPort(sock, portPath, initialBaudrate, "programming")}).catch(function(e) {return Promise.reject(e)})}
// The following temporarily removed (and replaced above) to intentionally close and reopen port in hopes it eliminates the CrOS v67+ failed download problem
// // Connection exists, prep to reuse it
// originalBaudrate = port.baud;
// updatePort(port, {mode: "programming", bSocket: sock});
// connect = function() {return changeBaudrate(port, initialBaudrate)}
// Connection exists, prep to reuse it
originalBaudrate = port.baud;
updatePort(port, {mode: "programming", bSocket: sock});
connect = function() {return changeBaudrate(port, initialBaudrate)}
} else {
// No connection yet, prep to create one
originalBaudrate = initialBaudrate;
Expand Down Expand Up @@ -261,6 +257,14 @@ function clearPropCommTimer() {
}
}

function wait(ms) {
/* Actively delay for ms milliseconds.
This should only be used for time-critical delays as it doesn't release to the task queue but instead consumes CPU time until finished.
*/
let Done = Date.now() + ms;
while (Date.now() < Done){}
}

function talkToProp(sock, port, binImage, toEEPROM) {
/* Return promise to deliver Propeller Application (binImage) to Propeller
sock is the websocket to direct mUser messages at
Expand All @@ -283,7 +287,8 @@ function talkToProp(sock, port, binImage, toEEPROM) {

function sendMBL() {
return new Promise(function(resolve, reject) {
setTimeout(function() {

function txmit() {
//Prep for expected packetID:transmissionId response (Micro-Boot-Loader's "Ready" signal)
propComm.mblEPacketId[0] = packetId;
propComm.mblETransId[0] = 0; //MBL transmission's Id is always 0
Expand All @@ -295,9 +300,16 @@ function talkToProp(sock, port, binImage, toEEPROM) {
.then(function() {log(notice(000, ["Found Propeller"]), mUser+mDbug, sock)}) //Succeeded!
.then(function() {return resolve()})
.catch(function(e) {return reject(e)}); //Failed!
}, postResetDelay);
}

if (!experimentalTiming) {
setTimeout(txmit, postResetDelay);
} else {
wait(postResetDelay);
txmit();
}
});
};
}

Promise.resolve()
.then(function() { resetPropComm(port, mblDeliveryTime, null, null, true);}) //Reset propComm object
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "BlocklyProp Launcher",
"description": "A Chrome application that connects your Propeller-Powered Hardware to the BlocklyProp website.",
"version": "0.9.4",
"version": "0.9.5",
"manifest_version": 2,
"minimum_chrome_version": "45",

Expand Down
2 changes: 1 addition & 1 deletion serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function closePort(port, command) {
log("Closed port " + port.path + " (id " + port.connId + ")", mDbug);
// Clear connection id to indicate port is closed
updatePort(port, {connId: null});
setTimeout(resolve, 250); //Delay resolve() to prevent future openPort() calls from arriving too soon to accommodate
resolve();
} else {
log("Could not close port " + port.path + " (id " + port.connId + ")", mDbug);
reject(Error(notice(neCanNotClosePort, [port.path])));
Expand Down