- Sun Feb 27, 2011 5:57 pm
#121460
FWIW, parsing isn't all that tough, even without using fscanf().
It helps if you get to decide the file format. If so, then keep it really simple, with single character tokens. E.g.,
var1 = 13;
var2 = 128;
is harder to parse than:
# var1, var2
13, 128
or
13
128
You have atoi() that you can use for integers. Floats you have to parse with custom code. Or, if interested, I have a simple float parser I just wrote a few weeks ago that you can use. I also have code that splits the line up. I used simple comma separators and split on those tokens.
As for binary... it can be easy. If you put the data in a struct then you just write the struct out raw, using sizeof() to get the size of the struct. Then do the same in reverse to read.
But that's probably more work than it has to be if you just write a simple parser for text.
As for memory, no reason you can't read one line at a time and parse. Shouldn't take much memory.
For the SD card, stick to 2G and below and you can use lighter weight FAT16 libraries that take less memory. And use an AVR with a reasonable amount of mem to begin with. Should work out fine I think.