Writing to USB Thumb Drive

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

Writing to USB Thumb Drive

Jump to solution
1,939 Views
arzsupra
Contributor I

Hi Everyone,

    I'm pretty new to MQX, so I'm having difficulty getting the MCU to write to a USB.  I took the USB intialization files from the web_hvac demo, and it seems to be intializing the USB drive when I plug it in.  When I call my write function, however, nothing gets written to the flash drive, and whenever I plug the drive into my machine to check if the data was written onto the file, it has me reformat the drive, which causes me to erase all the file on the USB.  Is this normal?

 

 

//TEST WRITING CODEvoid usb_file_write(){    FILE_PTR usb_fs_file;    char data[6] = "testme";    FILE_PTR usb_file;    usb_fs_file = fopen("USB:",NULL);    if(usb_fs_file==NULL){        printf("Error opening the MFS Device Driver.");        _mqx_exit(1);    }    usb_file=fopen("USB:\\data.text","a+");    if(usb_file==NULL){        printf("Error opening the file.");        _mqx_exit(1);    }    write(usb_file,data,strlen(data));    fclose(usb_file);}

 

Any help is appreciated, thanks!

 

 

 

Labels (1)
Tags (1)
0 Kudos
1 Solution
388 Views
cutworth
NXP Employee
NXP Employee

I think when you install USB file system, you use following call

 

usb_fs_handle = usb_filesystem_install( USB_handle, "USB:", "PM_C1:", "c:" );

 

And here you use "USB:" to open file, that is not correct, you should use "c:" instead.

View solution in original post

0 Kudos
1 Reply
389 Views
cutworth
NXP Employee
NXP Employee

I think when you install USB file system, you use following call

 

usb_fs_handle = usb_filesystem_install( USB_handle, "USB:", "PM_C1:", "c:" );

 

And here you use "USB:" to open file, that is not correct, you should use "c:" instead.

0 Kudos