LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxAnswers Discussion (https://www.linuxquestions.org/questions/linuxanswers-discussion-27/)
-   -   DISCUSSION: Developing Linux Device Drivers using Libusb API (https://www.linuxquestions.org/questions/linuxanswers-discussion-27/discussion-developing-linux-device-drivers-using-libusb-api-224021/)

vikram_cvk 08-29-2004 04:01 PM

DISCUSSION: Developing Linux Device Drivers using Libusb API
 
This thread is to discuss the article titled: Developing Linux Device Drivers using Libusb API

KneeLess 09-02-2004 01:16 PM

This is a good article, but #include <...> are left out, and the indentation on the code is horrible (because there isn't any). I'm not sure if this is problem with the linuxanswers themselves, but it would look much better if it was properly formatted.

maroonbaboon 07-22-2005 05:31 AM

Just experimenting a bit here. Here is some C code with the vB 'code' tags:
Code:

#include <stdio.h>
main() {
    Printf("hello world\n");
}

Here is the same thing cut and pasted, without tags

#include <stdio.h>
main() {
Printf("hello world\n");
}

So (according to the preview button) you lose your indentation but I have no idea what happened to the #include directives in this post. Perhaps the author could fix it up with some 'code' tags. The ref to the sourceforge site also needs changing so it comes out as a link.

I've been searching for documentation on USB device drivers recently. There are a few good references but overall the situation is not very satisfactory. So almost anything is a positive contribution. If I understand correctly libusb lets you access USB devices even if they don't have kernel-level drivers. As the author suggests the (again rather brief) documentation at http://libusb.sourceforge.net/doc is worth a look for further code and examples. Apparently gphoto and rio500 are based on libusb.

Tester1 12-28-2006 09:50 AM

Missing include lines
 
Quote:

Originally Posted by KneeLess
This is a good article, but #include <...> are left out,

I myself added the following include lines:

#include <stdio.h>
#include <stdlib.h>
#include <usb.h>

I do not know if all of those are necessary. After compiling and testing I noticed that usb_get_string_simple does not return any string via string parameter when testing the program as a user. The return value of the function usb_get_string_simple is -1 all the time.

But when I changed to root user and tested the program, everything worked fine.

Anyway, I wonder if this phenomen has something to do with udev? With two different live-cd (gentoo and SuSE) boot process stopped just after udev:

...
Starting udev....
... udev running.
Starting hardware detection...
Activating usb devices... <-- boot stops here

(the above example is with the SuSE 10.1 installation CD-ROM and repair system option).

jvogel 10-12-2007 12:23 PM

Linux Device Drivers
 
I am new to the Linux world. I have been programming for over 15 years and now I am writing a User Space USB device driver, or aleast trying to do so.

I found the article very interesting though it end with a hanging thought (i.e., These descriptors are defined using the) and that was the end.

I am looking for any information that anyone can give me about writing a USB device driver that has to be run in User Space.

Thanks,
John V.

alain91 10-24-2007 08:04 AM

complete
 
Hello,

Here is the end of the article :



Important attributes of USB devices useful in device driver coding
Configuration and Endpoints are one of the two important descriptors of any USB device. These desciptors are defined using the “struct usb_config_descriptor” and “struct_usb_endpoint_descriptor” respectively .

dev->descriptor.idVendor : Reveals the Vendor-Id of the USB device connected to the system.

dev->descriptor.idProduct : Reveals the Product-Id of the USB device connected to the system.

dev->descriptor.iManufacturer : Reveals the name of the Manufacturer USB device connected to the system.

EndpointAddress:Combination of endpoint address and enpoint direction on a USB device.

InterfaceNumber : One of the several interfaces that is allocated to the connected USB device.

AlternateSetting:This is part of the a single interface allocated to the USB device.


Prerequites for Libusb programming
Linux system with Kernel 2.4 above series.
Proficiency in C language.
Good understanding of USB device internals.
Idea about USBFS.

rockballad 01-15-2008 08:32 PM

Can't read descriptor info
 
Thanks for the good guide. But for unknown reason, I can't read the descriptor of the USBs device. Here's the output of your example

Code:

bus/device idVendor/idProduct
002/001 0000/0000
- Unable to fetch manufacturer string
- Unable to fetch product string
- Unable to fetch serial number string
 wTotalLength: 25
 bNumInterfaces: 1
 bConfigurationValue: 1
 iConfiguration: 0
 bmAttributes: e0h
 MaxPower: 0
 bInterfaceNumber: 0
 bAlternateSetting: 0
 bNumEndpoints: 1
 bInterfaceClass: 9
 bInterfaceSubClass: 0
 bInterfaceProtocol: 0
 iInterface: 0
 bEndpointAddress: 81h
 bmAttributes: 03h
 wMaxPacketSize: 2
 bInterval: 255
 bRefresh: 0
 bSynchAddress: 0
001/003 0EA0/2168
- Unable to fetch manufacturer string
- Unable to fetch product string
 wTotalLength: 39
 bNumInterfaces: 1
 bConfigurationValue: 1
 iConfiguration: 0
 bmAttributes: 80h
 MaxPower: 100
 bInterfaceNumber: 0
 bAlternateSetting: 0
 bNumEndpoints: 3
 bInterfaceClass: 8
 bInterfaceSubClass: 6
 bInterfaceProtocol: 80
 iInterface: 0
 bEndpointAddress: 81h
 bmAttributes: 02h
 wMaxPacketSize: 512
 bInterval: 0
 bRefresh: 0
 bSynchAddress: 0
 bEndpointAddress: 02h
 bmAttributes: 02h
 wMaxPacketSize: 512
 bInterval: 0
 bRefresh: 0
 bSynchAddress: 0
 bEndpointAddress: 83h
 bmAttributes: 03h
 wMaxPacketSize: 2
 bInterval: 1
 bRefresh: 0
 bSynchAddress: 0
001/001 0000/0000
- Unable to fetch manufacturer string
- Unable to fetch product string
- Unable to fetch serial number string
 wTotalLength: 25
 bNumInterfaces: 1
 bConfigurationValue: 1
 iConfiguration: 0
 bmAttributes: e0h
 MaxPower: 0
 bInterfaceNumber: 0
 bAlternateSetting: 0
 bNumEndpoints: 1
 bInterfaceClass: 9
 bInterfaceSubClass: 0
 bInterfaceProtocol: 0
 iInterface: 0
 bEndpointAddress: 81h
 bmAttributes: 03h
 wMaxPacketSize: 4
 bInterval: 12
 bRefresh: 0
 bSynchAddress: 0

The descriptor.xxxx is not available. While I can list the USBs device info in the Fedora Terminal by
$ /sbin/lsusb

Note: I'm using Fedora 8 64-bit as a VMWare guest.

Please tell me what's wrong with it.
Thanks in advance!

airodrim 04-02-2008 02:13 AM

Hi ppl, I used a similar test program to the one of the article.

Code:

/*
 * testlibusb.c
 *
 *  Test suite program
 */

#include <stdio.h>
#include <string.h>
#include "usb.h"

#define snprintf printf

#define ID_PRODUCT 0x0200
#define ID_VENDOR 0x8235

#define CONFIGURATION 1
#define INTERFACE_ 0
#define ALTINTERFACE 0
#define TIMEOUT 5000

#define OUT_ENDPOINT 0x01
#define IN_ENDPOINT 0x82

// #define SET_ALTINTERFACE_ONCE

int verbose = 0;
unsigned char first = true;

void print_endpoint(struct usb_endpoint_descriptor *endpoint)
{
  printf("      bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
  printf("      bmAttributes:    %02xh\n", endpoint->bmAttributes);
  printf("      wMaxPacketSize:  %d\n", endpoint->wMaxPacketSize);
  printf("      bInterval:        %d\n", endpoint->bInterval);
  printf("      bRefresh:        %d\n", endpoint->bRefresh);
  printf("      bSynchAddress:    %d\n", endpoint->bSynchAddress);
}

void print_altsetting(struct usb_interface_descriptor *interface)
{
  int i;

  printf("    bInterfaceNumber:  %d\n", interface->bInterfaceNumber);
  printf("    bAlternateSetting:  %d\n", interface->bAlternateSetting);
  printf("    bNumEndpoints:      %d\n", interface->bNumEndpoints);
  printf("    bInterfaceClass:    %d\n", interface->bInterfaceClass);
  printf("    bInterfaceSubClass: %d\n", interface->bInterfaceSubClass);
  printf("    bInterfaceProtocol: %d\n", interface->bInterfaceProtocol);
  printf("    iInterface:        %d\n", interface->iInterface);

  for (i = 0; i < interface->bNumEndpoints; i++)
    print_endpoint(&interface->endpoint[i]);
}

void print_interface(struct usb_interface *interface)
{
  int i;

  for (i = 0; i < interface->num_altsetting; i++)
    print_altsetting(&interface->altsetting[i]);
}

void print_configuration(struct usb_config_descriptor *config)
{
  int i;

  printf("  wTotalLength:        %d\n", config->wTotalLength);
  printf("  bNumInterfaces:      %d\n", config->bNumInterfaces);
  printf("  bConfigurationValue:  %d\n", config->bConfigurationValue);
  printf("  iConfiguration:      %d\n", config->iConfiguration);
  printf("  bmAttributes:        %02xh\n", config->bmAttributes);
  printf("  MaxPower:            %d\n", config->MaxPower);

  for (i = 0; i < config->bNumInterfaces; i++)
    print_interface(&config->interface[i]);
}

int print_device(struct usb_device *dev, int level)
{
  usb_dev_handle *udev;
  char description[256];
  char string[256];
  int ret, i;

  udev = usb_open(dev);
  if (udev) {
    if (dev->descriptor.iManufacturer) {
      ret = usb_get_string_simple(udev, dev->descriptor.iManufacturer, string, sizeof(string));
      if (ret > 0)
        snprintf(description, sizeof(description), "%s - ", string);
      else
        snprintf(description, sizeof(description), "%04X - ",
                dev->descriptor.idVendor);
    } else
      snprintf(description, sizeof(description), "%04X - ",
              dev->descriptor.idVendor);

    if (dev->descriptor.iProduct) {
      ret = usb_get_string_simple(udev, dev->descriptor.iProduct, string, sizeof(string));
      if (ret > 0)
        snprintf(description + strlen(description), sizeof(description) -
                strlen(description), "%s", string);
      else
        snprintf(description + strlen(description), sizeof(description) -
                strlen(description), "%04X", dev->descriptor.idProduct);
    } else
      snprintf(description + strlen(description), sizeof(description) -
              strlen(description), "%04X", dev->descriptor.idProduct);

  } else
    snprintf(description, sizeof(description), "%04X - %04X",
            dev->descriptor.idVendor, dev->descriptor.idProduct);

  printf("%.*sDev #%d: %s\n", level * 2, "                    ", dev->devnum,
        description);

  if (udev && verbose) {
    if (dev->descriptor.iSerialNumber) {
      ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string));
      if (ret > 0)
        printf("%.*s  - Serial Number: %s\n", level * 2,
              "                    ", string);
    }
  }

  if (udev)
    usb_close(udev);

  if (verbose) {
    if (!dev->config) {
      printf("  Couldn't retrieve descriptors\n");
      return 0;
    }

    for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
      print_configuration(&dev->config[i]);
  } else {
    for (i = 0; i < dev->num_children; i++)
      print_device(dev->children[i], level + 1);
  }

  return 0;
}

int read(struct usb_dev_handle *handle)
{
        if (usb_claim_interface(handle, INTERFACE_) < 0) {
                printf("error on usb_claim_interface: %s\n", usb_strerror());
                return -1;
        }
        printf("usb_claim_interface successful\n");
#ifdef SET_ALTINTERFACE_ONCE
        if (first) {
                first = false;
#endif
                if (usb_set_altinterface(handle, ALTINTERFACE) < 0){
                        printf("usb_set_altinterface failed: %s\n", usb_strerror());
                }
#ifdef SET_ALTINTERFACE_ONCE
        }
#endif
       
        int size = 512, res;
        char *data = (char *) malloc(size*sizeof(char));
        res = usb_bulk_read(handle, IN_ENDPOINT, data, size, TIMEOUT);
        if (res < 0){
                printf("usb_bulk_read failed: %s\n", usb_strerror());
        }
        printf("usb_bulk_read: %d bytes read: ", res);
        for (int i = 0; i < res; ++i) {
                printf("%3x ", data[i]);
        }
        printf("\n");
       
        usb_release_interface(handle, INTERFACE_);
        free(data);
}

int write(struct usb_dev_handle *handle)
{
        int size = 12;
        char *data = (char *) malloc(size*sizeof(char));
        data[0] = 0x33;
        data[1] = 0x5B;
        data[2] = 0x02;
        data[3] = 0x01;
        data[4] = 0x00;
        data[5] = 0x05;
        data[6] = 0x01;
        data[7] = 0x03;
        data[8] = 0x07;
        data[9] = 0x0F;
        data[10] = 0x7F;
        data[11] = 0x1F;
        // data = {0x33, 0x5B, 0x02, 0x01, 0x00, 0x05, 0x01, 0x03, 0x07, 0x0F, 0x7F, 0x1F};

        if (usb_claim_interface(handle, INTERFACE_) < 0) {
                printf("error on usb_claim_interface: %s\n", usb_strerror());
                return -1;
        }
        printf("usb_claim_interface successful\n");
#ifdef SET_ALTINTERFACE_ONCE
        if (first) {
                first = false;
#endif
                if (usb_set_altinterface(handle, ALTINTERFACE) < 0){
                        printf("usb_set_altinterface failed: %s\n", usb_strerror());
                }
#ifdef SET_ALTINTERFACE_ONCE
        }
#endif

        printf("usb_bulk_write: writing %d bytes: ", size);
        for (int i = 0; i < size; ++i) {
                printf("%3x ", data[i]);
        }
        printf("\n");
       
        int res = usb_bulk_write(handle, OUT_ENDPOINT, data, size, TIMEOUT);
        if (res < 0){
                printf("usb_bulk_write failed: %s\n", usb_strerror());
                return -1;
        }
       
        printf("usb_bulk_write: %d bytes written\n", res);
       
        usb_release_interface(handle, INTERFACE_);
        free(data);
}

int readWrite(struct usb_dev_handle *handle)
{
       
        int size = 512;
        char *data = (char *) malloc(size*sizeof(char));
       
        printf("type a string...\n");
        scanf("%s", data);        // Get a string
       
        if (usb_claim_interface(handle, INTERFACE_) < 0) {
                printf("error on usb_claim_interface: %s\n", usb_strerror());
                system("PAUSE");
                return -1;
        }
        printf("usb_claim_interface successful\n");
#ifdef SET_ALTINTERFACE_ONCE
        if (first) {
                first = false;
#endif
                if (usb_set_altinterface(handle, ALTINTERFACE) < 0){
                        printf("usb_set_altinterface failed: %s\n", usb_strerror());
                }
#ifdef SET_ALTINTERFACE_ONCE
        }
#endif
       
        if (usb_bulk_write(handle, OUT_ENDPOINT, data, strlen(data), 3000) < 0){
                printf("usb_bulk_write failed: %s\n", usb_strerror());
                system("PAUSE");
                return -1;
        }
       
        strcpy(data, "12345678901234567890");
        printf("%s\n", "read data");
        if (usb_bulk_read(handle, IN_ENDPOINT, data, size, 3000) < 0){
                printf("usb_bulk_read failed: %s\n", usb_strerror());
        }
        printf("output %d, %s\n", size, data);
//        for (int i = 0; i < size; ++i) {
//                printf("%4x ", data[i]);
//        }
       
        usb_release_interface(handle, INTERFACE_);
        free(data);
}

int readWriteLoop(struct usb_dev_handle *handle)
{
        int NOF_LOOPS = 20;
        int size = 12;
        char *data = (char *) malloc(size*sizeof(char));
        data[0] = 0x33;
        data[1] = 0x5B;
        data[2] = 0x02;
        data[3] = 0x01;
        data[4] = 0x00;
        data[5] = 0x05;
        data[6] = 0x01;
        data[7] = 0x03;
        data[8] = 0x07;
        data[9] = 0x0F;
        data[10] = 0x7F;
        data[11] = 0x1F;
        // data = {0x33, 0x5B, 0x02, 0x01, 0x00, 0x05, 0x01, 0x03, 0x07, 0x0F, 0x7F, 0x1F};

        if (usb_claim_interface(handle, INTERFACE_) < 0) {
                printf("error on usb_claim_interface: %s\n", usb_strerror());
                return -1;
        }
        printf("usb_claim_interface successful\n");
#ifdef SET_ALTINTERFACE_ONCE
        if (first) {
                first = false;
#endif
                if (usb_set_altinterface(handle, ALTINTERFACE) < 0){
                        printf("usb_set_altinterface failed: %s\n", usb_strerror());
                }
#ifdef SET_ALTINTERFACE_ONCE
        }
#endif

        printf("usb_bulk_write: writing %d bytes: ", size);
        for (int i = 0; i < size; ++i) {
                printf("%3x ", data[i]);
        }
        printf("\n------------------------\n");
       
        for (int var = 0; var < NOF_LOOPS; ++var) {
               
                int res = usb_bulk_write(handle, OUT_ENDPOINT, data, size, TIMEOUT);
                if (res < 0){
                        printf("usb_bulk_write failed: %s\n", usb_strerror());
                        return -1;
                }
               
                printf("usb_bulk_write: %d bytes written\n", res);

                int size = 64;
                char *data = (char *) malloc(size*sizeof(char));
                res = usb_bulk_read(handle, IN_ENDPOINT, data, size, TIMEOUT);
                if (res < 0){
                        printf("usb_bulk_read failed: %s\n", usb_strerror());
                }
                printf("usb_bulk_read: %d bytes read: ", res);
                for (int i = 0; i < res; ++i) {
                        printf("%3x ", data[i]);
                }
                printf("\n");
        }
       
        usb_release_interface(handle, INTERFACE_);
        free(data);
}

void logDevices()
{
        struct usb_bus *bus;
       
        printf("log devices...\n");
        for (bus = usb_get_busses(); bus; bus = bus->next) {
                if (bus->root_dev && !verbose)
                        print_device(bus->root_dev, 0);
                else {
                        struct usb_device *dev;
       
                        for (dev = bus->devices; dev; dev = dev->next)
                        print_device(dev, 0);
                }
        }
}

int main(int argc, char *argv[])
{
        struct usb_bus *bus;
        struct usb_device *dev;
        struct usb_dev_handle *handle;
 
        bool run = true;

        if (argc > 1 && !strcmp(argv[1], "-v"))
                verbose = 1;

        usb_set_debug(255);
       
        printf("initialize libraray, find busses and devices\n");
        usb_init();

        usb_find_busses();
        usb_find_devices();
       
        if (verbose)
                logDevices();

        int size = 512;
        char *data = (char *) malloc(size*sizeof(char));

        printf("Search for device with idVendor 0x%x and idProduct 0x%x\n", ID_VENDOR, ID_PRODUCT);
        for (bus = usb_get_busses(); bus; bus = bus->next) {
                if (verbose)
                        printf("Found bus %s\n", bus->dirname);
                for (dev = bus->devices; dev; dev = dev->next) {
                        if (verbose)
                                printf("Found device with idVendor 0x%x and idProduct 0x%x\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
                        if ((dev->descriptor.idProduct == ID_PRODUCT) && (dev->descriptor.idVendor == ID_VENDOR)){
                                printf("Device found -> open\n");
                                handle = usb_open(dev);
                                if (!handle) {
                                        printf("invalid handle: %s\n", usb_strerror());
                                        system("PAUSE");
                                        return -1;
                                }
                                printf("Set configuration\n");
                                if (usb_set_configuration(handle, CONFIGURATION) < 0) {
                                          printf("error on usb_set_configuration: %s\n", usb_strerror());
                                          system("PAUSE");
                                          return -1;
                                  }

                                printf("Set altinterface (must failed)\n");
#ifdef SET_ALTINTERFACE_ONCE
                                if (first) {
                                        first = false;
#endif
                                        if (usb_set_altinterface(handle, ALTINTERFACE) < 0){
                                                printf("usb_set_altinterface failed: %s\n", usb_strerror());
                                        }
#ifdef SET_ALTINTERFACE_ONCE
                                }
#endif
                                 
                                  printf("w=write, r=read, x=exit, t=write+read, u=write+read(2), l=r/w loop, z=reset and open\n");
       
                                while (run) {
                                          scanf("%s", data);
                                         
                                    switch (data[0]) {
                                                case 'w':        // write
                                                        write(handle);
                                                        break;
                                                case 'r':        // read
                                                        read(handle);
                                                        break;
                                                case 'x':        // exit
                                                        run = false;
                                                        break;
                                                case 't':        // write + read
                                                        if (write(handle)) {
                                                                read(handle);
                                                        }
                                                        break;
                                                case 'u':        // write + read
                                                        readWrite(handle);
                                                        break;
                                                case 'l':        // loop
                                                        readWriteLoop(handle);
                                                        break;
                                                case 's':        // reset first flag (set_altinterface())
                                                        first = true;
                                                        break;
                                                case 'z':        // reset and open
                                                        usb_reset(handle);
                                                        handle = usb_open(dev);
                                                        break;
                                                default:
                                                        break;
                                        }
                                  }
                                  printf("\ndone\n");
                          }
                  }
        }
        free(data);
        system("PAUSE");

        return 1;
}

I executed it as root under Fedora core 5, I can list the usb buses but no the devices. The output is

Code:

usb_set_debug: Setting debugging level to 255 (on)
initialize libraray, find busses and devices
usb_os_init: Found USB VFS at /dev/bus/usb
usb_os_find_busses: Found 005
usb_os_find_busses: Found 004
usb_os_find_busses: Found 003
usb_os_find_busses: Found 002
usb_os_find_busses: Found 001
usb_os_find_busses: Skipping non bus directory devices
usb_os_find_devices: Found 004 on 005
skipped 1 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 005
error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Found 001 on 004
usb_os_find_devices: Found 001 on 003
usb_os_find_devices: Found 002 on 002
skipped 1 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 002
error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Found 001 on 001
log devices...
Search for device with idVendor 0x8235 and idProduct 0x200
Found bus 005
Found bus 004
Found bus 003
Found bus 002
Found bus 001
sh: PAUSE: command not found

Does any one know what could it be the problem?

thx

lionfish0 07-26-2008 05:58 AM

rockballad, try running the program as root.

rockballad 07-27-2008 08:18 PM

Quote:

Originally Posted by lionfish0 (Post 3226762)
rockballad, try running the program as root.

Yes, I'm finished this. I'm trying to write a kernel version. But it seems hard for me.

Thanks

reldon 02-21-2009 12:44 AM

missing includes
 
I put the following includes to get the program to work

#include <stdio.h>
#include <usb.h>


Under Ubuntu linux you must compile using sudo as well as run the program using sudo to get it to work..

this is a good starting article.

linux.sridhark 05-03-2009 11:18 PM

Sri
 
Man! A worthy tutorial.

udellally 07-19-2009 10:10 AM

Hi.
I wrote a shell-prog that communicates a selfmade USB-device using the libusb.
It works fine, but I only can use the prog if I am logged in as root. Every other user gets the message, that there is no device connected, but without changing anything root can control it.
I tried to "chmod 777" all the libusb-files in /usr/lib/, but that did not work, too.
Has anyone of you a clue, what the problem could be?
Thanks.

mr805newbie 08-08-2009 12:24 AM

Is there some fort of GUI for this?

Quote:

gcc -o usbdevice_details testlibusb.c -I/usr/local/include -L. -lnsl -lm -lc -L/usr/local/lib -lusb
Is like huh...... for use newbs.

reinoud 08-11-2009 04:27 PM

Compile problem
 
I tried to compile teslibusb.c:
gcc -o usbdevice_details testlibusb.c -I/usr/local/include -L. -lnsl -lm -lc -L/usr/local/lib -lusb
However i get:
testlibusb.c:27: error: 'true' undeclared here (not in a function)
testlibusb.c:146: error: conflicting types for 'read'
/usr/include/unistd.h:312: error: previous declaration of 'read' was here
testlibusb.c: In function 'read':
testlibusb.c:170: error: 'for' loop initial declaration used outside C99 mode
testlibusb.c: At top level:
testlibusb.c:180: error: conflicting types for 'write'
/usr/include/unistd.h:318: error: previous declaration of 'write' was here
testlibusb.c: In function 'write':
testlibusb.c:214: error: 'for' loop initial declaration used outside C99 mode
testlibusb.c: In function 'readWriteLoop':
testlibusb.c:313: error: 'for' loop initial declaration used outside C99 mode
testlibusb.c:318: error: 'for' loop initial declaration used outside C99 mode
testlibusb.c:335: error: 'for' loop initial declaration used outside C99 mode
testlibusb.c: In function 'main':
testlibusb.c:368: error: 'bool' undeclared (first use in this function)
testlibusb.c:368: error: (Each undeclared identifier is reported only once
testlibusb.c:368: error: for each function it appears in.)
testlibusb.c:368: error: expected ';' before 'run'
testlibusb.c:423: error: 'run' undeclared (first use in this function)
testlibusb.c:434: error: 'false' undeclared (first use in this function)
testlibusb.c:466:2: warning: no newline at end of file

Is there a version that compiles out of the box?

reinoud 08-11-2009 06:30 PM

compiler warnings fixed
 
Most Compiler problems fixed by including:

stdbool.h (otherwise it doesn't know bool and true) and string.h (to remedy warnings about strlen)
Also, in C99 i can't use for (int i=0 bla bla)
first define int i; for (i=0 blabla) does the job.

Also rename read to read_from_device and write to write_to_device

muthumb14 03-23-2010 07:15 AM

What about applications development
 
yes I agree that we can detaect the mounted USB through LIBUSB, could we write the program to detect the FILEs in the USB and to opne the FILEs etc..

Rgds,
Muthu

arkroan 11-18-2010 02:38 AM

Quote:

Configuration and Endpoints are one of the two important descriptors of any USB device. These descriptors are defined using the
Does this guide end at this point?? I am not able to see any more of it.

arkroan 11-18-2010 02:52 AM

Quote:

Originally Posted by alain91 (Post 2934908)
Hello,

Here is the end of the article :



Important attributes of USB devices useful in device driver coding
Configuration and Endpoints are one of the two important descriptors of any USB device. These desciptors are defined using the “struct usb_config_descriptor” and “struct_usb_endpoint_descriptor” respectively .

dev->descriptor.idVendor : Reveals the Vendor-Id of the USB device connected to the system.

dev->descriptor.idProduct : Reveals the Product-Id of the USB device connected to the system.

dev->descriptor.iManufacturer : Reveals the name of the Manufacturer USB device connected to the system.

EndpointAddress:Combination of endpoint address and enpoint direction on a USB device.

InterfaceNumber : One of the several interfaces that is allocated to the connected USB device.

AlternateSetting:This is part of the a single interface allocated to the USB device.


Prerequites for Libusb programming
Linux system with Kernel 2.4 above series.
Proficiency in C language.
Good understanding of USB device internals.
Idea about USBFS.

Oh now i see it.. Sorry for the previous post.

dollysingh 07-17-2012 07:36 AM

Output is same for all usb drive.
 
Hi,

I compiled the code.
I run it for 2 different pen drives but in both case I got the same output.
Manufacture name is not right and same output is repeated lot of times.

Output goes like this:

bus/device idVendor/idProduct
008/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.2
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
007/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
006/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.0
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
005/002 08FF/2810
- Product : Fingerprint Sensor
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: a0h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 8
bInterval: 0
bRefresh: 0
bSynchAddress: 0
005/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.2
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
004/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
003/006 413C/8156
- Manufacturer : Dell Computer Corp
- Product : Dell Wireless 370 Bluetooth Mini-card
wTotalLength: 216
bNumInterfaces: 4
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 3
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 16
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 82h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 0
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 0
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 1
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 9
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 9
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 2
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 17
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 17
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 3
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 4
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 5
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 2
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 84h
bmAttributes: 02h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 04h
bmAttributes: 02h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 3
bAlternateSetting: 0
bNumEndpoints: 0
bInterfaceClass: 254
bInterfaceSubClass: 1
bInterfaceProtocol: 0
iInterface: 0
003/004 413C/8158
wTotalLength: 62
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 1
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 3
bInterfaceSubClass: 1
bInterfaceProtocol: 2
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 10
bRefresh: 0
bSynchAddress: 0
003/003 413C/8157
wTotalLength: 34
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 1
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 3
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 8
bInterval: 10
bRefresh: 0
bSynchAddress: 0
003/002 0A5C/4500
- Manufacturer : Broadcom
- Product : BCM2046B1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 47
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 1
bInterval: 255
bRefresh: 0
bSynchAddress: 0
003/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.0
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
002/003 058F/6387
- Manufacturer : Generic
- Product : Mass Storage
- Serial Number: 1180FF3A
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 8
bInterfaceSubClass: 6
bInterfaceProtocol: 80
iInterface: 0
bEndpointAddress: 01h
bmAttributes: 02h
wMaxPacketSize: 512
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 82h
bmAttributes: 02h
wMaxPacketSize: 512
bInterval: 0
bRefresh: 0
bSynchAddress: 0
002/001 1D6B/0002
- Manufacturer : Linux 2.6.38.8-customc ehci_hcd
- Product : EHCI Host Controller
- Serial Number: 0000:00:1d.7
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 12
bRefresh: 0
bSynchAddress: 0
001/004 05CA/18A0
- Manufacturer : Ricoh co. Ltd.
- Product : Integrated Webcam
- Serial Number: CN0TX6137248789NAHC8
wTotalLength: 1144
bNumInterfaces: 2
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 1
bInterfaceProtocol: 0
iInterface: 2
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 64
bInterval: 16
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 0
bNumEndpoints: 0
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bInterfaceNumber: 1
bAlternateSetting: 1
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5076
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 2
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 4976
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 3
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 968
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 4
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 632
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 5
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 800
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 6
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 7
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 8
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 9
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 10
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5052
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 11
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 4956
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 12
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 840
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 13
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 624
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 14
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 700
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 15
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 16
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 17
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 18
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
001/001 1D6B/0002
- Manufacturer : Linux 2.6.38.8-customc ehci_hcd
- Product : EHCI Host Controller
- Serial Number: 0000:00:1a.7
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 12
bRefresh: 0
bSynchAddress: 0
"

Please help !

dollysingh 07-17-2012 08:15 AM

Hi,

I compiled the code.
I run it for 2 different pen drives but in both case I got the same output.
Manufacture name is not right and same output is repeated lot of times.

Output goes like this:

bus/device idVendor/idProduct
008/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.2
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
007/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
006/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.0
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
005/002 08FF/2810
- Product : Fingerprint Sensor
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: a0h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 8
bInterval: 0
bRefresh: 0
bSynchAddress: 0
005/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.2
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
004/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
003/006 413C/8156
- Manufacturer : Dell Computer Corp
- Product : Dell Wireless 370 Bluetooth Mini-card
wTotalLength: 216
bNumInterfaces: 4
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 3
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 16
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 82h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 0
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 0
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 1
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 9
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 9
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 2
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 17
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 17
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 3
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 4
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 5
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 2
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 84h
bmAttributes: 02h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 04h
bmAttributes: 02h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 3
bAlternateSetting: 0
bNumEndpoints: 0
bInterfaceClass: 254
bInterfaceSubClass: 1
bInterfaceProtocol: 0
iInterface: 0
003/004 413C/8158
wTotalLength: 62
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 1
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 3
bInterfaceSubClass: 1
bInterfaceProtocol: 2
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 10
bRefresh: 0
bSynchAddress: 0
003/003 413C/8157
wTotalLength: 34
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 1
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 3
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 8
bInterval: 10
bRefresh: 0
bSynchAddress: 0
003/002 0A5C/4500
- Manufacturer : Broadcom
- Product : BCM2046B1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 47
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 1
bInterval: 255
bRefresh: 0
bSynchAddress: 0
003/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.0
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
002/003 058F/6387
- Manufacturer : Generic
- Product : Mass Storage
- Serial Number: 1180FF3A
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 8
bInterfaceSubClass: 6
bInterfaceProtocol: 80
iInterface: 0
bEndpointAddress: 01h
bmAttributes: 02h
wMaxPacketSize: 512
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 82h
bmAttributes: 02h
wMaxPacketSize: 512
bInterval: 0
bRefresh: 0
bSynchAddress: 0
002/001 1D6B/0002
- Manufacturer : Linux 2.6.38.8-customc ehci_hcd
- Product : EHCI Host Controller
- Serial Number: 0000:00:1d.7
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 12
bRefresh: 0
bSynchAddress: 0
001/004 05CA/18A0
- Manufacturer : Ricoh co. Ltd.
- Product : Integrated Webcam
- Serial Number: CN0TX6137248789NAHC8
wTotalLength: 1144
bNumInterfaces: 2
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 1
bInterfaceProtocol: 0
iInterface: 2
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 64
bInterval: 16
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 0
bNumEndpoints: 0
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bInterfaceNumber: 1
bAlternateSetting: 1
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5076
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 2
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 4976
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 3
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 968
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 4
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 632
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 5
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 800
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 6
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 7
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 8
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 9
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 10
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5052
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 11
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 4956
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 12
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 840
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 13
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 624
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 14
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 700
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 15
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 16
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 17
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 18
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
001/001 1D6B/0002
- Manufacturer : Linux 2.6.38.8-customc ehci_hcd
- Product : EHCI Host Controller
- Serial Number: 0000:00:1a.7
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 12
bRefresh: 0
bSynchAddress: 0
"

Please help !

dollysingh 07-17-2012 08:17 AM

Output is same for all usb drive.
 
Hi,

I compiled the code.
I run it for 2 different pen drives but in both case I got the same output.
Manufacture name is not right and same output is repeated lot of times.

Output goes like this:

bus/device idVendor/idProduct
008/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.2
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
007/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
006/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1d.0
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
005/002 08FF/2810
- Product : Fingerprint Sensor
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: a0h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 8
bInterval: 0
bRefresh: 0
bSynchAddress: 0
005/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.2
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
004/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
003/006 413C/8156
- Manufacturer : Dell Computer Corp
- Product : Dell Wireless 370 Bluetooth Mini-card
wTotalLength: 216
bNumInterfaces: 4
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 3
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 16
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 82h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 0
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 0
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 1
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 9
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 9
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 2
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 17
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 17
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 3
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 4
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 5
bNumEndpoints: 2
bInterfaceClass: 224
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 83h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 03h
bmAttributes: 01h
wMaxPacketSize: 64
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 2
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 84h
bmAttributes: 02h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 04h
bmAttributes: 02h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 3
bAlternateSetting: 0
bNumEndpoints: 0
bInterfaceClass: 254
bInterfaceSubClass: 1
bInterfaceProtocol: 0
iInterface: 0
003/004 413C/8158
wTotalLength: 62
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 1
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 3
bInterfaceSubClass: 1
bInterfaceProtocol: 2
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 10
bRefresh: 0
bSynchAddress: 0
003/003 413C/8157
wTotalLength: 34
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 1
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 3
bInterfaceSubClass: 1
bInterfaceProtocol: 1
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 8
bInterval: 10
bRefresh: 0
bSynchAddress: 0
003/002 0A5C/4500
- Manufacturer : Broadcom
- Product : BCM2046B1
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 47
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 1
bInterval: 255
bRefresh: 0
bSynchAddress: 0
003/001 1D6B/0001
- Manufacturer : Linux 2.6.38.8-customc uhci_hcd
- Product : UHCI Host Controller
- Serial Number: 0000:00:1a.0
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 2
bInterval: 255
bRefresh: 0
bSynchAddress: 0
002/003 058F/6387
- Manufacturer : Generic
- Product : Mass Storage
- Serial Number: 1180FF3A
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 8
bInterfaceSubClass: 6
bInterfaceProtocol: 80
iInterface: 0
bEndpointAddress: 01h
bmAttributes: 02h
wMaxPacketSize: 512
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 82h
bmAttributes: 02h
wMaxPacketSize: 512
bInterval: 0
bRefresh: 0
bSynchAddress: 0
002/001 1D6B/0002
- Manufacturer : Linux 2.6.38.8-customc ehci_hcd
- Product : EHCI Host Controller
- Serial Number: 0000:00:1d.7
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 12
bRefresh: 0
bSynchAddress: 0
001/004 05CA/18A0
- Manufacturer : Ricoh co. Ltd.
- Product : Integrated Webcam
- Serial Number: CN0TX6137248789NAHC8
wTotalLength: 1144
bNumInterfaces: 2
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 1
bInterfaceProtocol: 0
iInterface: 2
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 64
bInterval: 16
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 0
bNumEndpoints: 0
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bInterfaceNumber: 1
bAlternateSetting: 1
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5076
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 2
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 4976
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 3
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 968
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 4
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 632
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 5
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 800
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 6
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 7
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 8
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5100
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 9
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 10
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5052
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 11
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 4956
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 12
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 840
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 13
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 624
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 14
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 700
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 15
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 16
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 17
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 1
bAlternateSetting: 18
bNumEndpoints: 1
bInterfaceClass: 14
bInterfaceSubClass: 2
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 82h
bmAttributes: 05h
wMaxPacketSize: 5120
bInterval: 1
bRefresh: 0
bSynchAddress: 0
001/001 1D6B/0002
- Manufacturer : Linux 2.6.38.8-customc ehci_hcd
- Product : EHCI Host Controller
- Serial Number: 0000:00:1a.7
wTotalLength: 25
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 0
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 9
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 4
bInterval: 12
bRefresh: 0
bSynchAddress: 0
"

Please help !

Quote:

Originally Posted by alain91 (Post 2934908)
Hello,

Here is the end of the article :



Important attributes of USB devices useful in device driver coding
Configuration and Endpoints are one of the two important descriptors of any USB device. These desciptors are defined using the “struct usb_config_descriptor” and “struct_usb_endpoint_descriptor” respectively .

dev->descriptor.idVendor : Reveals the Vendor-Id of the USB device connected to the system.

dev->descriptor.idProduct : Reveals the Product-Id of the USB device connected to the system.

dev->descriptor.iManufacturer : Reveals the name of the Manufacturer USB device connected to the system.

EndpointAddress:Combination of endpoint address and enpoint direction on a USB device.

InterfaceNumber : One of the several interfaces that is allocated to the connected USB device.

AlternateSetting:This is part of the a single interface allocated to the USB device.


Prerequites for Libusb programming
Linux system with Kernel 2.4 above series.
Proficiency in C language.
Good understanding of USB device internals.
Idea about USBFS.


kimi_2019 10-17-2019 02:54 AM

is it possible to use libusb when your performed as an USB device?
 
In your case, you use libusb as a host. Is it possible to use libusb when you are an USB device?


All times are GMT -5. The time now is 05:45 PM.