Peculiar CardInfo filename result - ASCII codes instead of text

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Peculiar CardInfo filename result - ASCII codes instead of text

Postby Clapton » Wed Feb 22, 2012 10:52 pm

I recently purchased the Light and Temperature Data Logger shield kit, which comes with the Data Logger Shield Kit v1.0. and a preformatted SD card.

I am having a peculiar problem with some of the SD example code. I am running the Adafruit version of the SD library (adafruit-SD-587d4ec.zip).

I ran the ReadWrite example and successfully created the "test.txt" file on the card. In fact, I ran it several times, and it appends to the existing file without any problem.

When I then query the card with the CardInfo example, the serial monitor reflects the following (note the filename at the bottom):


Initializing SD card ...
... wiring is correct and a card is present.

Card type: SD2

Volume type is FAT16

Volume size (bytes): 1947926528
Volume size (Kbytes): 1902272
Volume size (Mbytes): 1857

Files found on the card (name, date and size in bytes):
84698384.848884 2000-01-01 01:00:00 144


What is strange is that the filename is shown as ASCII numeric codes (84698384.848884) instead of the actual ASCII characters the codes represent (test.txt).

The line of code that generates this last line of data is:

  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);



I have examined the contents of the card on another machine, and the file is indeed named test.txt. Has anyone else observed this? Thank you.
Clapton
 
Posts: 8
Joined: Wed Feb 22, 2012 10:23 pm

Re: Peculiar CardInfo filename result - ASCII codes instead of text

Postby pburgess » Wed Feb 22, 2012 11:35 pm

Looks like a compatibility issue between the library and Arduino 1.0.

Not having the exact hardware setup here at the moment, could you try making a change and report back whether this fixes it? In the SdFat library, the file SdFile.cpp, line 597 currently looks like this:

Code: Select all
    Serial.print(dir.name[i]);


Try changing this to:

Code: Select all
    Serial.write(dir.name[i]);


Rebuild the sketch and see if that prints the filename correctly now. If so, I'll make the correction in the repository. Thanks!
User avatar
pburgess
 
Posts: 1339
Joined: Sun Oct 26, 2008 1:29 am

Re: Peculiar CardInfo filename result - ASCII codes instead of text

Postby Clapton » Thu Feb 23, 2012 12:18 am

That corrected the problem. Thank you.

On another note, I opened the file SdFile.cpp using Notepad (I'm running XP) to make the edit. I do not see lines, rather I see a jumble of non-printable characters interspersed with text. I performed the edit by searching for the statement indicated by you and made the change.

Why does the file not appear as an orderly text file? I mean, finding line 597 was out of the question with my method. Identifying any line by number is impossible.

Thank you again.
Clapton
 
Posts: 8
Joined: Wed Feb 22, 2012 10:23 pm

Re: Peculiar CardInfo filename result - ASCII codes instead of text

Postby pburgess » Thu Feb 23, 2012 1:41 am

Awesome, thanks for your help in tracking that down. I'll go check it in.

As for the jumble of lines...this happens because different systems handle line breaks using a different character, or sequence of chars. NotePad assumes text will be in the DOS/Windows format, so code that originated on another platform (UNIX, Mac, etc.) tends to look jumbled like this. More sophisticated text editors will usually handle either format interchangeably and automatically.
User avatar
pburgess
 
Posts: 1339
Joined: Sun Oct 26, 2008 1:29 am

Re: Peculiar CardInfo filename result - ASCII codes instead of text

Postby Clapton » Thu Feb 23, 2012 1:03 pm

Ah HA! Thank you for that tidbit as well! :D Wordpad does a much nicer job rendering these files. (Alas, still no line numbers though.)

Best regards.
Clapton
 
Posts: 8
Joined: Wed Feb 22, 2012 10:23 pm


Return to Arduino Shields from Adafruit

Who is online

Users browsing this forum: Google [Bot] and 4 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [103]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]