Shop OBEX P1 Docs P2 Docs Learn Events
why i can create files on sd card only 32 files maximum? — Parallax Forums

why i can create files on sd card only 32 files maximum?

kamengrinder666kamengrinder666 Posts: 8
edited 2011-07-10 19:45 in Propeller 1
CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

obj

text : "vga_text"
fs: "fsrw2.6"

var
byte filename[13]

pub start
text.start (16)
fs.mount (0)
bytemove(@filename,string("REC_0000.CSV"),13)

repeat
increment (@filename , 13)
fs.popen (@filename , "w")
fs.pclose
text.str (@filename)
text.str (string(13))
waitcnt (30_000_000 + cnt)

pub increment(address,length)
' address is the starting address of the byte array for the string
' length is the total length of the byte array including the zero byte that marks the end of the string
address += length - 6 ' Change the address so it points to the rightmost digit of the numeric value.
repeat
result := byte[address] ' Use the implicit result variable for a temporary variable
if result => "0" and result =< "9" ' Check to make sure there's a digit character there
byte[address] := ++result ' Increment the character
if result > "9"
byte[address--] := "0" ' If greater than "9", set to zero and carry a one
next ' Repeat the loop
quit


pub increment is the function that increase number of filename that i found on this forum (thank you very much)

i want to test how many files that i can create on sd card with my code

and the result is 32 files

i don't understand why i can create only 32 files .

and how to create more than 32 files ?

i'd be grateful to anyone who could make this clear to me

thank you very much in advance

sorry for my english

my sd card is fat32 format

Comments

  • kamengrinder666kamengrinder666 Posts: 8
    edited 2011-07-08 21:44
    answer this for me if you could , please.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-07-08 22:35
    attachment.php?attachmentid=78421&d=1297987572
  • AribaAriba Posts: 2,690
    edited 2011-07-08 23:17
    What happens after 32 files?
    Your increment methode looks wrong, but it's difficult to say without indentions. "next" is not necessary to repeat a loop.
    You need to capture the aborts from the fsrw methodes, this is done with a backslash before the methode call. And you should also test the return value. Most fsrw methodes return zero if succesful, or a negative error number otherwise.

    Try it with this code: (I've only tested the increment methode)
    _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    obj
    
    text : "vga_text"
    fs: "fsrw2.6"
    
    var
      byte filename[13]
    
    pub start 
      text.start(16)
      \fs.mount (0)
      bytemove(@filename,string("REC_0000.CSV"),13)
    
      repeat
        increment (@filename , 7)
        \fs.popen (@filename , "w")
        \fs.pclose
        text.str (@filename)
        text.out(13)
        waitcnt (30_000_000 + cnt)
    
    pub increment(address,pos)
    ' address is the starting address of the byte array for the string
    ' pos is the position in the byte array of to the rightmost digit of the numeric value
      address += pos  ' Change the address so it points to the rightmost digit of the numeric value.
      repeat
        result := byte[address] ' Use the implicit result variable for a temporary variable
        if result => "0" and result =< "9" ' Check to make sure there's a digit character there
          byte[address] := ++result ' Increment the character
          if result > "9"
            byte[address--] := "0" ' If greater than "9", set to zero and carry a one
          else
            quit
    

    Andy
  • kamengrinder666kamengrinder666 Posts: 8
    edited 2011-07-09 08:31
    thank for response

    ElectricAye
    - thank you . i will post my code on your way on next time.

    Ariba
    - thank you for editing my code but i think my pub increment is work for sure
    i have already tested by running number from 1 to 9999 and it's work

    about my code, my vga screen stop display filenames at REC_0032.CSV
    and i get 32 files on my sd card

    i have tested your code now . filenames are displayed continuously even i unmount my sd card
    i unmount my sd card when REC_0048.CSV displayed
    i wish i get 48 files on my sd card but it's only 32 files too

    is format of sd card involve?

    ==sorry for my english==
  • AribaAriba Posts: 2,690
    edited 2011-07-09 10:10
    This main loop should give you some infos about Errors from FSRW:
    pub start | err 
      text.start(16)
      err := \fs.mount(0)
      if err
        text.str(string(13,"Mount error: "))
        text.dec(err)
      bytemove(@filename,string("REC_0000.CSV"),13)
    
      repeat
        increment(@filename ,13)
        err := \fs.popen(@filename , "w")
        if err
           text.str(string(13,"Open error: "))
           text.dec(err)
        err := \fs.pclose
        if err
           text.str(string(13,"Close error: "))
           text.dec(err)
        text.out(13)
        text.str(@filename)
        waitcnt (30_000_000 + cnt)
    

    Andy
  • kamengrinder666kamengrinder666 Posts: 8
    edited 2011-07-09 10:57
    thank a lot for your code !!

    my vga screen show this :

    REC_0001.CSV
    REC_0002.CSV

    .
    .

    REC_0032.CSV
    open error: -2
    REC_0033.CSV
    open error: -2
    REC_0034.CSV
    open error: -2

    .
    .

    what open error: -2 mean??
  • AribaAriba Posts: 2,690
    edited 2011-07-09 11:41
    You need to search the error numbers in the FSRW source(s).
    direntry := freeentry
    if (direntry == 0)
    abort(-2) ' no empty directory entry
    I don't know why this error happens, but perhaps it helps if you write somthing into the file after open:
    ...
        err := \fs.popen(@filename , "w")
        if err
           text.str(string(13,"Open error: "))
           text.dec(err)
        else
          \fs.pputs(@filename)
        ...
    
  • kwinnkwinn Posts: 8,697
    edited 2011-07-09 13:39
    "abort(-2) ' no empty directory entry" - Could it be that there are a lot of files already on the SD card ? Have you tried doing a quick format on the SD card ?
  • Mark_TMark_T Posts: 1,981
    edited 2011-07-09 14:35
    I believe the problem is that the maximum number of root directory entries is set to 32 in the filesystem itself. You'll find exactly the same problem with anything using the card till you reformat it. From what I understand FAT32 top level directory is one cluster in size, so if the cluster size is small the number of entries is limited. 32 would mean a cluster size of 2 sectors (1k, which is 32 directory entries). All other directories are like files and can be any size I believe, so a simple fix is create files lower down in the hierarchy
  • kamengrinder666kamengrinder666 Posts: 8
    edited 2011-07-09 23:27
    oh, thank you so much for replying

    ariba : thank a lot for help . i will try it.

    kwinn : i have tried to format already but it's also created only 32 files too.

    mark_t : i understand what you said now . is fsrw have any methods to create files on other directories ?
  • KyeKye Posts: 2,200
    edited 2011-07-10 08:36
    http://www.parallaxsemiconductor.com/an006

    Has code in there to fix your problem. Read the APP note first.
  • kamengrinder666kamengrinder666 Posts: 8
    edited 2011-07-10 19:45
    thank you very much Nyamekye !!!

    i'll try to edit my code and tell you the results.

    thanks
Sign In or Register to comment.