Skip to content

Commit 08c10ce

Browse files
committed
Removed all postResetDelay adjustment and retry code, regardless of platform, and applied active wait technique for postResetDelay to attempt to fix CrOS 67+ download failures. Bumped version to 0.9.6.
1 parent 98b8c19 commit 08c10ce

File tree

4 files changed

+18
-53
lines changed

4 files changed

+18
-53
lines changed

index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
<td>Verbose Logging:</td>
4747
<td colspan="2"><input type="checkbox" id="bpc-trace"/></td>
4848
</tr>
49-
<tr>
50-
<td>Experimental Timing:</td>
51-
<td colspan="2"><input type="checkbox" id="exp-timing"/></td>
52-
</tr>
5349
<tr>
5450
<td colspan="3"><div id="log" class="con"></div></td>
5551
</tr>

index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ var portLister = [];
104104
// Is verbose loggin turned on?
105105
var verboseLogging = false;
106106

107-
// Is experimental timing turned on?
108-
var experimentalTiming = false;
109-
110107
document.addEventListener('DOMContentLoaded', function() {
111108

112109
$('version-text').innerHTML = 'v'+clientVersion;
@@ -185,10 +182,6 @@ document.addEventListener('DOMContentLoaded', function() {
185182
verboseLogging = $('bpc-trace').checked;
186183
};
187184

188-
$('exp-timing').onclick = function() {
189-
experimentalTiming = $('exp-timing').checked;
190-
};
191-
192185
$('wx-allow').onclick = function() {
193186
var wx_enabled = $('wx-allow').checked;
194187
if(wx_enabled) {

loader.js

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART. */
1717

1818
// Programming metrics
19-
let postResetDelay = null; //Delay after reset and before serial stream; Post-Reset Delay is set by loadPropeller()
20-
let autoAdjust = 30; //Amount to adjust postResetDelay upon each failure
2119
let txData; //Data to transmit to the Propeller (size/contents created later)
2220

2321
const defaultClockSpeed = 80000000;
2422
const defaultClockMode = 0x6F;
2523
const maxDataSize = 1392; //Max data packet size (for packets sent to running Micro Boot Loader)
2624
const mblRespSize = 8; //Size of Micro Boot Loader Response (and Expected) array buffers
25+
const postResetDelay = 100; //Delay after reset and before serial stream
2726

2827
// propComm stage values
2928
const sgIdle = -1;
@@ -137,8 +136,6 @@ function loadPropeller(sock, portPath, action, payload, debug) {
137136
let originalBaudrate;
138137

139138
if (port.isWired) {
140-
//Set postResetDelay based on platform; ideal Post-Reset Delay = 100 ms; adjust downward according to typically-busy operating systems
141-
postResetDelay = ((platform === pfWin) && (!experimentalTiming)) ? 60 : 100;
142139
if (port.connId) {
143140
// Connection exists, prep to reuse it
144141
originalBaudrate = port.baud;
@@ -150,8 +147,6 @@ function loadPropeller(sock, portPath, action, payload, debug) {
150147
connect = function() {return openPort(sock, portPath, initialBaudrate, "programming")}
151148
}
152149
} else {
153-
//Nearly-clear the postResetDelay (it's controlled by wireless device)
154-
postResetDelay = 1;
155150
//TODO Retrieve actual current baudrate
156151
originalBaudrate = initialBaudrate;
157152
updatePort(port, {mode: "programming", bSocket: sock});
@@ -287,27 +282,22 @@ function talkToProp(sock, port, binImage, toEEPROM) {
287282

288283
function sendMBL() {
289284
return new Promise(function(resolve, reject) {
290-
291-
function txmit() {
292-
//Prep for expected packetID:transmissionId response (Micro-Boot-Loader's "Ready" signal)
293-
propComm.mblEPacketId[0] = packetId;
294-
propComm.mblETransId[0] = 0; //MBL transmission's Id is always 0
295-
//Send Micro Boot Loader package and get response; if wired port, unpause (may be auto-paused by incoming data error); wireless ports, carry on immediately
296-
log("Transmitting Micro Boot Loader package", mDeep);
297-
send(port, txData, true)
298-
.then(function() {if (port.isWired) {return unPause(port)}}) //Unpause port (if wired)
299-
.then(function() {return propComm.response}) //Wait for response (may timeout with rejection)
300-
.then(function() {log(notice(000, ["Found Propeller"]), mUser+mDbug, sock)}) //Succeeded!
301-
.then(function() {return resolve()})
302-
.catch(function(e) {return reject(e)}); //Failed!
303-
}
304-
305-
if (!experimentalTiming) {
306-
setTimeout(txmit, postResetDelay);
307-
} else {
285+
//If wired, actively wait before transmitting Micro Boot Loader; active (vs. passive) wait prevents extended delays in CrOS v67+
286+
if (port.isWired) {
287+
log("Waiting " + Math.trunc(postResetDelay) + " ms", mDeep);
308288
wait(postResetDelay);
309-
txmit();
310289
}
290+
//Prep for expected packetID:transmissionId response (Micro-Boot-Loader's "Ready" signal)
291+
propComm.mblEPacketId[0] = packetId;
292+
propComm.mblETransId[0] = 0; //MBL transmission's Id is always 0
293+
//Send Micro Boot Loader package and get response; if wired port, unpause (may be auto-paused by incoming data error); wireless ports, carry on immediately
294+
log("Transmitting Micro Boot Loader package", mDeep);
295+
send(port, txData, true)
296+
.then(function() {if (port.isWired) {return unPause(port)}}) //Unpause port (if wired)
297+
.then(function() {return propComm.response}) //Wait for response (may timeout with rejection)
298+
.then(function() {log(notice(000, ["Found Propeller"]), mUser+mDbug, sock)}) //Succeeded!
299+
.then(function() {return resolve()})
300+
.catch(function(e) {return reject(e)}); //Failed!
311301
});
312302
}
313303

@@ -317,20 +307,9 @@ function talkToProp(sock, port, binImage, toEEPROM) {
317307
.then(function() {if (port.isWired) {return setControl(port, {dtr: false});}}) // Start Propeller Reset Signal
318308
.then(function() {if (port.isWired) {return flush(port);}}) // Flush transmit/receive buffers (during Propeller reset)
319309
.then(function() {if (port.isWired) {return setControl(port, {dtr: true});}}) // End Propeller Reset
320-
.then(function() {if (port.isWired) {log("Waiting " + Math.trunc(postResetDelay) + " ms", mDeep);}}) // Wait post-reset-delay and...
321310
.then(function() { return sendMBL();}) //send comm package, including Micro Boot Loader; verify receipt
322-
.catch(function(e) { //Error!
323-
if (noticeCode(e.message) === nePropellerNotFound && --attempts) { // Retry (if "Propeller not found" and more attempts available)
324-
log("Propeller not found: retrying...", mDeep);
325-
if (platform === pfWin) { // If Windows platform,
326-
postResetDelay = Math.max(postResetDelay - autoAdjust, 1); // Shorten Post Reset Delay upon every attempt (min 1)
327-
}
328-
return sendLoader(); // note: sendLoader does not return execution below (promises continue at next .then/.catch)
329-
}
330-
return reject(e); // Or if other error (or out of retry attempts), reject with message
331-
})
332-
.then(function() {return resolve();}) //Propeller found? Resolve
333-
.catch(function(e) {return reject(e);}) //Error! Reject with message
311+
.then(function() { return resolve();}) //Propeller found? Resolve
312+
.catch(function(e) { return reject(e);}) //Error! Reject with message
334313
});
335314
}
336315

@@ -456,9 +435,6 @@ function talkToProp(sock, port, binImage, toEEPROM) {
456435
//=((10 [bits per byte] * [max packet size]) / final baud rate) * 1,000 [to scale ms to integer] + 1 [to always round up] + 1500 or 250 [Network or Rx hardware to OS slack time]
457436
var userDeliveryTime = Math.trunc(((10*maxDataSize)/finalBaudrate)*1000+1 + ((port.isWired) ? 250 : 1500));
458437

459-
//Set for limited retry attempts (multiple when wired; potentially trying various post-reset timing)
460-
var attempts = (port.isWired) ? ((platform === pfWin) ? Math.max(Math.trunc(postResetDelay / autoAdjust), 1) : 1) : 1;
461-
462438
Promise.resolve()
463439
.then(function() {return sendLoader();}) //Get Propeller's attention and send initial application (Micro Boot Loader)
464440
.then(function() {return changeBaudrate(port, finalBaudrate);}) //Bump up to faster finalBaudrate

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "BlocklyProp Launcher",
33
"description": "A Chrome application that connects your Propeller-Powered Hardware to the BlocklyProp website.",
4-
"version": "0.9.5",
4+
"version": "0.9.6",
55
"manifest_version": 2,
66
"minimum_chrome_version": "45",
77

0 commit comments

Comments
 (0)