Closed surajparab945 closed 7 years ago
What does the config3.ini file look like?
[PROFILES] 1=PROFILE1 2=PROFILE5
[PROFILE1] sound_file_name1 = "/SoundP~1/bell.wav"
A1 = 10 B1 = 0
C1 = 0 D1 = 1
E = 0 F = 1000
[PROFILE2] sound_file_name2 = /SoundP~1/steam.wav
A2 = 1 B2 = 1
C2 = 20 D2 = 0
E = 1 F = 0
This is the output where I get the profiles in do while loop but afterwards when I access outside the do while loop I get blank.
Initializing SD card... done. Sound directory Ini file exists PROFILE1 PROFILE5 PROFILE4 PROFILE2 PROFILE3 MAXIMUM SOUND PROFILES:5
Ini file exists "/SoundP~1/bell.wav"
You are storing the buffer pointer in SP. The buffer pointer does not change but its contents do. You must copy the buffer contents to a char array.
Hii,
I want to read the maximum profiles and order in which it is stored, for that, I am storing the data in a pointer array from buffer. When I am using the pointer array outside the loop it show me nothing as if data has been not stored ? I can see the data in buffer using Serial monitor and also using pointer array. I can see the data but only in a loop and if I print outside the loop It doesn't print anything. It will be more clear when I will provide the
code.
char *SP[80]; void setup() { // debug output at 9600 baud Serial.begin(9600);pinMode(10,OUTPUT); // setup SD-card Serial.print(F("Initializing SD card...")); if (!SD.begin(10)) { Serial.println(F(" failed!")); while (true); }
Serial.println(F(" done."));
//INI FILE const char *filename = "/config3.ini"; const size_t bufferLen = 80; char buffer[bufferLen];
IniFile ini(filename); if (!ini.open()) { Serial.print("Ini file "); Serial.print(filename); Serial.println(" does not exist"); //error("Ini Setting File Does NOt Exist"); } Serial.println("Ini file exists");
// Check the file is valid. This can be used to warn if any lines // are longer than the buffer. if (!ini.validate(buffer, bufferLen)) { Serial.print("ini file "); Serial.print(ini.getFilename()); Serial.print(" not valid: "); //error("Setting File Is Not Valid"); } // to Determine the number of profiles and it's order do {
if( ini.getValue("PROFILES", number , buffer, bufferLen)){
SP[j]= buffer; Serial.println(SP[j]);
count = j;
} while(buffer[0] != '\0' );
Serial.println(count); ini.close();
for(int i = 0; i <= count; i++){
Serial.println(SP[i]);
} }`