-
@Gordon and @Wilberforce thank you for your help.
My plan for large data captures was to implement request/response protocol, but as initially stated, I cannot capture <800 bytes at 9600 baud reliably. My existing infrastructure requires 19200 baud and I would like to go higher. -
@Gordon
Thanks for responding.
I do not know of a way to implement a cts function with RS485, which is a two wire bi-polar uni-directional interface. I can only guess about interrupts, buffer sizes, buffer overwrites,being a problem. But being that with ESP-32 is new to Espruino and not many others are experiencing a similar problem, I will have to wait or find and pay someone knowledgeable about the ESP-32 and Espruino to fix this. -
@Wilberforce
Thanks for your input. While this might solve my short term problem, it will not solve my long term goal. In my production environment I will need to save, serve and update dozens of non static (10-100KB) files on top of several large static files totaling 1.5-3MB for my SPA . The non static files will need to come in serially, being that one of my connections to the environment will be RS485. I mention RS485 because of the limitation of flow control, if I don't have a way of taking data at at least 19200 baud, hopefully higher, I will need to rethink the Espruino implementation idea. -
Thanks to Wilberforce I was able to write a constant string to flash memory. While a constant string is nice, my long term goal is to serve a single page app from flash or a SD card with a file size of 1, 2MB or more. My next baby step was to write a single file of ~800 bytes to flash. Unfortunately after dropping my baud all the way down to 9600 to send a file in binary form to my ESP32, I still lose arbitrary blocks of data. It might be 1 to 20 bytes, but it means I am a long way from sending 200-500 KB file to the my ESP32 flash or SD card. Here's my code(mangled from over a week of hacking) and sample file. The need to write data from a serial link is not only for saving server files, but also for being able to save production data from other devices.
var formatFlashDrive = false; var writeFile = true; Serial2.setup(9600, { tx: D17, rx: D16 }); var fileWriteStarted = false; var fileName = 'index.html'; var fs = require("fs"); var intervalID, existingBlinkRate = 0, timerCount = 0; Serial2.print("Are you there?"); if(formatFlashDrive){ console.log('Formatting FS - only need to do once'); try { console.log("Flash Files: ",fs.readdirSync()); } catch (e) { console.log('Uncaught Error: Unable to mount media : NO_FILESYSTEM'.e); E.flashFatFS({addr : int=0x300000, sectors : int=256, format : bool=false }); } } if(!writeFile){console.log("Ready to write to fs");} if(!writeFile){ console.log("Reading index.html from flash"); try{ console.log(fs.readFileSync("index.html")); // prints "Hello World!!!" Serial2.write(fs.readFileSync("index.html")); }catch(e){ console.log("File Read Error = ",e); Serial2.write('File Read Error'); } //flashLED(10); } Serial2.on('data',function(data){ if(!writeFile)return; if(!fileWriteStarted){ setTimeout(function(){ console.log('Reading ',fileName); Serial2.write(fs.readFileSync("index.html")); },2000); fileWriteStarted = true; console.log('Writing data'); fs.writeFileSync(fileName,data); return; } fs.appendFileSync(fileName, data); console.log('Appending data'); });
-
@Wilberforce, you da man. Thank you for any and all help
-
-
Was trying to exercise a module by using a button press on my Olimex Gateway board. This board has a button, led, sd card, and Ethernet plug, a really nice board by the way. I digress, the button is connected to D34 but when I run the following code, it crashes and resets.
igitalRead(D34); function buttonDown(){ console.log("Hello"); } setWatch(buttonDown,D34,{repeat:true, edge:'rising'});
I have tried running this code with both espruino_1v92_esp32.bin and espruino_1v94.23_esp32.bin firmware and they both crash, although espruino_1v94.23_esp32.bin seems to handle it much better.
I am including the core dump.
All help is appreciated.
-
@Robin, Thank you for the feedback. You did catch a typo. I found and changed it while redoing my post.
@Wilberforce, Thank you for the solution and the explaination. Works like a champ now. I might be back soon when I try to reflash the firmware to implement the SD card. -
Thank you for the response.
Here's the code in it's entirety:print("Before getFree()"); console.log(require( "Flash").getFree()); print("After getFree()"); var fs = require("fs"); if ( typeof(fs.readdirSync()) === 'undefined' ) { console.log('Formatting FS'); E.flashFatFS({ format: true }); } fs.writeFileSync("hello.txt", "Hello World"); console.log(fs.readFileSync("hello.txt")); // prints "Hello World" fs.appendFileSync("hello.txt", "!!!"); console.log(fs.readFileSync("hello.txt")); // prints "Hello World!!!"
I put a couple of print statements in to delineate where the memory table should be printed.
The output from the code above is:
Before getFree()
[
{ "addr": 1114112, "length": 3080191 }
]
After getFree()
Uncaught Error: Unable to mount media : NO_FILESYSTEM
at line 6 col 28
if ( typeof(fs.readdirSync()) === 'undefined' ) { -
My Goal is to be able to use the ESP32 to serve a React.js or Vue.js single page app. Then use WS to communicate to back to the ESP32. The SPA file will eventually be over 2 Megs. But for now I just want to serve a html file out of the flash file system using the FAT protocol.
When trying to use example code from the espruin0.com/ESP32 page, none of the following works as is shown in the example.
console.log(require( "Flash").getFree());
var fs = require("fs");
if ( typeof(fs.readdirSync()) === 'undefined' ) {console.log('Formatting FS'); E.flashFatFS({ format: true });
}
fs.writeFileSync("hello.txt", "Hello World");
console.log(fs.readFileSync("hello.txt")); // prints "Hello World"
fs.appendFileSync("hello.txt", "!!!");
console.log(fs.readFileSync("hello.txt")); // prints "Hello World!!!"The results I get are:
For the "console.log(require( "Flash").getFree());" command:[
{ "addr": 1114112, "length": 3080191 }
]
For the rest of the code:
Uncaught Error: Unable to mount media : NO_FILESYSTEM
at line 6 col 28
if ( typeof(fs.readdirSync()) === 'undefined' ) {I am relatively new so there is a strong chance I am doing something wrong.
@Wilberforce
Have you checked your github account lately.