Hi,
Me again, with my simple problems.
Here's my story: I want to store my config file as a .txt file on my SD card.
So i made i file status.ini on my SD, with 2 lines of text in it.
Now i just want to read it for the SD line by line in a string, so i can get my settings out of it.
I made a little demo code. (Adapted for the Datalogger example from the SD lib.)
void setup(void)
{
//Start Serial Port
Serial.begin(9600);
//Read Config File from SD
//Disable Ethernet shield
pinMode(Eth_SPI_Select, OUTPUT);
digitalWrite (Eth_SPI_Select, HIGH);
//Enable SD.
pinMode(SDC_SPI_Select, OUTPUT);
digitalWrite (SDC_SPI_Select, LOW);
//Init SD Card
Serial.print("Initializing SD card...");
if (!SD.begin(SDC_SPI_Select)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
File statusFile = SD.open("status.ini");
// if the file is available, write to it:
if (statusFile) {
while (statusFile.available()) {
Serial.write(statusFile.read());
//SD_Read=SD_Read+(statusFile.read(),OCT);
}
statusFile.close();
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening status.ini");
}
Serial.print(SD_Read);
}
This codes, reads the data from the SD and puts it in my serial monitor.
The output:
Request_Mode=<Auto>
Set_Temp=<190>
So far i'm fine, it succesfully reads from the SD.
But now i want to put this output into a string, so i uncomment the "//SD_Read=SD_Read+statusFile.read();" line and comment the "Serial.write(statusFile.read());" line. Now the output of SD_Read is:
8210111311710111511695771111001016160651171161116210831011169584101109112616049574862
What kind of format is this? Any tips how to fix this?
Big thanks,
Nico