I've got an application that requires moving to specific points on a file on an SD card, reading, modifying and then writing an update. The file is fixed size. The code has no problems moving to the specific offsets required and then reading in blocks of data.
However, when the code does a seek() to the next desired location, then a write() and a flush(), the data is not written. If my code seeks back to the start of the block just written and reads it back, it does not contain the new data.
The file is definitely open for writing, and the write operation indicates it wrote all the bytes. No calls are indicating any error.
Since reads and seeks are working I'm assuming this is not a problem with wiring of the device to the Arduino Mega. The files range from around 100K to almost 2M each, and the code needs to access the entire content of the file, but almost never sequentially. Writes are almost always non-sequential as well.
Is it necessary to do a close after each write instead of the flush?
Does anyone have any suggestions of things I should be investigating?
Bob