Pages: [1]   Go Down
Author Topic: Trivial fix for SD library CardInfo example  (Read 1011 times)
0 Members and 1 Guest are viewing this topic.
Rhode Island, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
  // 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:
  // 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!
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13705
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Absolutely helpfull, thanks,

Could you state for which version of the SD library this patch is needed?
« Last Edit: April 22, 2011, 02:01:31 am by robtillaart » Logged

Rob Tillaart

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

Rhode Island, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: