The error is in the ESP8266 library, but that's probably not at fault - there's just so little memory available that it can't allocate memory when it needs it, and it crashes.
If you want to write to a file, I'd write it a bit at a time - each time you get new data, add it to the end. You might be able to use pipe...
There's an example of transmitting a file on the Internet page:
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
} else {
res.writeHead(404, {'Content-Type': 'text/plain'});
res.end("404: Page "+a.pathname+" not found");
}
}
require("http").createServer(onPageRequest).listen(8080);
You might just be able to reverse that to:
function onPageRequest(req, res) {
var a = url.parse(req.url, true);
// ...
var f = E.openFile(a.pathname, "w");
req.pipe(f); // it should auto-close
}
require("http").createServer(onPageRequest).listen(8080);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Can you post up your code?
The error is in the ESP8266 library, but that's probably not at fault - there's just so little memory available that it can't allocate memory when it needs it, and it crashes.
If you want to write to a file, I'd write it a bit at a time - each time you get new data, add it to the end. You might be able to use pipe...
There's an example of transmitting a file on the Internet page:
You might just be able to reverse that to:
but I haven't tried it...