fs.writeFileSync() not working with serial link #7049
Replies: 1 comment
-
Posted at 2017-10-03 by Wilberforce Rather than using serial, you can use http to update the flash. You can do an http request and then write the output to fs, you could host the file on your local computer, it out the file in github or gist. Posted at 2017-10-04 by miCatotonic @wilberforce Posted at 2017-10-04 by @gfwilliams When you do Otherwise, it might make sense to set up some kind of serial protocol with a command and acknowledgement? Posted at 2017-10-04 by miCatotonic @gfwilliams Posted at 2017-10-05 by @gfwilliams Ahh - with RS485 you'd have trouble with CTS flow control. I'd suggest implementing a command & response sort of thing then... What you're doing won't work that well on any Espruino device: you get data from the serial port a few bytes at a time, and each time you're opening and closing a file... it's just taking too much time. If you don't want to do some command/response thing you could use Posted at 2017-10-05 by Wilberforce It's the esp32 port so the blocksize is 4096. Posted at 2017-10-05 by miCatotonic @gfwilliams and @wilberforce thank you for your help. Posted at 2017-10-05 by miCatotonic @wilberforce |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-10-02 by miCatotonic
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.
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions