Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 5781

USB - Memory Stick Removal Error

$
0
0

Hi,

I am using the File X on USB Mass Storage to read some files from a memory stick.

I insert the memory stick for the first time after powering the product, read some file and unplug the memory stick. Everything works fine.

Now, when I insert the memory stick again, the program goes to g_fx_media0_err_callback_failed_to_get_fx_media_internal(). There are times when it simply does nothing, it doesn't goes to g_fx_media0_err_callback_failed_to_get_fx_media_internal() but doesn't triggers the plug event either.

I suppose I am missing something in the unplug event. Right now I am doing this:

UINT usb_host_plug_event_notification(ULONG usb_event, UX_HOST_CLASS * host_class, VOID * instance)
{
    app_event_t event;

    UX_HOST_CLASS_STORAGE_MEDIA * p_ux_host_class_storage_media;

    if (UX_SUCCESS == _ux_utility_memory_compare (
            _ux_system_host_class_storage_name,
            host_class,
            _ux_utility_string_length_get (_ux_system_host_class_storage_name))) {

        ux_system_host_storage_fx_media_get(instance, &p_ux_host_class_storage_media, &g_fx_media0_ptr);

        switch(usb_event)
        {
            case UX_DEVICE_INSERTION:
                event.id = APP_EVENT_USB_PLUG_IN;
                event.args = NULL;
                tx_queue_send(&app_queue, &event, TX_NO_WAIT);
                break;
            case UX_DEVICE_REMOVAL:
                event.id = APP_EVENT_USB_PLUG_OUT;
                event.args = NULL;
                tx_queue_send(&app_queue, &event, TX_NO_WAIT);
                break;
            default:
                // Do nothing!
                break;
        }
    }

    return UX_SUCCESS;
}

 

In the main thread:

if(tx_queue_receive(&app_queue, &event, TX_WAIT_FOREVER) == TX_SUCCESS)
{

switch(event.id)
{

case APP_EVENT_USB_PLUG_OUT:
fx_file_close(&usb_file);
fx_media_close(g_fx_media0_ptr);
break;

}

}


Viewing all articles
Browse latest Browse all 5781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>