Skip to content

Commit a7d40c9

Browse files
committed
Merge branch 'master' of https://github.com/rikkuness/EspruinoTools into packetsend
2 parents 5ed322b + faf5fc9 commit a7d40c9

13 files changed

+82
-90
lines changed

core/flasher.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
console.log("Downloaded "+binary.byteLength+" bytes");
363363
flashBinaryToDevice(binary, flashOffset, callback, statusCallback);
364364
});
365-
};
365+
}
366366

367367

368368
function resetDevice(callback) {
@@ -417,9 +417,7 @@
417417
}, 2000/*timeout*/);
418418
});
419419
});
420-
};
421-
422-
420+
}
423421

424422
Espruino.Core.Flasher = {
425423
init : init,

core/flasherESP8266.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
(function(){
1414

1515
const BLOCK_SIZE = 0x400;
16-
var uart;
16+
// var uart;
1717
var uartLine = "";
1818
var packetHandler;
1919

@@ -166,7 +166,7 @@ function unsetupEspruino(options) {
166166
function cmdSync(options) {
167167
console.log("Syncing...");
168168
return new Promise((resolve,reject)=>{
169-
var success = false;
169+
// var success = false;
170170
var interval;
171171
packetHandler = function(d) {
172172
if (d.cmd==8) {

core/modules.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,20 @@
126126
console.log("loadModule("+fullModuleName+")");
127127

128128
var urls = []; // Array of where to look for this module
129-
var modName; // Simple name of the module
129+
// var modName; // Simple name of the module
130130
if(Espruino.Core.Utils.isURL(fullModuleName)) {
131-
modName = fullModuleName.substr(fullModuleName.lastIndexOf("/") + 1).split(".")[0];
131+
// modName = fullModuleName.substr(fullModuleName.lastIndexOf("/") + 1).split(".")[0];
132132
urls = [ fullModuleName ];
133133
} else {
134-
modName = fullModuleName;
134+
// modName = fullModuleName;
135135
Espruino.Config.MODULE_URL.split("|").forEach(function (url) {
136136
url = url.trim();
137137
if (url.length!=0)
138138
Espruino.Config.MODULE_EXTENSIONS.split("|").forEach(function (extension) {
139139
urls.push(url + "/" + fullModuleName + extension);
140140
})
141141
});
142-
};
142+
}
143143

144144
// Recursively go through all the urls
145145
(function download(urls) {
@@ -234,7 +234,7 @@
234234
callback(loadedModuleData.join("\n") + "\n" + code);
235235
});
236236
}
237-
};
237+
}
238238

239239

240240
Espruino.Core.Modules = {

core/serial.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,6 @@ To add a new serial device, you must add an object to
286286
});
287287
};
288288

289-
var str2ab=function(str) {
290-
var buf=new ArrayBuffer(str.length);
291-
var bufView=new Uint8Array(buf);
292-
for (var i=0; i<str.length; i++) {
293-
var ch = str.charCodeAt(i);
294-
if (ch>=256) {
295-
console.warn("serial> Attempted to send non-8 bit character - code "+ch);
296-
ch = "?".charCodeAt(0);
297-
}
298-
bufView[i] = ch;
299-
}
300-
return buf;
301-
};
302-
303289
var closeSerial=function() {
304290
if (currentDevice) {
305291
currentDevice.close();

core/serial_chrome_serial.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Author: Gordon Williams (gw@pur3.co.uk)
3030
}
3131

3232
var connectionInfo;
33-
var connectedPort; // unused?
33+
// var connectedPort; // unused?
3434
var connectionDisconnectCallback;
3535
var connectionReadCallback;
3636

@@ -65,7 +65,7 @@ Author: Gordon Williams (gw@pur3.co.uk)
6565
openCallback(undefined);
6666
} else {
6767
connectionInfo = cInfo;
68-
connectedPort = serialPort;
68+
// connectedPort = serialPort;
6969
console.log(cInfo);
7070
openCallback(cInfo);
7171
}

core/serial_web_audio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
connectionReadCallback(arr.buffer);
219219
}, 10);
220220
}
221-
};
221+
}
222222

223223
// ----------------------------------------------------------
224224

