To attach to the USB device using usbd_attach() function

Hi, I’m working on a USB class driver. Iam able to connect to the USB
stack using usbd_connect() function. But when I try to attach to the
USB device using usbd_attach() function, Iam not able to attach to
the device.
Insertion callback function is not called even the USB device is
inserted.
Following is the code used:

void insertion(struct usbd_connection *usb_connection,
usbd_device_instance_t *usb_instance)
{
int attach_handle;
struct usbd_device *device;

printf (“DEVICE INSERTED\n”);
attach_handle = usbd_attach( usb_connection, usb_instance, 0,
&device );
if (attach_handle == EOK)
{
printf(“DEVICE ATTACHED successfully\n”);
}
else
{
printf(“FAILURE\n”);
}
return;
}

Could you post the code showing the connection to the USB stack ?
Are you specifying the device you are interested in the usbd_connect_parm_t
?
Is the device listed when you run the ‘usb’ utility ?

Henry

manochithra <mano.chithra@wipro-dot-com.no-spam.invalid> wrote in message
news:db87nq$qvm$1@inn.qnx.com

Hi, I’m working on a USB class driver. Iam able to connect to the USB
stack using usbd_connect() function. But when I try to attach to the
USB device using usbd_attach() function, Iam not able to attach to
the device.
Insertion callback function is not called even the USB device is
inserted.
Following is the code used:

void insertion(struct usbd_connection *usb_connection,
usbd_device_instance_t *usb_instance)
{
int attach_handle;
struct usbd_device *device;

printf (“DEVICE INSERTED\n”);
attach_handle = usbd_attach( usb_connection, usb_instance, 0,
&device );
if (attach_handle == EOK)
{
printf(“DEVICE ATTACHED successfully\n”);
}
else
{
printf(“FAILURE\n”);
}
return;
}

Hi thanks for ur info. After specifying the Vendor ID and Product Id
of the device I use, my Insertion callback function is called but
usbd_attach() returns the error msg EBUSY.
Can u please help me out in resolving this problem.

void Dev_insertion(struct usbd_connection *usb_connection,
usbd_device_instance_t *usb_instance)
{
int attach_handle;
struct usbd_device *device;
printf (“DEVICE INSERTED\n”);

attach_handle = usbd_attach( usb_connection, usb_instance, 0,
&device );
if (attach_handle == EOK)
{
printf(“DEVICE ATTACHED successfully\n”);
}
else if (attach_handle == ENODEV )
{
printf(“Error - ENODEV\n”);
}
else if (attach_handle == EBUSY )
{
printf(“Error - EBUSY\n”);
}
else if (attach_handle == ENOMEM )
{
printf(“Error - ENOMEM\n”);
}
else
{
printf(“FAILURE %d\n”, attach_handle);
}
return;
}

Does this happen every time ? EBUSY means that a driver has already attached
to the device. Are there any other drivers running that would attach to the
device ?
Make sure you are not running multiple drivers.

manochithra <mano.chithra@wipro-dot-com.no-spam.invalid> wrote in message
news:dbii7v$dks$1@inn.qnx.com

Hi thanks for ur info. After specifying the Vendor ID and Product Id
of the device I use, my Insertion callback function is called but
usbd_attach() returns the error msg EBUSY.
Can u please help me out in resolving this problem.

void Dev_insertion(struct usbd_connection *usb_connection,
usbd_device_instance_t *usb_instance)
{
int attach_handle;
struct usbd_device *device;
printf (“DEVICE INSERTED\n”);

attach_handle = usbd_attach( usb_connection, usb_instance, 0,
&device );
if (attach_handle == EOK)
{
printf(“DEVICE ATTACHED successfully\n”);
}
else if (attach_handle == ENODEV )
{
printf(“Error - ENODEV\n”);
}
else if (attach_handle == EBUSY )
{
printf(“Error - EBUSY\n”);
}
else if (attach_handle == ENOMEM )
{
printf(“Error - ENOMEM\n”);
}
else
{
printf(“FAILURE %d\n”, attach_handle);
}
return;
}