Writing to USB Thumb Drive

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Writing to USB Thumb Drive

ソリューションへジャンプ
1,952件の閲覧回数
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 解決策
401件の閲覧回数
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 返信
402件の閲覧回数
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 件の賞賛