Arduino read properties file from SD card

Hello all, Is there any library that can read a properties file from sd card? Or at least one that can take the full text as string and split the properties?

The file would contain data like:

sensor1.pin=2
sensor2.pin=5
loop.period=10000
web.server=blablabla.com

and I would like to get it in something like a map in java or something. So when I want to find the sensor 1 pin, I would search for it and get the string "2" etc.

Is there any library that can read a properties file from sd card?

No, but it's pretty easy to do so. First, you need to read and store a complete record. That is a simple matter of reading each character, deciding whether it is an end-of-record marker (carriage return, usually), and then storing the character or parsing the record and resetting for the next record.

The strtok() function is a big help in parsing, as are atoi() and atof(). strdup() can copy the text data to new memory, or strcat() can copy it to existing memory.

PaulS:

Is there any library that can read a properties file from sd card?

No, but it's pretty easy to do so. First, you need to read and store a complete record. That is a simple matter of reading each character, deciding whether it is an end-of-record marker (carriage return, usually), and then storing the character or parsing the record and resetting for the next record.

The strtok() function is a big help in parsing, as are atoi() and atof(). strdup() can copy the text data to new memory, or strcat() can copy it to existing memory.

Thanks. I had thought that it can be implemented this way, I just asked if there is any library that can help me do that faster :slight_smile: . Thanks!!