Shop OBEX P1 Docs P2 Docs Learn Events
Memory Stick Data Logger variable file names — Parallax Forums

Memory Stick Data Logger variable file names

dexfdexf Posts: 7
edited 2009-03-31 20:28 in BASIC Stamp
All:

I've been using the Memory Stick Data Logger, 27937, quite successfully for some time.
And now, I would like to extend the logging process by saving the results to progressively
different file names (every 24 hours for example). ie: data1.txt, data2.txt and so on.

I use the line(s) like:

SEROUT TX\CTS, Baud, [noparse][[/noparse]$07, $20, "data.txt", CR]

to write the data and control the stick logger.·

What I would like to do is have control of the file name used without having to just repeat
code with differrent file names for the multiple slots in a BS2e. I guess I'm looking for a
more elegant solution. I'd like to build and use a string as a variable for the file name.
So far, I've had no success and wonder if this is even possible with the BS2(e).

If it can help anyone, I'm attaching the entire working BS2 file that I use.

Any help and thoughts would be appreciated.

Dex

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-31 17:07
    There really are not strings in Stamp Basic in the sense you're using. It's very easy to use numeric file names though. If you have a file number in FN, you could write:

    SEROUT TX\CTS, Baud, [noparse][[/noparse]$07, $20, "F",DEC3 FN, ".txt", CR

    This uses file names of the form F000.txt through F999.txt.
  • dexfdexf Posts: 7
    edited 2009-03-31 17:10
    Mike,

    Perfect.· I just knew there had to be a way.

    Many thanks,

    Dex
    ·
  • dexfdexf Posts: 7
    edited 2009-03-31 19:59
    Mike,

    Your solution to generate multiple stick files looked good but for some reason, the file name saved to the stick stays the same as "Current0.txt" instead of the expected "Current00.txt". Debug shows it being generated correctly with the same type syntax, but it isn't being passed to the stick through the 27937 module. I've put extra delays in and completely reinitialized the 27937 (see the attached code) for each new file but the lines like:

    SEROUT TX\CTS, Baud, [noparse][[/noparse]$07, $20, "Current", DEC2 FN, ".txt", CR]

    just aren't working correctly. The same file current0.txt just keeps being overwritten on the memory stick. I don't get both digits.

    FN is defined as a nibble. 16 days was plenty and I've run out of RAM space anyway.

    The revised code including your suggestion of the above type line(s)·is attached.

    I've shortened all timing loops for debugging ease.

    I know I must be missing something.

    All suggestions appreciated.

    Dex
  • SRLMSRLM Posts: 5,045
    edited 2009-03-31 20:05
    When you communicate with the datalogger, don't you have to specify how many bytes are going to be sent? I seem to remember that was an issue for me...

    Also, what happens when you set FN equal to something like 10 or 14?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-31 20:19
    You may be having your filename truncated to 8 characters. I'm not sure if the datalogger supports long file names. Keep the file name to 8 characters or less. Use "File" instead of "Current" and you'll get "File00" through "File15".
  • dexfdexf Posts: 7
    edited 2009-03-31 20:28
    SRLM,
    I'm looking at Table 4.1 of the Vinculum VNC1L chip spec and the open, close, delete file op commands don't seem to have that restriction. Other data like the csv that I build, yes.

    Mike,
    You caught the problem. I've shortenned the file name to currXX.txt and then files are written correctly.
    Back to the old DOS days.

    And another "closely guarded secret" ( file name length ) exposed. I love it.

    Many thanks gentlemen.

    Dex
Sign In or Register to comment.