sdaau
2012-10-27 08:36:48 UTC
Hi all,
I am trying to communicate with a device from Linux, and I'm experiencing a specific problem - with usblib-1.0 unable to retrieve the configuration from a device, while usblib 0.1 is able to do so (on the same computer and OS). Apologies for a slightly longer mail while I explain.
First of all, here are some infos on my PC:
$ cat /etc/issue
Ubuntu 11.04 \n \l
$ uname -a
Linux ljutntcol 2.6.38-16-generic #67-Ubuntu SMP Thu Sep 6 18:00:43 UTC 2012 i686 i686 i386 GNU/Linux
$ apt-show-versions -r libusb
libusb-0.1-4/natty uptodate 2:0.1.12-17
libusb-1.0-0/natty uptodate 2:1.0.8-2
libusb-1.0-0-dev/natty uptodate 2:1.0.8-2
libusb-dev/natty uptodate 2:0.1.12-17
libusbmuxd1/natty uptodate 1.0.7-1ubuntu0.11.04.1
$ gcc --version
gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
The device I'm trying to connect to (an oscilloscope; more info follows later) apparently doesn't have a driver for linux. I first tried to write a small application that includes <usb.h> - that is, which uses libusb 0.1 - based on the example in http://pvrusb2.dax.nu/ ... That application was able to connect to device, retrieve configuration settings, and send and retrieve data to and from the device via endpoints -- except that the responses I got from the device were wrong (had a correct header, but didn't carry correct data).
So, I thought I'd double check, by rewriting my small application, this time for libusb-1.0. Everything seems to function (although didn't check reading in via endpoint); except when one comes to this part in the code, where I was trying to retrieve the config descriptor:
...
struct libusb_config_descriptor *configDesc ;
...
// this line fails with "error [parse_endpoint] invalid descriptor length 0"
// r = libusb_get_config_descriptor(dev, 0x00, &configDesc);
// this line fails with response -5 (LIBUSB_ERROR_NOT_FOUND)
// r = libusb_get_config_descriptor(dev, 0x01, &configDesc);
// note; this device in lsusb shows: ...
// bNumInterfaces 1
// bConfigurationValue 1
// iConfiguration 0
// ...
// so I thought, maybe better to just ask for 'active'
// config descriptor - instead of specifying one
// explicitly myself:
r = libusb_get_active_config_descriptor(dev, &configDesc);
if (r < 0) {
fprintf(stderr, "failed to get config descriptor (%d)\n", r);
return;
}
Well, also here I got "failed to get config descriptor", but since I couldn't get any further, I had to get more debugging information. So I tried adding libusb_set_debug(NULL, 3); in the code - then it turns out that libusb-1.0 needs to be re-built from source, to --enable-debug-log. So this is what I did:
$ git clone http://git.libusb.org/libusb.git libusb-1.0
Cloning into libusb-1.0...
...
$ cd libusb-1.0/
$ ./autogen.sh # also runs ./configure
$ make
...
$ ./examples/listdevs # run example program - debug works:
libusb: 0.000000 debug [libusb_init] libusb-1.0.9 git:1.0.9-28-g7634714
...
Then, I tried recompiling my test program against the static version of this library:
$ gcc -g myTestProg.c libusb-1.0/libusb/.libs/libusb-1.0.a -I./libusb-1.0/libusb -lpthread -lrt -o myTestProg
... and could finally retrieve the following debug info. for the offending libusb_get_active_config_descriptor:
$ ./myTestProg
...
Got device from handle
libusb: 0.006148 debug [libusb_reset_device]
libusb: 0.286630 debug [libusb_set_configuration] configuration 1
libusb: 0.295627 debug [libusb_get_active_config_descriptor]
libusb: 0.295837 debug [sysfs_get_active_config_descriptor] active configuration 1
libusb: 0.296054 debug [sysfs_get_active_config_descriptor] active configuration 1
libusb: 0.296158 error [sysfs_get_active_config_descriptor] short read 40/49
failed to get config descriptor (-1)
So, I'm basically down to LIBUSB_ERROR_IO = -1, because of a "short read 40/49", when trying to do sysfs_get_active_config_descriptor.
Now, all I want to do here with the config descriptor, is retrieve the number of endpoints, and possibly their adresses. For the number of endpoints in libusb 0.1, I have used (and it worked fine):
...
struct usb_device *dev = NULL;
int numeps = 0;
...
dev = find_first_device();
...
numeps = dev->config[0].interface[0].altsetting[0].bNumEndpoints;
... while in libusb-1.0; apparently (via http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/) one has to use:
...
struct libusb_config_descriptor *configDesc ;
const struct libusb_interface *inter;
const struct libusb_interface_descriptor *interdesc;
...
// r = libusb_get_config_descriptor(dev, 0, &configDesc);
r = libusb_get_active_config_descriptor(dev, &configDesc);
inter = &configDesc->interface[0];
interdesc = &inter->altsetting[0];
numeps = (int)interdesc->bNumEndpoints;
... thus, I have to first retrieve the config descriptor for libusb-1.0, before I can retrieve number of endpoints; and that is where the process dies.
*********
At this point, I started wondering - how come in this program, config descriptor retrieval fails - while the `lsusb` program can show the number of endpoints properly?
So I thought, I should try rebuilding the Ubuntu version of `lsusb` (from the `usbutils` package); and try rebuilding the latest `lsusb` from git. Turns out, the Ubuntu version uses <usb.h> and builds against libusb-dev, which is actually libusb 0.1(.4) - while the one from git uses <libusb.h> and builds aganst libusb-1.0-0-dev packages in Ubuntu (I didn't want to mess with config files, to force the git `lsusb` version to build against the git `libusb-1.0` version of the library [which was built previously]).
So this is basically what I did to build the Ubuntu version of `lsusb`:
$ apt-get source usbutils
...
usbutils-0.87/usb.ids
$ cd usbutils-0.87/
$ ./configure
...
usbutils 0.87
============= ...
compiler: gcc
cflags: -g -O2
ldflags:
$ make V=1 lsusb # V=1 disables "silent make mode" from Automake
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-lsusb.o -MD -MP -MF .deps/lsusb-lsusb.Tpo -c -o lsusb-lsusb.o `test -f 'lsusb.c' || echo './'`lsusb.c
mv -f .deps/lsusb-lsusb.Tpo .deps/lsusb-lsusb.Po
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-lsusb-t.o -MD -MP -MF .deps/lsusb-lsusb-t.Tpo -c -o lsusb-lsusb-t.o `test -f 'lsusb-t.c' || echo './'`lsusb-t.c
mv -f .deps/lsusb-lsusb-t.Tpo .deps/lsusb-lsusb-t.Po
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-names.o -MD -MP -MF .deps/lsusb-names.Tpo -c -o lsusb-names.o `test -f 'names.c' || echo './'`names.c
mv -f .deps/lsusb-names.Tpo .deps/lsusb-names.Po
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-devtree.o -MD -MP -MF .deps/lsusb-devtree.Tpo -c -o lsusb-devtree.o `test -f 'devtree.c' || echo './'`devtree.c
mv -f .deps/lsusb-devtree.Tpo .deps/lsusb-devtree.Po
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-usbmisc.o -MD -MP -MF .deps/lsusb-usbmisc.Tpo -c -o lsusb-usbmisc.o `test -f 'usbmisc.c' || echo './'`usbmisc.c
mv -f .deps/lsusb-usbmisc.Tpo .deps/lsusb-usbmisc.Po
gcc -g -O2 -Wl,--as-needed -o lsusb lsusb-lsusb.o lsusb-lsusb-t.o lsusb-names.o lsusb-devtree.o lsusb-usbmisc.o -lusb -lz
$ cd ..
... and this is what I did to build the git version of `lsusb`:
$ git clone https://github.com/gregkh/usbutils.git usbutils-git
Cloning into usbutils-git...
...
$ cd usbutils-git/
$ git submodule init
Submodule 'usbhid-dump' (git://digimend.git.sourceforge.net/gitroot/digimend/usbhid-dump.git) registered for path 'usbhid-dump'
$ git submodule update
Cloning into usbhid-dump...
...
$ autoreconf --install --symlink
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `auxdir'.
...
$ ./configure
...
usbutils 006
============= ...
compiler: gcc
cflags: -g -O2
ldflags:
$ make V=1 lsusb # V=1 disables "silent make mode" from Automake
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-lsusb.o -MD -MP -MF .deps/lsusb-lsusb.Tpo -c -o lsusb-lsusb.o `test -f 'lsusb.c' || echo './'`lsusb.c
mv -f .deps/lsusb-lsusb.Tpo .deps/lsusb-lsusb.Po
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-lsusb-t.o -MD -MP -MF .deps/lsusb-lsusb-t.Tpo -c -o lsusb-lsusb-t.o `test -f 'lsusb-t.c' || echo './'`lsusb-t.c
mv -f .deps/lsusb-lsusb-t.Tpo .deps/lsusb-lsusb-t.Po
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-names.o -MD -MP -MF .deps/lsusb-names.Tpo -c -o lsusb-names.o `test -f 'names.c' || echo './'`names.c
mv -f .deps/lsusb-names.Tpo .deps/lsusb-names.Po
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-devtree.o -MD -MP -MF .deps/lsusb-devtree.Tpo -c -o lsusb-devtree.o `test -f 'devtree.c' || echo './'`devtree.c
mv -f .deps/lsusb-devtree.Tpo .deps/lsusb-devtree.Po
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-usbmisc.o -MD -MP -MF .deps/lsusb-usbmisc.Tpo -c -o lsusb-usbmisc.o `test -f 'usbmisc.c' || echo './'`usbmisc.c
mv -f .deps/lsusb-usbmisc.Tpo .deps/lsusb-usbmisc.Po
gcc -g -O2 -Wl,--as-needed -o lsusb lsusb-lsusb.o lsusb-lsusb-t.o lsusb-names.o lsusb-devtree.o lsusb-usbmisc.o -lusb-1.0 -lz
$ cd ..
So finally, here are the results of calling of these versions of `lsusb` against the device (note, under Ubuntu `sudo` has to be used, otherwise a "cannot read device status, Operation not permitted (1)" may be generated):
$ ./usbutils-0.87/lsusb --version
lsusb (usbutils) 0.87
$ ./usbutils-git/lsusb --version
lsusb (usbutils) 006
$ sudo ./usbutils-git/lsusb -v -d f4ec:ee38
./usbutils-git/lsusb: cannot open "/usr/share/usb.ids", No such file or directory
Bus 002 Device 012: ID f4ec:ee38
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0xf4ec
idProduct 0xee38
bcdDevice 1.00
iManufacturer 1 Siglent TechCo., Ltd.
iProduct 2 USB Digital Oscilloscope
iSerial 0
bNumConfigurations 1
Couldn't get configuration descriptor 0, some information will be missing
Couldn't get configuration descriptor 0, some information will be missing
Device Status: 0x0001
Self Powered
$ sudo ./usbutils-0.87/lsusb -v -d f4ec:ee38
./usbutils-0.87/lsusb: cannot open "/usr/share/usb.ids", No such file or directory
Bus 002 Device 012: ID f4ec:ee38
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0xf4ec
idProduct 0xee38
bcdDevice 1.00
iManufacturer 1 Siglent TechCo., Ltd.
iProduct 2 USB Digital Oscilloscope
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 49
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 4
bInterfaceClass 220
bInterfaceSubClass 161
bInterfaceProtocol 181
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x86 EP 6 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x05 EP 5 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Status: 0x0001
Self Powered
Clearly, Ubuntu's lsusb (usbutils) 0.87 w/ libusb 0.1.4 can read configuration descriptor data without a problem; while lsusb (usbutils) 006 from git w/ libusb-1.0 cannot - arguably, because of the same "short read" problem.
That is about as much as I can state about the problem - would anyone have any idea why this "short read" problem happens when retrieving configuration descriptor with libusb-1.0; and how could I go around it?
Many thanks in advance for any comments,
Cheers!
I am trying to communicate with a device from Linux, and I'm experiencing a specific problem - with usblib-1.0 unable to retrieve the configuration from a device, while usblib 0.1 is able to do so (on the same computer and OS). Apologies for a slightly longer mail while I explain.
First of all, here are some infos on my PC:
$ cat /etc/issue
Ubuntu 11.04 \n \l
$ uname -a
Linux ljutntcol 2.6.38-16-generic #67-Ubuntu SMP Thu Sep 6 18:00:43 UTC 2012 i686 i686 i386 GNU/Linux
$ apt-show-versions -r libusb
libusb-0.1-4/natty uptodate 2:0.1.12-17
libusb-1.0-0/natty uptodate 2:1.0.8-2
libusb-1.0-0-dev/natty uptodate 2:1.0.8-2
libusb-dev/natty uptodate 2:0.1.12-17
libusbmuxd1/natty uptodate 1.0.7-1ubuntu0.11.04.1
$ gcc --version
gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
The device I'm trying to connect to (an oscilloscope; more info follows later) apparently doesn't have a driver for linux. I first tried to write a small application that includes <usb.h> - that is, which uses libusb 0.1 - based on the example in http://pvrusb2.dax.nu/ ... That application was able to connect to device, retrieve configuration settings, and send and retrieve data to and from the device via endpoints -- except that the responses I got from the device were wrong (had a correct header, but didn't carry correct data).
So, I thought I'd double check, by rewriting my small application, this time for libusb-1.0. Everything seems to function (although didn't check reading in via endpoint); except when one comes to this part in the code, where I was trying to retrieve the config descriptor:
...
struct libusb_config_descriptor *configDesc ;
...
// this line fails with "error [parse_endpoint] invalid descriptor length 0"
// r = libusb_get_config_descriptor(dev, 0x00, &configDesc);
// this line fails with response -5 (LIBUSB_ERROR_NOT_FOUND)
// r = libusb_get_config_descriptor(dev, 0x01, &configDesc);
// note; this device in lsusb shows: ...
// bNumInterfaces 1
// bConfigurationValue 1
// iConfiguration 0
// ...
// so I thought, maybe better to just ask for 'active'
// config descriptor - instead of specifying one
// explicitly myself:
r = libusb_get_active_config_descriptor(dev, &configDesc);
if (r < 0) {
fprintf(stderr, "failed to get config descriptor (%d)\n", r);
return;
}
Well, also here I got "failed to get config descriptor", but since I couldn't get any further, I had to get more debugging information. So I tried adding libusb_set_debug(NULL, 3); in the code - then it turns out that libusb-1.0 needs to be re-built from source, to --enable-debug-log. So this is what I did:
$ git clone http://git.libusb.org/libusb.git libusb-1.0
Cloning into libusb-1.0...
...
$ cd libusb-1.0/
$ ./autogen.sh # also runs ./configure
$ make
...
$ ./examples/listdevs # run example program - debug works:
libusb: 0.000000 debug [libusb_init] libusb-1.0.9 git:1.0.9-28-g7634714
...
Then, I tried recompiling my test program against the static version of this library:
$ gcc -g myTestProg.c libusb-1.0/libusb/.libs/libusb-1.0.a -I./libusb-1.0/libusb -lpthread -lrt -o myTestProg
... and could finally retrieve the following debug info. for the offending libusb_get_active_config_descriptor:
$ ./myTestProg
...
Got device from handle
libusb: 0.006148 debug [libusb_reset_device]
libusb: 0.286630 debug [libusb_set_configuration] configuration 1
libusb: 0.295627 debug [libusb_get_active_config_descriptor]
libusb: 0.295837 debug [sysfs_get_active_config_descriptor] active configuration 1
libusb: 0.296054 debug [sysfs_get_active_config_descriptor] active configuration 1
libusb: 0.296158 error [sysfs_get_active_config_descriptor] short read 40/49
failed to get config descriptor (-1)
So, I'm basically down to LIBUSB_ERROR_IO = -1, because of a "short read 40/49", when trying to do sysfs_get_active_config_descriptor.
Now, all I want to do here with the config descriptor, is retrieve the number of endpoints, and possibly their adresses. For the number of endpoints in libusb 0.1, I have used (and it worked fine):
...
struct usb_device *dev = NULL;
int numeps = 0;
...
dev = find_first_device();
...
numeps = dev->config[0].interface[0].altsetting[0].bNumEndpoints;
... while in libusb-1.0; apparently (via http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/) one has to use:
...
struct libusb_config_descriptor *configDesc ;
const struct libusb_interface *inter;
const struct libusb_interface_descriptor *interdesc;
...
// r = libusb_get_config_descriptor(dev, 0, &configDesc);
r = libusb_get_active_config_descriptor(dev, &configDesc);
inter = &configDesc->interface[0];
interdesc = &inter->altsetting[0];
numeps = (int)interdesc->bNumEndpoints;
... thus, I have to first retrieve the config descriptor for libusb-1.0, before I can retrieve number of endpoints; and that is where the process dies.
*********
At this point, I started wondering - how come in this program, config descriptor retrieval fails - while the `lsusb` program can show the number of endpoints properly?
So I thought, I should try rebuilding the Ubuntu version of `lsusb` (from the `usbutils` package); and try rebuilding the latest `lsusb` from git. Turns out, the Ubuntu version uses <usb.h> and builds against libusb-dev, which is actually libusb 0.1(.4) - while the one from git uses <libusb.h> and builds aganst libusb-1.0-0-dev packages in Ubuntu (I didn't want to mess with config files, to force the git `lsusb` version to build against the git `libusb-1.0` version of the library [which was built previously]).
So this is basically what I did to build the Ubuntu version of `lsusb`:
$ apt-get source usbutils
...
usbutils-0.87/usb.ids
$ cd usbutils-0.87/
$ ./configure
...
usbutils 0.87
============= ...
compiler: gcc
cflags: -g -O2
ldflags:
$ make V=1 lsusb # V=1 disables "silent make mode" from Automake
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-lsusb.o -MD -MP -MF .deps/lsusb-lsusb.Tpo -c -o lsusb-lsusb.o `test -f 'lsusb.c' || echo './'`lsusb.c
mv -f .deps/lsusb-lsusb.Tpo .deps/lsusb-lsusb.Po
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-lsusb-t.o -MD -MP -MF .deps/lsusb-lsusb-t.Tpo -c -o lsusb-lsusb-t.o `test -f 'lsusb-t.c' || echo './'`lsusb-t.c
mv -f .deps/lsusb-lsusb-t.Tpo .deps/lsusb-lsusb-t.Po
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-names.o -MD -MP -MF .deps/lsusb-names.Tpo -c -o lsusb-names.o `test -f 'names.c' || echo './'`names.c
mv -f .deps/lsusb-names.Tpo .deps/lsusb-names.Po
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-devtree.o -MD -MP -MF .deps/lsusb-devtree.Tpo -c -o lsusb-devtree.o `test -f 'devtree.c' || echo './'`devtree.c
mv -f .deps/lsusb-devtree.Tpo .deps/lsusb-devtree.Po
gcc -DHAVE_CONFIG_H -I. -DDATADIR=\"/usr/share\" -g -O2 -MT lsusb-usbmisc.o -MD -MP -MF .deps/lsusb-usbmisc.Tpo -c -o lsusb-usbmisc.o `test -f 'usbmisc.c' || echo './'`usbmisc.c
mv -f .deps/lsusb-usbmisc.Tpo .deps/lsusb-usbmisc.Po
gcc -g -O2 -Wl,--as-needed -o lsusb lsusb-lsusb.o lsusb-lsusb-t.o lsusb-names.o lsusb-devtree.o lsusb-usbmisc.o -lusb -lz
$ cd ..
... and this is what I did to build the git version of `lsusb`:
$ git clone https://github.com/gregkh/usbutils.git usbutils-git
Cloning into usbutils-git...
...
$ cd usbutils-git/
$ git submodule init
Submodule 'usbhid-dump' (git://digimend.git.sourceforge.net/gitroot/digimend/usbhid-dump.git) registered for path 'usbhid-dump'
$ git submodule update
Cloning into usbhid-dump...
...
$ autoreconf --install --symlink
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `auxdir'.
...
$ ./configure
...
usbutils 006
============= ...
compiler: gcc
cflags: -g -O2
ldflags:
$ make V=1 lsusb # V=1 disables "silent make mode" from Automake
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-lsusb.o -MD -MP -MF .deps/lsusb-lsusb.Tpo -c -o lsusb-lsusb.o `test -f 'lsusb.c' || echo './'`lsusb.c
mv -f .deps/lsusb-lsusb.Tpo .deps/lsusb-lsusb.Po
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-lsusb-t.o -MD -MP -MF .deps/lsusb-lsusb-t.Tpo -c -o lsusb-lsusb-t.o `test -f 'lsusb-t.c' || echo './'`lsusb-t.c
mv -f .deps/lsusb-lsusb-t.Tpo .deps/lsusb-lsusb-t.Po
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-names.o -MD -MP -MF .deps/lsusb-names.Tpo -c -o lsusb-names.o `test -f 'names.c' || echo './'`names.c
mv -f .deps/lsusb-names.Tpo .deps/lsusb-names.Po
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-devtree.o -MD -MP -MF .deps/lsusb-devtree.Tpo -c -o lsusb-devtree.o `test -f 'devtree.c' || echo './'`devtree.c
mv -f .deps/lsusb-devtree.Tpo .deps/lsusb-devtree.Po
gcc -DHAVE_CONFIG_H -I. -I/usr/include/libusb-1.0 -DDATADIR=\"/usr/share\" -DHAVE_LIBZ -g -O2 -MT lsusb-usbmisc.o -MD -MP -MF .deps/lsusb-usbmisc.Tpo -c -o lsusb-usbmisc.o `test -f 'usbmisc.c' || echo './'`usbmisc.c
mv -f .deps/lsusb-usbmisc.Tpo .deps/lsusb-usbmisc.Po
gcc -g -O2 -Wl,--as-needed -o lsusb lsusb-lsusb.o lsusb-lsusb-t.o lsusb-names.o lsusb-devtree.o lsusb-usbmisc.o -lusb-1.0 -lz
$ cd ..
So finally, here are the results of calling of these versions of `lsusb` against the device (note, under Ubuntu `sudo` has to be used, otherwise a "cannot read device status, Operation not permitted (1)" may be generated):
$ ./usbutils-0.87/lsusb --version
lsusb (usbutils) 0.87
$ ./usbutils-git/lsusb --version
lsusb (usbutils) 006
$ sudo ./usbutils-git/lsusb -v -d f4ec:ee38
./usbutils-git/lsusb: cannot open "/usr/share/usb.ids", No such file or directory
Bus 002 Device 012: ID f4ec:ee38
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0xf4ec
idProduct 0xee38
bcdDevice 1.00
iManufacturer 1 Siglent TechCo., Ltd.
iProduct 2 USB Digital Oscilloscope
iSerial 0
bNumConfigurations 1
Couldn't get configuration descriptor 0, some information will be missing
Couldn't get configuration descriptor 0, some information will be missing
Device Status: 0x0001
Self Powered
$ sudo ./usbutils-0.87/lsusb -v -d f4ec:ee38
./usbutils-0.87/lsusb: cannot open "/usr/share/usb.ids", No such file or directory
Bus 002 Device 012: ID f4ec:ee38
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0xf4ec
idProduct 0xee38
bcdDevice 1.00
iManufacturer 1 Siglent TechCo., Ltd.
iProduct 2 USB Digital Oscilloscope
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 49
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 4
bInterfaceClass 220
bInterfaceSubClass 161
bInterfaceProtocol 181
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x86 EP 6 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x05 EP 5 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Status: 0x0001
Self Powered
Clearly, Ubuntu's lsusb (usbutils) 0.87 w/ libusb 0.1.4 can read configuration descriptor data without a problem; while lsusb (usbutils) 006 from git w/ libusb-1.0 cannot - arguably, because of the same "short read" problem.
That is about as much as I can state about the problem - would anyone have any idea why this "short read" problem happens when retrieving configuration descriptor with libusb-1.0; and how could I go around it?
Many thanks in advance for any comments,
Cheers!