I want to read, write a file in the PC using fopen, fread, fwrite, fclose standard io function.
Can we use fopen, fread, fwrite, fclose standard io function?
If yes, please send sample code.
Best regards,
Takashima
Hi Takashima,
that depends on the semihosting implementation of the debug connection. E.g. it works fully for Segger J-Link (see https://mcuoneclipse.com/2014/12/26/code-coverage-for-embedded-target-with-eclipse-gcc-and-gcov/ ) but afaik not for P&E (yet?).
Erich
Dear Erich,
Thank you for your quick reply.
I'm using TWR-K65F180M with J-Link lite OpenSDA, and I wrote the following code, but I cannot open WAVE.wav file.
FILE *fp;
if ((fp = fopen("WAVE.wav", "rb"))==NULL){
PRINTF("Cannot read file.\r\n");
for(;;){};
}
Please advise to fix this issue.
Best regards,
Takashima
Dear Takashima,
The question is: what is the current directory of your system?
See https://mcuoneclipse.com/2015/08/23/tutorial-using-gnu-profiling-gprof-with-arm-cortex-m/ where it uses fwrite() to write files. There the current directory is the project root folder. You should use an absolute path or find out what is the current directory on your system (e.g. with creating a file first).
I hope this helps,
Erich
Dear Erich,
Thank you for your reply.
I refer https://mcuoneclipse.com/2015/08/23/tutorial-using-gnu-profiling-gprof-with-arm-cortex-m/ , but I cannot find out sample code which use fopen(), fwrite() functions.
Can you send sample code?
Best regards,
Takashima