Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ddk_en/usb/usbd_attach.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ddk_en/usb/usbd_attach.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ddk_en/usb/usbd_attach.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ddk_en/usb/usbd_attach.html on line 8

usbd_attach()

Attach to a USB device

Synopsis:

#include <sys/usbdi.h>

int usbd_attach( struct usbd_connection *connection, 
                 usbd_device_instance_t *instance, 
                 size_t extra, 
                 struct usbd_device **device );

Arguments:

connection
An opaque handle that identifies the USB stack (from usbd_connect()).
instance
Describes which device you wish to attach to.
extra
The size of additional memory you'd like allocated with the device. You can use usbd_device_extra() later to get a pointer to this additional memory. Typically, the class driver would store various status/config/device-specific details in here (if needed).
device
An opaque handle used to identify the device in later calls.

Library:

libusbdi

Description:

You use the usbd_attach() function to attach to a USB device. Typically, you do this out of the insertion callback (made when the device matched your filter), which will give you the connection and instance parameters involved. The insertion callback is prototyped as follows:

void (*insertion)(struct usbd_connection *, usbd_device_instance_t *instance)

The usbd_device_instance_t structure looks like this:

typedef struct usbd_device_instance {
    _uint8                    path;
    _uint8                    devno;
    _uint16                   generation;
    usbd_device_ident_t       ident;
    _uint32                   config;
    _uint32                   iface;
    _uint32                   alternate;
} usbd_device_instance_t;

Looping

Another way to attach is to loop and attach to all devices (in which case you build the instance yourself). For example:

for (busno = 0; busno < 10; ++busno) {
    for (devno = 0; devno < 64; ++devno) {
        memset(&instance, USBD_CONNECT_WILDCARD, sizeof(usbd_device_instance_t));
        instance.path = busno, instance.devno = devno;
        if (usbd_attach(connection, &instance, 0, &device) == EOK) {
          ......
        }
    }
}

The degree of “attachedness” depends on how you connected:

Returns:

EOK
Success.
ENODEV
Specified device doesn't exist. If in a loop, then there's nothing at that devno. If from a callback, then the device has since been removed.
EBUSY
A shared/exclusive conflict.
ENOMEM
No memory for internal device structures.

Classification:

QNX Neutrino, QNX 4

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

usbd_connect(), usbd_detach(), usbd_device_extra(), usbd_disconnect()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ddk_en/usb/usbd_attach.html on line 203

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ddk_en/usb/usbd_attach.html on line 203