MFS Multiple file open

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MFS Multiple file open

Jump to solution
692 Views
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

Labels (1)
0 Kudos
1 Solution
449 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
2 Replies
450 Views
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 Kudos
449 Views
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 Kudos