Go Down

Topic: Trivial fix for SD library CardInfo example (Read 1 time) previous topic - next topic

davidhbrown

I was getting negative numbers for the Volume size when running the new CardInfo example. Seems to work better with an unsigned long instead of a signed long around line 85.

was:
Code: [Select]
  // print the type and size of the first FAT-type volume
  long volumesize;

Output:
Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC

Volume type is FAT16

Volume size (bytes): -334233600
Volume size (Kbytes): -326400
Volume size (Mbytes): -318

Files found on the card (name, date and size in bytes):
TEST.TXT      2000-01-01 01:00:00 847

Patched:
Code: [Select]
  // print the type and size of the first FAT-type volume
  unsigned long volumesize;
Better output:
Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC

Volume type is FAT16

Volume size (bytes): 3960733696
Volume size (Kbytes): 3867904
Volume size (Mbytes): 3777

Files found on the card (name, date and size in bytes):
TEST.TXT      2000-01-01 01:00:00 847


Hope this is helpful. I understand there may be other issues with using this size card, but it's what I had on hand. Really appreciate the example of reading the directory. I needed that!

robtillaart

#1
Apr 22, 2011, 08:58 am Last Edit: Apr 22, 2011, 09:01 am by robtillaart Reason: 1
Absolutely helpfull, thanks,

Could you state for which version of the SD library this patch is needed?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

davidhbrown

Sorry to be unclear. I meant the example code, not the library itself. Looking at the new CardInfo example I found at http://arduino.cc/en/Tutorial/CardInfo (linked from http://arduino.cc/en/Reference/SD ). This seems newer than the latest 0022 version of I have downloaded/installed... at least, it doesn't show up in the File>Examples>SD submenu.

It's line number is 83 when I copy/paste all http://arduino.cc/en/Tutorial/CardInfo?action=sourceblock&num=1 into an editor that shows me line numbers.

Go Up