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
Solved! Go to Solution.
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!
-----------------------------------------------------------------------------------------------------------------------
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!
-----------------------------------------------------------------------------------------------------------------------
Thanks Garabo !
It worked for me. I tried the same thing earlier but it somehow failed.
Thank you again !
Regards,
Nitin