-
-
-
Something appears to up with the pipe not ending as expected.
https://github.com/espruino/Espruino/issues/1116
I would be interesting if someone with an Espruino with an SD card could check this to see if the same issue exists.
-
-
-
-
Hi Gordon,
Linux wasn't in the list of official boards - so I wasn't sure where to post. I'm happy to put it anywhere in the forum you want.I built the image since you did the patch for jumjum, and the error message above still occurs with the code above. I have no idea what is generating the error - it appears to be the return of the function call? I'm happy to look at it if you point me in the right direction.
-
Raised here:
https://github.com/espruino/Espruino/issues/1116#issuecomment-291659546
Following the snippet from here:
http://www.espruino.com/Internet#transferring-files
Testing on linux ( which has a side issue of the path not working due to it not being at the root of an SD card)
echo index file > /tmp/www/index.htm
upload:
function onPageRequest(req, res) { var a = url.parse(req.url, true); var f = E.openFile(a.pathname, "r"); if (f !== undefined) { res.writeHead(200, {'Content-Type': 'text/plain'}); f.pipe(res); // streams the file to the HTTP response debugger; } else { res.writeHead(404, {'Content-Type': 'text/plain'}); res.end("404: Page "+a.pathname+" not found"); } } require("http").createServer(onPageRequest).listen(8080);
And in browser:
http://192.168.69.16:8080/tmp/www/index.htm
at the debug point in the browser, when you hit c to continue we get:
Uncaught Error: Expecting a function to call, got Number
This does not occur for the not found case..
Not sure what is causing this error or if the example needs to be updated?
-
-
/* Proof of concept fs upload file ESP32 / Linux (c) 2017 Wilberforce */ function post_file(req,res){ console.log("post_file",req.url); var f = E.openFile(req.url,"w"); req.pipe(f,{chunkSize:512, end:false, complete:function(){ console.log("Complete"); f.close(); res.end("pipe upload done"); } }); res.end(); } var html_index=` <html> <head> <title>Uploader</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <form action="" method="post"> <input type="file" name="user_file" /> <button type="submit">Submit</button> </form> <script> var ajaxFileUpload = function (filename,data) { var xhr = new XMLHttpRequest(); xhr.open("PUT", "http://192.168.15.18:88/node_modules/"+filename, true); xhr.addEventListener("load", function (e) { // file upload is complete console.log(xhr.responseText); }); //xhr.send(data); xhr.send(data); }; var form = document.querySelector("form"); //debugger; form.addEventListener("submit", function (e) { //debugger; var input = document.querySelector('input[type="file"]'); var fdata = new FormData(); var file; file = input.files[0]; //fdata.append(file.name, file); //var file = $('#load-file')[0].files[0]; //debugger; var fileReader = new FileReader(); fileReader.onloadend = function (e) { var arrayBuffer = e.target.result; var fileType = $('#file-type').val(); //debugger; ajaxFileUpload(file.name,arrayBuffer); }; fileReader.readAsArrayBuffer(file); // Prevents the standard submit event e.preventDefault(); return false; }, false); </script> </html> ` function page_index(req,res) { res.writeHead(200); res.end(html_index); return 200; } var http = require("http"); http.createServer(function (req, res) { console.log({header:req.header}); console.log({method:req.method}); console.log({url:req.url}); code=404; if(req.url=='/' && req.method == 'GET') code=page_index(req,res); if(req.url=='/post' && req.method == 'POST') code=post_file(req,res); if(req.url=='/put' || req.method == 'PUT') code=post_file(req,res); if ( code == 404 ) { res.writeHead(404); res.end('Not Found'); } }).listen(88); // Not found fs=require("fs"); if ( typeof(fs.readdirSync())==="undefined" ) { console.log("Formatting FS"); E.flashFatFS({format:true}); } console.log(fs.readdirSync()); console.log(fs.readdirSync('node_modules'));
-
Thanks Gordon. Decoding the post boundarys is quite difficult so I decided to do it the easy way - put the file content as the body and just stream that up.
So this lets the browser do all the hard work instead... It allows you to select a file and upload it using the PUT method... insteading pasting the file contents. It should allow binary files too.
Next steps are to clean up the look, and allow folder creation and folder selection.....
-
-
@gordon any chance you could post your code - I would like to see where you put the end handler.
-
-
Did you modify the connection set up?
This example works on the esp32, you might have enough space in the esp8266...
It assumes you have a wifi connected, and
wifi.save()
already done so that there is a connnection:https://github.com/espruino/Espruino/blob/master/targets/esp32/tests/https-google-sheets.js
-
@JumJum
The best thing to do is to use the window 10 64 bit bash on windows. I'm using this for development.
Install Bash on Ubuntu on Windows 10 https://msdn.microsoft.com/da-dk/commandline/wsl/install_guidegit clone --recursive git://github.com/espruino/EspruinoBuildTools.git cd EspruinoBuildTools/esp32/build/Espruino source scripts/provision.sh LINUX make clean && make ./espruino
-
-
-
-
Are you sure they're not still running in the background in some form?
No - the serial port gets locked - you can't flash with a current ide connection. And the esptool.py script is closed before attempting to reconnect in the ide.
Can you please explain what this means:
ERROR: RECEIVE ERROR: {"connectionId":2,"error":"overrun"}
-
I've downloaded the firmware above and flashed with that:
process.env ={ "VERSION": "1v91.374", "BUILD_DATE": "Mar 4 2017", "BUILD_TIME": "13:37:12", "GIT_COMMIT": "5e9489ee5936f24d2684588ff42393b76105cb23", "BOARD": "ESP32", "CHIP": "ESP32", "CHIP_FAMILY": "ESP32", "FLASH": 0, "RAM": 524288, "SERIAL": "240ac400-2f90", "CONSOLE": "Serial1", "EXPORTS": { "jsvLock": 1074761212, "jsvLockAgainSafe": 1075125944, "jsvUnLock": 1074763152, "jsvSkipName": 1074778216, "jsvMathsOp": 1074787824, "jsvMathsOpSkipNames": 1074791308, "jsvNewFromFloat": 1074773388, "jsvNewFromInteger": 1074773300, "jsvNewFromString": 1074772312, "jsvNewFromBool": 1074773360, "jsvGetFloat": 1074782172, "jsvGetInteger": 1074776600, "jsvGetBool": 1074782920, "jspeiFindInScopes": 1074800584, "jspReplaceWith": 1074800352, "jspeFunctionCall": 1074809836, "jspGetNamedVariable": 1074802216, "jspGetNamedField": 1074802600, "jspGetVarNamedField": 1074802708, "jsvNewWithFlags": 1074772040 } }
Using:
var p; if ( process.env.CHIP_FAMILY == 'ESP8266' ) p=NodeMCU.D4; else p = D23; var ow = new OneWire(p); ow.reset(); var d=require("DS18B20"); var sensor = d.connect(ow); console.log(sensor.getTemp()); console.log(sensor.getTemp()); console.log(ow.search());
I have two sensors connected and see:
_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v91.374 Copyright 2016 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate >24.9375 24.9375 [ "28cc2e230500006b", "283260dc04000001" ] =undefined >
-
I'm getting this after flashing an ESP32:
>>> Disconnected >>> Connecting... Set Slow Write = true [object Object] Connected [object Object] ERROR: RECEIVE ERROR: {"connectionId":2,"error":"overrun"} Disconnect callback... WARNING: [notify_warn] Disconnected >>> Disconnected ERROR: executeExpression called when not connected! >>> Connecting... Set Slow Write = true [object Object] Connected [object Object] Found a prompt... great! >>> Sending... ---> "\u0010console.log(\"<\",\"<<\",JSON.stringify(process.env),\">>\",\">\")\n" >>> Sent ERROR: RECEIVE ERROR: {"connectionId":3,"error":"overrun"} Disconnect callback... WARNING: [notify_warn] Disconnected >>> Disconnected WARNING: No result found - just got "" Device found (connectionId=3) [success] Connected to port COM3 >>> Connected to port COM3
If from the ide If I attempt disconnect/connect a few times, and then hit reset on the board, it finally connects.
-
There is some code in progress to add UDP, so in the future yes.
https://github.com/espruino/Espruino/issues/1062
By default when the ESP8266 is running STA (station mode), a DNS server is started, so I believe this would also need to be stopped - an option would need to be added
you need to watch for wifi.on("connected") events - and in this function do your MQTT setup.
So if the connection is dropped, or the board restarts, it will then run this code.
There is some discussion on gitter about this - you might ask them to post their code so you can see how they have set it up...
https://gitter.im/espruino/Espruino?at=58ee1f738e4b63533dbfad9e
Something like: