MFS Multiple file open

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MFS Multiple file open

跳至解决方案
1,418 次查看
nitinkothari
Contributor II

Hello,

I am using MFS with MQX on MCF54418.

If I try to open second file with one file already open, the fopen returns NULL and it fails.

This is how I am opening File1.txt :

//Declare File system structure

typedef struct

{

  MQX_FILE_PTR DEV_FD_PTR;

  MQX_FILE_PTR PM_FD_PTR;

  MQX_FILE_PTR FS_FD_PTR;

  char_ptr     DEV_NAME;

  char_ptr     PM_NAME;

  char_ptr     FS_NAME;

 

} USB_FILESYSTEM_STRUCT, _PTR_ USB_FILESYSTEM_STRUCT_PTR;

//Create an instance

USB_FILESYSTEM_STRUCT stUsbFileSystem; 

//Open File1.txt

stUsbFileSystem.FS_FD_PTR = fopen("C:\\File1.txt", "r");

Now my question is, how to proceed if I have  to open File2.txt without closing File1.txt ?

Any help is greatly appreciated !

Regards,

Nitro

标签 (1)
0 项奖励
回复
1 解答
1,175 次查看
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Nitin,

Try something like this:

void my_task(uint32_t temp)
{
    FILE_PTR      fp;
    FILE_PTR      fp_temp;

    _time_delay(2000);

    printf("Before write in files\n");
    fp = fopen("a:\\test.txt","a+");
    write(fp, "Hello World", 11);
   
    fp_temp = fopen("a:\\test_t.txt","a+");
    write(fp_temp, "Hello World_Temp", 18);
   
    fclose(fp);
    fclose(fp_temp);

    _task_block();
   
}


Regards,
Garabo

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,176 次查看
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Nitin,

Try something like this:

void my_task(uint32_t temp)
{
    FILE_PTR      fp;
    FILE_PTR      fp_temp;

    _time_delay(2000);

    printf("Before write in files\n");
    fp = fopen("a:\\test.txt","a+");
    write(fp, "Hello World", 11);
   
    fp_temp = fopen("a:\\test_t.txt","a+");
    write(fp_temp, "Hello World_Temp", 18);
   
    fclose(fp);
    fclose(fp_temp);

    _task_block();
   
}


Regards,
Garabo

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
1,175 次查看
nitinkothari
Contributor II

Thanks Garabo !

It worked for me. I tried the same thing earlier but it somehow failed.

Thank you again !

Regards,

Nitin

0 项奖励
回复