-
• #2
Sounds like you might be trying to do two different things?
For settings, presumably you can load and save the whole file in one go? so:
var mySettings = { "foo" : "bar" }; require('fs').writeFile("settings.js",JSON.stringify(mySettings)); mySettings = JSON.parse(require('fs').readFile("settings.js")); // or to write to the console console.log(require('fs').readFile("settings.js"));
If the file is so big that it won't fit in memory and you need to pipe it, you need to pipe to the actual serial device rather than the function
console.log
:function re() { var f = E.openFile("settings.js","r"); if (f !== undefined) { f.pipe(USB); // or 'Serial1'/etc } else { console.log("What?"); } }
-
• #3
Thanks. I will give that code a go when I get home from work.
What I would like to achieve is to store settings into a config file preferably in json format into a config file of some sort(maybe settings.js?) Which will then get loaded and updated/saved onto a sdcard.
Does anyone have an example that I can work from?
I managed to get this far. However, I am stuck at how to pipe the data to the console screen. If possible, I would like to eventually pipe the file data to a serial port and also pipe data from the serial port to the file located on the sdcard.
At the moment, the console is only receiving: {}. Inside the settings.js file I have:
The console.log should output the contents of settings.js, but instead console.log only outputs { }.