Hi Liying,
I think that you are halfway there!
It sounds like you are having a CONSTANT value connected to "pos mode" and "pos offset". What you need to do, is create some code that calculates "pos mode" and "pos offset" depending on how long you have been acquiring data. In the first two days, "pos mode" and "pos offset" should be "1 (end)" and "0". Then after two days, when you want to start overwriting the file from the start, "pos mode" and "pos offset" has to be changed to point to the beginning of the file. You can for example choose "0 (start)" and "0" and then increase "pos offset" so you don't keep overwriting the very beginning of the file. You will have to calculate "pos offset" by knowing how many bytes you write to the file at a time.
The Circular Buffer is simply a technique used when accessing a buffer. 'Circular' simply refers to the fact that when the end is reached, it continues from start again. It is basically the same functionality you are referring to - only difference is that you wish to use File I/O and not RAM.
Let me know if you have any questions, thanks.
- Philip Courtois, Thinkbot Solutions