Shop OBEX P1 Docs P2 Docs Learn Events
Automatically creating multiple files on Datalogger — Parallax Forums

Automatically creating multiple files on Datalogger

banjobanjo Posts: 443
edited 2012-11-13 11:25 in BASIC Stamp
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:
  FOR fileNr = 1 to 10
     SEROUT TX\CTS, Baud, ["OPW ", STR fileNr, ".txt", CR]
     GOSUB Get_Serial_Bytes
  NEXT
This 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

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-11-13 00:41
    Only one file is allowed to be open at a time on the datalogger. It is probably kicking back an error code of "file already open".

    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.
  • banjobanjo Posts: 443
    edited 2012-11-13 03:02
    OK, I'll look into this with multiple files open at same time when I'm at home again.
    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-13 07:40
    As you will notice from the last posting in the thread you mentioned, the file name must be no more than 8 characters. Use something like "FILE", DEC number, ".TXT"
  • banjobanjo Posts: 443
    edited 2012-11-13 11:25
    Thanks for the quick and helpful support, now I got it to work by using DEC fileNr instead of STR fileNr. Case closed
Sign In or Register to comment.