Go Down

Topic: Read bytes from within SD file? (Read 2365 times) previous topic - next topic

cruzze

Sep 01, 2011, 10:34 pm Last Edit: Sep 05, 2011, 12:29 pm by cruzze Reason: 1
Hi,

So, I finally got my Sparkfun microSD shield working on the Mega 2560, thanx to
http://mcukits.com/2009/04/06/arduino-ethernet-shield-mega-hack/. That is, disconnect pins 10-13 between the Sparkfun SD board and the Mega. Then, connect pin 10 on the SD board to pin 53 on the Mega, 11 to 51, 12 to 50, 13 to 52 and use the libraries as is (no code changes).
I am working on a logger project that creates a decent amount of data is appended to a file on the SD card. Every now and then I want my Mega to pump over portions of this file to my smartphone once this is connected. Since the size of the file well exceeds the capacity of my SRAM and EEPROM (hence no way of reading the whole file), is it possible to read just portions of the file and send it?
I'm using the fat16lib20101009 by Bill Greiman.

Thanks for any assistance!

Cruzze

fat16lib

You can use seekSet() to position the file to a byte offset from the start of the file.  The fat16rewrite.pde example uses seekSet() to position to the middle of a file.

You can just read the file and discard data that you don't want to send to the phone.

cruzze

Thanks, it works! I am able to read multi-MB text files from my micro-SD card.
The file.seekSet(n) can work as a pointer to use the text file as some sort of RandomAccessFile which I was originally exploring!

Brilliant!

Cruzze

Go Up