-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Was trying to figure out why uploading file to storage takes many minutes and had finally look into source.
espruino --help
, espruino --listconfigs
has no hint there is something like slowWrite
flag
-v
logs a lot of stuff including data that is going to be sent but again nothing that would hint what happens while the data is transferred
Finally I had to find and uncomment this line
Line 386 in 8eb606c
//console.log("Sending block "+JSON.stringify(d)+", wait "+split.delay+"ms"); |
Sending block "\u0010print()\n\u0010require(\"", wait 50ms
Sending block "Storage\").write(\"ba", wait 50ms
--]
Sending block "ck-sb.JPG\",atob(\"/9", wait 50ms
Sending block "j/4AAQSkZJRgABAQEAY", wait 50ms
Sending block "ABgAAD/4RCIRXhpZgAA", wait 50ms
Sending block "TU0AKgAAAAgABAE7AAI", wait 50ms
Sending block "AAAAHAAAISodpAAQAAA", wait 50ms
Sending block "ABAAAIUpydAAEAAAAOA", wait 50ms
Sending block "AAQcuocAAcAAAgMAAAA", wait 50ms
....
Maybe this line could be enabled with "-v"?
Some magic is here
EspruinoTools/plugins/versionChecker.js
Lines 59 to 66 in 8eb606c
if (vCurrent > 1.43 && | |
(env.CONSOLE=="USB"||env.CONSOLE=="Bluetooth"||env.CONSOLE=="Telnet")) { | |
console.log("Firmware >1.43 supports faster writes over USB"); | |
Espruino.Core.Serial.setSlowWrite(false); | |
} else if (vCurrent >= 2.18 && env.BOARD=="ESP32" && env.CONSOLE=="Serial1") { | |
console.log("Firmware >=2.18 on ESP32 supports flow control"); | |
Espruino.Core.Serial.setSlowWrite(true); | |
} |
Line 47 in 8eb606c
var slowWrite = true; |
was silently used with no logging. BTW why the ESP32 message says it uses flow control and then slow writes are set to true, shouldn't it be false because flow control works and can stop the flow?
I was actually using -p tcp://127.0.0.1:2222
so also the driver in
https://github.com/espruino/EspruinoTools/blob/8eb606cff5992a64c3127b8bf32fd0b01ad7873c/core/serial_node_socket.js
has no workaround like e.g. this
EspruinoTools/core/serial_web_bluetooth.js
Line 192 in 8eb606c
Espruino.Core.Serial.setSlowWrite(false, true); // hack - leave throttling up to this implementation |
more places https://github.com/search?q=repo%3Aespruino%2FEspruinoTools%20setSlowWrite&type=code
And looks like the versionChecker.js is parsing console name from process.env
(USB, Telnet, ...) instead of setting it from the real transport that is used. So in my case I was using TCP port but my console was not named "Telnet". I am not sure adding "SWDCON" next to "Telnet" is good workaround.
Another puzzling thing was that I found this code
Lines 354 to 358 in 8eb606c
split = findSplitIdx(split, /\x03/, 250, "Ctrl-C"); // Ctrl-C | |
split = findSplitIdx(split, /reset\(\);\n/, 250, "reset()"); // Reset | |
split = findSplitIdx(split, /load\(\);\n/, 250, "load()"); // Load | |
split = findSplitIdx(split, /Modules.addCached\("[^\n]*"\);\n/, 250, "Modules.addCached"); // Adding a module | |
split = findSplitIdx(split, /\x10require\("Storage"\).write\([^\n]*\);\n/, 500, "Storage.write"); // Write chunk of data |
that contains matches for Storage.write with some 500ms delays but it does not match because default is "--config STORE_LINE_NUMBERS=true" and there is extra stuff after "x10" with line number - like
u0010\u001b[10drequire(\"Storage\").write
. When fixed it does not match anyway (maybe because of Line 338 in 8eb606c
if (!sendingBinary) { |
Some suggestions to improve this:
Can the slowWrite be false by default?
If not can the serial_node_socket set it to false like in other place and Telnet is removed from the check?
Can the slowWrite flag be overriden from command line or --config parameter so it is more visible?