Most recent activity
-
- 11 comments
- 4,179 views
-
I noticed that trying to connect to ESP_203D1D with my desktop computer makes espruino fail.
Happened as soon as I tried to connect:
abort() was called at PC 0x40084b1f on core 0
or the normal error we see:
E (36210) event: post event to user fail!
E (39052) event: post event to user fail!
E (41894) event: post event to user fail!
E (44737) event: post event to user fail! -
-
Hello everybody,
I am trying to match the second string between quotes and while it works fine on node.js it fails on espruino v1.99.
With the resources available on espruino, how else would you do it?
espruino 1.99: >/\w+\.\w+/g.exec("form-data; name=\"file\"; filename=\"file.txt\"")[0] ="me=\"file.txt" node.js: /\w+\.\w+/g.exec("form-data; name=\"file\"; filename=\"file.txt\"")[0] => 'file.txt'
v2.01 is broken too.
Thank you.
-
Thank you Gordon. I will give it a try.
I saw that the espruino tool is capable of placing a file in the storage area, but it seems that this is only for the original espruinos.
EDIT: It worked perfectly. Had to make 'var boundary = "";' else it would complain about it not having the .length property.
-
@Wilberforce
Were you ever able to to upload files to your espruino with the pipe?I am following your example, but I am not seeing the complete file save in the flash.
File index.htm size is 4752, printed POST data is "cRcv": 4752, but file in flash does not match.
I know that the problem is not in the filesystem, because using "multipart/form-data" on the form post I get the complete file... plus some added strings like this:
------WebKitFormBoundaryZ2Lus84JA68itxnM
Content-Disposition: form-data; name="file"; filename="index.html"
Content-Type: text/html...html file contents...
------WebKitFormBoundaryZ2Lus84JA68itxnM--
httpSRq: { "type": 1, "res": httpSRs: { }, "svr": httpSrv: { "type": 1, "#onconnect": function (b,d) {if(b.headers.Connection&&0<=b.headers.Connection.indexOf("Upgrade")){var f=b.headers["Sec-WebSocket-Key"];f=btoa(E.toString(require("crypto").SHA1(f+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11")));d.writeHead(101,{Upgrade:"websocket",Connection:"Upgrade","Sec-WebSocket-Accept":f,"Sec-WebSocket-Protocol":b.headers["Sec-WebSocket-Protocol"]});var g=new e(void 0,{masking:!1,connected:!0});g.socket=d;b.on("data",g.parseData.bind(g));b.on("close",function(){clearInterval(g.srvPing);g.srvPing=void 0;g.emit("close")}); g.srvPing=setInterval(function(){g.emit("ping",!0);g.send("ping",137)},g.keepAlive);c.emit("websocket",g)}else a(b,d)}, "#onwebsocket": function (ws) {print(ws); ws.on('message', msg => { print("[WS] " + JSON.stringify(msg)); }); ws.on('close', evt => { print("[WS] CLOSED"); });}, "port": 80, "sckt": 4098 }, "sckt": 4099, "headers": { "Host": "192.168.25.8", "Connection": "keep-alive", "Content-Length": "4752", "Origin": "http://192.168.25.8", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.53 Safari/537.36", "DNT": "1", "Accept": "*/*", "Referer": "http://192.168.25.8/upload", "Accept-Encoding": "gzip, deflate", "Accept-Language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,it;q=0.6,ja;q=0.5,es;q=0.4" }, "cRcv": 4752, "method": "PUT", "url": "/upload", "hdrs": true, "dRcv": "" }
>fs.statSync("upload") ={ "size": 3216, "dir": false, "mtime": Date: Mon Feb 1 2077 00:00:00 GMT+0000 }
if (a.pathname == "/upload") { print(req); if (req.method == "PUT") { try { fs.unlink(a.pathname); } catch (e) { } var f = E.openFile(a.pathname, "w"); req.pipe(f, { chunkSize: 512, end: false, complete: () => { f.close(); res.end(); } }); } else { res.writeHead(200, {'Content-Type':'text/html'}); res.end(html_index); } }
Add a RC filter to those buttons. It will help reducing interrupts.