core/serial_web_serial.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@
109109
flowControl: "none",
110110
rtscts: false });
111111
}).then(function () {
112+
var getReaderSuccess = false;
112113
function readLoop() {
113114
serialPortReader = serialPort.readable.getReader();
114115
serialPortReader.read().then(function ({ value, done }) {
116+
getReaderSuccess = true;
115117
serialPortReader.releaseLock();
116118
serialPortReader = undefined;
117119
if (value) {
@@ -130,8 +132,19 @@
130132
readLoop();
131133
}
132134
}).catch(function(e) {
133-
serialPortReader.releaseLock();
134-
console.log("Serial> serialPortReader rejected", e);
135+
if (getReaderSuccess == false && e == "BreakError: Break received") {
136+
// This fixes a longstanding issue (since 2017) that affected ESP32 devices.
137+
// Espruino Web IDE, sometimes did not connect to an ESP32 device, especially the first time you tried.
138+
// The workaround was to use another tool to connect to the ESP32, like minicom or cutecom
139+
// and once connected using one of these tools, you tried again using Espruino Web IDE.
140+
console.log("Condition break received and ignored");
141+
console.log("Retrying the read loop...");
142+
getReaderSuccess = true;
143+
readLoop();
144+
} else {
145+
serialPortReader.releaseLock();
146+
console.log("Serial> serialPortReader rejected", e);
147+
}
135148
});
136149
}
137150
serialPort.addEventListener("disconnect", (event) => {

core/terminal.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
callback(data);
336336
});
337337

338-
};
338+
}
339339

340340
/* check for any terminal-inline-image and if they are still BMP
341341
then convert them to PNG using canvas */
@@ -430,7 +430,7 @@
430430
if (i in elements)
431431
elements[i].remove();
432432
// now write this to the screen
433-
var t = [];
433+
// var t = [];
434434
for (var y in termText) {
435435
var line = termText[y];
436436
if (y == termCursorY) {
@@ -485,7 +485,7 @@
485485
var x = Math.min(pos.left, terminal.offsetWidth);
486486
var y = Math.min(pos.top-tPos.top, terminal.height-terminalfocus.offsetHeight);
487487
terminalfocus.style.left=x+"px";
488-
terminalfocus.style.top=(pos.top-tPos.top)+"px";
488+
terminalfocus.style.top=y+"px";
489489
}
490490
};
491491

@@ -495,8 +495,6 @@
495495
return str.substr(0,s+1);
496496
}
497497

498-
499-
500498
var handleReceivedCharacter = function (/*char*/ch) {
501499
function isUTF8StartChar(ch) {
502500
return (ch>=0xC2) && (ch<=0xF4);
@@ -612,7 +610,7 @@
612610
var old = onInputData;
613611
onInputData = callback;
614612
return old;
615-
};
613+
}
616614

617615
/// Called when data comes OUT of Espruino INTO the terminal
618616
function outputDataHandler(readData) {
@@ -632,7 +630,7 @@
632630
displayData = [];
633631
displayTimeout = null;
634632
}, 50);
635-
};
633+
}
636634

637635
var receivedData = "";
638636
function searchData(bytes){
@@ -661,36 +659,36 @@
661659
});
662660
// Ensure that data from Espruino goes to this terminal
663661
Espruino.Core.Serial.startListening(Espruino.Core.Terminal.outputDataHandler);
664-
};
662+
}
665663

666664
/// Get the current terminal line that we're on
667665
function getCurrentLine() {
668666
return termText.length-1;
669-
};
667+
}
670668

671669
/// Set extra text to display before a certain terminal line
672670
function setExtraText(line, text) {
673671
if (termExtraText[line] != text) {
674672
termExtraText[line] = text;
675673
updateTerminal();
676674
}
677-
};
675+
}
678676

679677
/// Clear all extra text that is to be displayed
680678
function clearExtraText() {
681679
termExtraText = {};
682680
updateTerminal();
683-
};
681+
}
684682

685683
/// Does the terminal have focus?
686684
function hasFocus() {
687685
return document.querySelector("#terminal").classList.contains("focus");
688-
};
686+
}
689687

690688
/// Give the terminal focus
691689
function focus() {
692690
document.getElementById("terminalfocus").focus();
693-
};
691+
}
694692

695693
// Is the terminal actually visible, or is it so small it can't be seen?
696694
function isVisible() {
@@ -713,15 +711,15 @@
713711
while (line < termText.length && termText[line].substr(0,1)==":")
714712
text += "\n"+termText[line++].substr(1);
715713
return { line : startLine, text : text };
716-
};
714+
}
717715

718716
/** Get the Nth from latest line of text in the terminal (unlike getInputLine) */
719717
function getTerminalLine(n) {
720718
if (n===undefined) n=0;
721719
var line = termText.length-(1+n);
722720
if (line<0) return undefined;
723721
return termText[line];
724-
};
722+
}
725723

726724
/** Add a notification to the terminal (as HTML). If options.buttonclick is set
727725
then the first <button> inside the notification text

0 commit comments

Comments
 (0)