Go Down

Topic: Problem reading written Data (Read 681 times) previous topic - next topic

Chaos_Lord

Jun 11, 2012, 12:45 pm Last Edit: Jun 11, 2012, 01:52 pm by Chaos_Lord Reason: 1
Hallo everyone,

i just got my Ethernetshield and i`m trying to store some Data in an MicroSD card and read it back.

My Writing function is:
Code: [Select]

createFile("VERSION.NUM", "Versionsnummer")

void createFile(char* dateiname , String dateiinhalt) {
 int bytewritten = 0;
 // Erstellt eine Datei mit dem ├╝bergebenem Inhalt
  myFile = SD.open(dateiname , FILE_WRITE);
  bytewritten = myFile.print(dateiinhalt);
  myFile.close();
}


The file is created on the card. now i try to read the just written data back

Code: [Select]

readfromFile("VERSION.NUM");

void readfromFile(char* dateiname) {
 String incommingData = "";
 myFile = SD.open(dateiname , FILE_READ);
 while (myFile.available()) {
     Serial.println(myFile.read());
 }
 myFile.close();
}


In the Serial Monotor i get: 86
101
114
115
105
111
110
115
110
117
109
109
101
114

I guess these are the bytes wich were read, but how do i get a "humanreadable" String of this to use the stored data in the programm?

CL

SurferTim

Try this instead:
Code: [Select]
  while (myFile.available()) {
      Serial.write(myFile.read());
  }


Serial.println() converts the integer return to a number. Serial.write() does not.
Watch for me on National Geographic Wild "When Sharks Attack: Gulf Coast Killers". Airs on June 22nd.

Chaos_Lord

Ah ok thank you,

but now i got another Problem. After the Data is now correctly shown on the screen i want to get it into some form, that i can use in the programm. Trying to make a string leaves an if Check going false? An Idea?

PaulS

Quote
Trying to make a string leaves an if Check going false? An Idea?

I don't understand this statement. I don't see any attempt at codding this, either, though.

Chaos_Lord

Hi everyone

got the problem solved, i need to use an internal buffer to read from the file and put this buffer together to a char so i can use it...

Tnx for the help here :D


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy