Peculiar CardInfo filename result - ASCII codes instead of text

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

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Clapton
 
Posts: 8
Joined: Wed Feb 22, 2012 11:23 pm

Peculiar CardInfo filename result - ASCII codes instead of text

Post by Clapton »

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.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

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

Post by pburgess »

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!

Clapton
 
Posts: 8
Joined: Wed Feb 22, 2012 11:23 pm

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

Post by Clapton »

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.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

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

Post by pburgess »

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.

Clapton
 
Posts: 8
Joined: Wed Feb 22, 2012 11:23 pm

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

Post by Clapton »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”