Can we use fopen, fread, fwrite, fclose standard io function?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Can we use fopen, fread, fwrite, fclose standard io function?

2,861件の閲覧回数
isaotakashima
Contributor IV


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

ラベル(1)
0 件の賞賛
返信
4 返答(返信)

2,181件の閲覧回数
BlackNight
NXP Employee
NXP Employee

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

0 件の賞賛
返信

2,181件の閲覧回数
isaotakashima
Contributor IV

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

0 件の賞賛
返信

2,181件の閲覧回数
BlackNight
NXP Employee
NXP Employee

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

0 件の賞賛
返信

2,181件の閲覧回数
isaotakashima
Contributor IV

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

0 件の賞賛
返信