+ Reply to Thread
Results 1 to 6 of 6

Thread: SD Card interface: Can I read names of files already on card?

  1. #1

    Default SD Card interface: Can I read names of files already on card?

    That would be nice. I've got a device hooked to a card that generates files with random names (unpredictable, really, unless I exactly synced an RTC with the internal clock of the other device...filenames include a timestamp down to the second). I need to be able to access these files with the propeller, but as far as I can tell, the SD card object requires a known filename to be specified.
    Is there a way around this?
    Thanks

    Rafael

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You've got to play the game.
    You can't win.
    You can't break even, except on a very cold day.
    It doesn't get that cold.
    ~Laws of Thermodynamics~
    Last edited by ForumTools; 10-02-2010 at 06:01 PM. Reason: Forum Migration

  2. #2

    Default

    Finger,

    I'm not sure why you would want to name files randomly, unless, of course, you have time stamps recorded inside the files along with whatever data you record. You might what to elaborate more on what you're trying to do both on the data recording end of it and on the data accessing end of it.
    Last edited by ForumTools; 10-02-2010 at 06:01 PM. Reason: Forum Migration

  3. #3

    Default

    I can't affect the recording side. The box that generates the data is a cheap video digitizing box that takes an analog video input and turns it into mpeg files on an SD card. These are named according to the date and time the recording was started, or something like that. I have absolutely no control over them. I would like to access the raw video data, which I can do with the SD card object, but only if I know the filename. As far as I can tell there's no such thing as "Open the first file in the directory" or "list filenames".

    Rafael

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You've got to play the game.
    You can't win.
    You can't break even, except on a very cold day.
    It doesn't get that cold.
    ~Laws of Thermodynamics~
    Last edited by ForumTools; 10-02-2010 at 06:01 PM. Reason: Forum Migration

  4. #4

    Default

    1) Remember that the SD card routines use 8.3 (short) filenames. If your device generates long filenames, these will be "mangled" to fit uniquely in an 8.3 format.

    2) There are PUB routines in the SD card object called "opendir" and "nextfile" used to make directory listings. You could use these to either go through all the root files in directory order looking for one that matches some criteria that you specify, then open the file using its name. You'd have to go through the file list each time unless you want to save the names in an array to speed up the process next time.
    Last edited by ForumTools; 10-02-2010 at 06:01 PM. Reason: Forum Migration

  5. #5

    Default

    I believe Raymans Ymodem utility already has directory listing code if you want to keep from
    re-inventing the wheel.

    http://forums.parallax.com/showthread.php?p=719452

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
    Last edited by ForumTools; 10-02-2010 at 06:01 PM. Reason: Forum Migration

  6. #6

    Default

    Femto basic has a "files" command that list all the files. You should be able to get a list of files using the same method.
    here's the relevant code from Femto...

    Code:
     146: ' FILES
                   if \fsrw.mount(spiDO,spiClk,spiDI,spiCS)
                      abort string("Can't mount SD card")
                   fsrw.opendir
                   b := 0
                   d := false
                   repeat while fsrw.nextfile(@f0) == 0
                      d := true
                      if b == 39
                         dsp.out(dsp#Cr)
                         b := 0
                      dsp.str(@f0)
                      repeat 13 - strsize(@f0)
                         dsp.out(" ")
                      b := b + 13
                   if d
                      dsp.out(dsp#Cr)
                   \fsrw.unmount
    Last edited by ForumTools; 10-02-2010 at 06:01 PM. Reason: Forum Migration

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts