Usb mass storage file system location on QNX

末鹿安然 提交于 2019-12-13 00:37:09

问题


I need my software to be notifed that usb mass storage stick has been inserterd, also i need locationa where this stick has been mounted. Is it possible to obtain this information, especially location on fs where stick has been mounted from any C library ?

For instertion i already know usbd_connect() and i'm using it. Unfortunatelly there is no information with respect to location on fs.

regards JosiP


回答1:


io-usb should be up and running on your target.

Add the library "usbdi" to your project.

Then use the following code snipet :

#include <sys/usbdi.h>

static struct usbd_connection *conn_usb = NULL;
static void cbinsert(struct usbd_connection *connection, usbd_device_instance_t *ins);
static void cbremove(struct usbd_connection *connection, usbd_device_instance_t *ins);

        int init(void)
        {
            usbd_funcs_t funcs = { _USBDI_NFUNCS, cbinsert, cbremove, NULL };
            usbd_connect_parm_t parm = {NULL, USB_VERSION, USBD_VERSION, 0, 0, NULL, 0, NULL,  &funcs,0};

            if (usbd_connect(&parm, &conn_usb) != EOK) {
                /* write your own error handler */
            }

And then, add your customized handler :

static void cbinsert(struct usbd_connection *usb_connection,usbd_device_instance_t *usb_instance)
{
    if (usb_instance->ident.dclass == 8 && usb_instance->ident.subclass == 6) {
        /* USB mass storage */
    } else if (usb_instance->ident.dclass == 3 && usb_instance->ident.subclass == 1) {
        /* USB mouse */
    } else {
        /* unknown device */
    }

This is an example. You will have to customized it. But everything you need is there.

Hope this help ! Emmanuel




回答2:


Try using MCD(Media Content Detector) in QNX. Refer to the below links -

http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/m/mcd.html http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.dev_pub.ref_guide%2Ftopic%2Fdrivers.html



来源:https://stackoverflow.com/questions/29164829/usb-mass-storage-file-system-location-on-qnx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!