You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to beagl...@googlegroups.com
Hello all.
This is probably a dumb question but, is there a way to write to a text file using Bonescript without erasing the current contents of the file? I am using writeTextFile, but the file content gets replaced by the last data sent there.
I am trying to output the readings of a sensor to an ASCII text file every set interval of time. I am very new to BeagleBone, and my application is quite simple, so I am trying to do this the easiest way possible.
Thanks.
Michael M
unread,
Oct 20, 2014, 2:47:38 PM10/20/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to beagl...@googlegroups.com
Not sure if there is a better way, but you could do a readTextFile, store the data in a string, append your data to the string, then writeTextFile the data to a file. This would work well until your text files start getting large, after which things will start getting slow and memory-intensive.
mced...@gmail.com
unread,
Mar 2, 2016, 4:26:19 PM3/2/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to BeagleBoard, ortegaan...@gmail.com
function appendTextFile(filename,text){ var b = require('bonescript'); b.readTextFile(filename, printStatus); function printStatus(x) { if (x.err===null) textout=x.data + text; else textout = text; b.writeTextFile(filename,textout); } }
// and if you want time tags, e.g. for an html log file function appendTagged(filename,text){ appendTextFile(filename,'<br>\n'+Date().substr(4,21) + text) }
Mark A. Yoder
unread,
Mar 3, 2016, 10:15:37 AM3/3/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to BeagleBoard, ortegaan...@gmail.com, mced...@gmail.com
I think nodejs's appendFile[1] will do just what you want.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to BeagleBoard
Hello friend. I think maybe is too late for you, but if someone is alredy looking for information about that, i took the solution.
In the bonescript library i didn't find a function to append in a text file, so i used the function appendFile(), from node.js library. To use this function, we have to write var fs = require('fs');
In my code, i read the value of a pin and i write this value on a text file, append to the other values. This is my code: