Automatically creating multiple files on Datalogger
banjo
Posts: 447
Hello,
So, having a BS2 and constantly being out of RAM and almost out of EEPROM. For sure there are some cleaning and optimizations/variable re-use that I need to do. As I however anyway have a Memory Stick Datalogger, I got the clever (?) idea to use file/files on a USB-stick as temporary storage instead of variables in RAM, especially for more seldom used variables where the performance hit might not be an issue.
Now to my question:
To start with I would need 10 byte "variables" on the USB-stick, and my thought was to just have 10 text files with the name 1.txt 2.txt ...10.txt. Every text file would contain only one value = the "variable". Later on I'll look into using a binary file where the position of a byte in the file equals to the variable number, i.e. the 5th byte in the file would be "variable" #5, but to get started I wanted to use these easily readable text files.
To avoid using too much EEPROM, I've tried to automatically create the files in this way:
... ["OPW ", STR fileNr\1, ".txt", CR] ... or
... ["OPW ", STR fileNr, CR]
Any clues or ideas are more than welcome.
/Thomas
FYI:
To create/open a single file I'm using this syntax which is working fine: SEROUT TX\CTS, Baud, ["OPW datafile.txt", CR]
So, having a BS2 and constantly being out of RAM and almost out of EEPROM. For sure there are some cleaning and optimizations/variable re-use that I need to do. As I however anyway have a Memory Stick Datalogger, I got the clever (?) idea to use file/files on a USB-stick as temporary storage instead of variables in RAM, especially for more seldom used variables where the performance hit might not be an issue.
Now to my question:
To start with I would need 10 byte "variables" on the USB-stick, and my thought was to just have 10 text files with the name 1.txt 2.txt ...10.txt. Every text file would contain only one value = the "variable". Later on I'll look into using a binary file where the position of a byte in the file equals to the variable number, i.e. the 5th byte in the file would be "variable" #5, but to get started I wanted to use these easily readable text files.
To avoid using too much EEPROM, I've tried to automatically create the files in this way:
FOR fileNr = 1 to 10 SEROUT TX\CTS, Baud, ["OPW ", STR fileNr, ".txt", CR] GOSUB Get_Serial_Bytes NEXTThis is syntaxically correct, but not creating any files, same applies when using
... ["OPW ", STR fileNr\1, ".txt", CR] ... or
... ["OPW ", STR fileNr, CR]
Any clues or ideas are more than welcome.
/Thomas
FYI:
To create/open a single file I'm using this syntax which is working fine: SEROUT TX\CTS, Baud, ["OPW datafile.txt", CR]
Comments
You might be better off with your other scheme. The SEK command can be used to position the pointer at any byte position for read or write commands.
It may be possible to read from a file that is open for write. I may be confusing this with some other device, but if that is the case, you could manage without a lot of file juggling.
Oh, too, the multislot BASIC Stamps have more program space, and also more RAM in the form of scratchpad memory.
BTW, I think I found the answer in this thread:
http://forums.parallax.com/showthread.php?116238-data-logger-creating-multi-files
Basically the syntax should be like this: SEROUT TX\CTS, Baud, [$09, $20, "datafile", DEC number, ".txt", CR]
I've looked at the other Stamps, but when I'm upgrading I'll probably go for Propeller instead. I'll try to first squeeze out what I can from the current components and my limited knowledge of electronics.