stevemarple / IniFile

Arduino library to parse ini files.
GNU Lesser General Public License v2.1
87 stars 45 forks source link

Not an issue, more a question #3

Closed ethanous closed 10 years ago

ethanous commented 10 years ago

So i have to say, your solution for reading files off of a SD card is considerably more streamlined then other solutions i have seen out there. But i do have a question/request. Im building a reverse geocache platform and i want to use your library so that i can put gps coordinates onto my sd card and not have to re flash my arduino every time i want to change the route. Currently im using a hard coded array with floating locations. IE: float latArray[] = {11.111111, 22.222222, 33.333333}; float longArray[] = {-11.111111, -22.222222, -33.333333}; since your codes is written to return char, i am not able to make it work with my code. I was hoping you would have a suggestion as to the easiest way to use what you have written so that i can use it in my code. Thanks for any info you can provide.

stevemarple commented 10 years ago

getValue() overloaded for float is missing. I'll see if I can add that. In its absence you can get a string and use sscanf to convert.

stevemarple commented 10 years ago

I've added an overloading for getValue() so that you can read floating point values from the ini file. It passes regression testing under linux. It compiles in the Arduino environment but I've not tested that feature there. If you try it please let me know if it works.

ethanous commented 10 years ago

Im sorry its been so long, but i have been distracted by other projects. So i downloaded your latest code and i am sure im simply doing something wrong, can you help provide a pointer as to where im going wrong? ini file: [geo_coords] longArray = 11.111111, 22.222222, 33.333333

part of my code: if (ini.getValue("geo_coords", "longArray", buffer, bufferLen)) { Serial.print("long array: "); Serial.println(String(buffer)); sscanf(buffer, "%f, %f, %f", &lonArray[0], something, &lonArray[1]); Serial.println(something,6); }

when i print out the buffer, everything looks correct, but when i try to print something, i get all 0s. Eventually i want it to actually automatically create my array based on coordinates in the ini file. Thanks again for any help you can provide. Your code has helped me fix other issues i was seeing.

stevemarple commented 10 years ago

If you can print the buffer correctly it seems you have read the string properly. This code is tested by the regression testing. That short code snippet doesn't show how the variables and buffer memory are defined and allocated. Do you need to use "Serial.println(String(buffer));", won't "Serial.println(buffer);" do?

ethanous commented 10 years ago

I am able to read the data from the buffer just fine. Its actually parsing the info is where im having the issue. sscanf doesn't seem to be reading the line correctly. I am attempting to read the buffer and split it into an array. You can see ultimately what im trying to do with that line, but when i try to simply write to a single variable to ensure im putting data into the array, i am not getting anything back. From what i can tell, the sscanf has the correctly syntax so i am a bit at a loss. C is not a language i work with from day to day so please bare with me. Thanks again for all of the help you have provided so far.

stevemarple commented 10 years ago

Since the buffer holds the correct data the fault isn't with IniFile. A more appropriate place to ask for help on general programming issues is the Arduino forum, http://forum.arduino.cc/ Be sure to include the variable definitions.