MFS install

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

MFS install

1,302 Views
nitinkothari
Contributor II

Hello all,

I am using MFS with USB Host stack for Mass Storage Device and I am pretty new to it.

I am trying to read a text file from the connected MSD. Here is the sequence of funciton calls I am using for the purpose :

_io_usb_mfs_install("USBD:", 0, (pointer)msg.ccs);  /* msg.ccs is a pointer to class_call_structure poitner*/

DEV_FD_PTR = fopen("USBD:", NULL);  /* First fopen to open the device*/

FS_FD_PTR = fopen("C:\\my_read_file.txt", "a+");  /* 2nd fopen to open the file*/

So instead of reading the data from the file, all I could read was the data from Sector 0.

Can anyone please tell me what am I doing wrong ?

Appreciate your time.

Regards,

Nik

Labels (2)
Tags (2)
5 Replies

580 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Nik

Please see the sample code for fopen:


Open the MFS device driver and open a file on the device.
char buffer[100] = "This a test file";
char buffer2[100];
/* Open the MFS device driver: */
mfs_fd_ptr = fopen("MFS1:", NULL);
if (mfs_fd_ptr == NULL) {
printf("Error opening the MFS device driver!");
_mqx_exit(1);
}
/* Open file on disk in the current directory and write to it: */
fd_ptr = fopen("MFS1:myfile.txt", "w+");
write(fd_ptr, buffer, strlen(buffer));
read(fd_ptr, buffer2, strlen(buffer));
/* Close the file: */
error_code = fclose(fd_ptr);

/* Open other files, create directories, and so on. */

/* The application has done all it needs. */

/* Close the MFS device driver and uninstall it: */

error_code = fclose(mfs_fd_ptr);

if (!error_code) {

error_code = _io_mfs_uninstall("MFS1:");

} else if (error_code == MFS_SHARING VIOLATION) {

printf("There are open files on the device. Call fclose on their

handles before attempting to fclose the device driver");

}

Regards

Please refer to the MQXMFSUS.pdf for more information

http://cache.freescale.com/files/32bit/doc/user_guide/MQXMFSUG.pdf?fpsp=1&WT_TYPE=Users Guides&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation

580 Views
nitinkothari
Contributor II

Hi Daniel,

Thanks for the reponse.

I tried exactly the same. But in my case, after the second fopen , it reads Sector 0 information only.

Can anyone please suggest what could be wrong ?

Regards,

Nik

0 Kudos

580 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Nik:

Did you mount USB filesystem successfully before fopen?  if not, there is demo code for it , for your reference.

<MQX_INSTALL_DIR>/mfs/examples/mfs_usb/usb_tasks.c

Hope it helps

580 Views
nitinkothari
Contributor II

Thanks again Daniel.

I had a look at the example code you had mentioned.

Is this line mounting the device :

             error_code = _io_mfs_install(usb_fs_ptr->DEV_FD_PTR, file_system_name, 0);  ??

Thanks !

Nik

0 Kudos

580 Views
danielchen
NXP TechSupport
NXP TechSupport

HI

I attached a document for your reference. Page 2-Page5 explained something about USB device installation.

0 Kudos