Writing to USB Thumb Drive

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

Writing to USB Thumb Drive

跳至解决方案
1,955 次查看
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!

 

 

 

标签 (1)
标记 (1)
0 项奖励
1 解答
404 次查看
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 项奖励
1 回复
405 次查看
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 项奖励