0
\$\begingroup\$

I'm trying to write measurements from external sensor to the file (lets say 1 per second). I'm using ATMega32 and PetitFS. At this moment I'm able to write one measure:

int main(void){

    BYTE result;
    WORD s1;

    for(;;){
        sprintf(buff, "Measure: %d\r\n", mes);
        s1=4;
        result = pf_write(buff, sizeof(buff), &s1);
        write_close();
    }
}

Now I'm trying to extend above code with pf_lseek to append another measure after previous one. Can someone give me a hint/suggestion how to achieve this?

\$\endgroup\$
0
\$\begingroup\$

I think you did not post the whole code, as pf_mount and pf_open are also needed to get started.

First of all - just don't close the file, call pf_write again with another sample.

Second - if you want to append to an existing file - open the file with pf_open and then try pf_lseek perhaps with a very high number (UINT32_MAX). I think that it will just set the pointer to the end of the file (check the error code).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.