david1982 Posted April 14, 2015 Report Share Posted April 14, 2015 Hello all,I have a working spi SD card setup using gfile.What I want to do is have a file on the SD card with some settings (numbers) and have my code read the file and then have the setting number applied to an int.How would I best go about this?Thank you. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted April 14, 2015 Report Share Posted April 14, 2015 If you don't want to do it manually then the best option is to use an existing library. I don't know specific embedded solutions for this but I guess any C INI file parser that you will find using google will work.If you don't have the required resources then the best option is always to create your own set of configuration and settings structs and save them in binary to a file. You can then simply read back the raw data and cast it into the same struct again.You'll find a lot of examples on how to save and restore structs to binary files in C using google.~ Tectu Link to comment Share on other sites More sharing options...
inmarket Posted April 14, 2015 Report Share Posted April 14, 2015 Saving in binary is very quick and easy, just write the struct to the file. Binary however is difficult if you want someone to be able to edit it when the sdcard is not in your device. In that case you should use some text format.If you need to use a text format a function to look at is gprintg which is equivalent to fprintf except it uses gfile. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now