files on sdcard written jut 50%
Posted: Thu Sep 25, 2014 6:02 pm
Hi, I am trying to write some text to a file in placed in an sd card, as reported below:
after that, I have the following situation on the file "log.txt":
512 bytes text
512 bytes 0x00
512 bytes text
512 bytes 0x00
...
Is it right? I am using fat fs include in chibios 2.6.5, with 512 bytes sector size, and a 4GB sd card.
Can somebody please explain such a behavior?
Thank you in advance.
-g
Code: Select all
log_res = f_open(&log_file, "0:/log.txt", FA_OPEN_ALWAYS | FA_WRITE);
if (log_res) {
return;
}
f_sync(&log_file);
/* append to the end of file */
log_res = f_lseek(&log_file, f_size(&log_file));
/* write data */
log_res = f_write(&log_file, logbuffer, pbuffer - logbuffer, &log_bw);
f_sync(&log_file);
if (log_bw < (uint16_t)(pbuffer - logbuffer))
setFsFull();
/* log_res = f_truncate(&log_file); */
log_res = f_close(&log_file);
after that, I have the following situation on the file "log.txt":
512 bytes text
512 bytes 0x00
512 bytes text
512 bytes 0x00
...
Is it right? I am using fat fs include in chibios 2.6.5, with 512 bytes sector size, and a 4GB sd card.
Can somebody please explain such a behavior?
Thank you in advance.
-g