|
From: Jens T. T. <jt...@to...> - 2009-04-23 19:09:57
|
Hi,
I'm still having problems with the camera I was writing
about a few days ago. It worked well with libusb-0.1 but
when trying to use libusb-1.0 reading data from the device
fails. What I do is the following (error checking not shown
but present in the code for each function call and everything
looks quite fine until the last step):
a) libusb_init( NULL );
b) libusb_set_debug( NULL, 3 );
c) cnt = libusb_get_device_list( NULL, &list );
for ( i = 0; i < cnt; i++ )
{
struct libusb_device_descriptor desc;
if ( libusb_get_device_descriptor( list[ i ], &desc ) == 0
&& desc.idVendor == 0x184c
&& desc.idProduct == 0x0000 )
{
dev = list[ i ];
break;
}
}
d) libusb_open( dev, &udev );
e) libusb_free_device_list( list, 1 );
f) libusb_set_configuration( udev, 1 );
g) libusb_claim_interface( udev, 0 );
h) libusb_set_interface_alt_setting( udev, 0, 0 );
i) set up buffer with data to be send to device, then
libusb_bulk_transfer( udev, 4, buf, len, &cnt, 0 );
This works and len == cnt afterwards
j) On trying to read the reply the device is supposed to send
libusb_bulk_transfer( udev, 8, readbuf, 64, &cnt, 0 );
the call fails returns -1 and the debug output is
libusb:error [submit_bulk_transfer] submiturb failed error -1 errno=2
The same code (modulo the required changes) works with libusb-0.1,
thus I am pretty sure that what I send to the device etc. is correct
and should result in a reply.
As far as I can see (going by the documentation in the kernel) -2
(ENOENT) means "specified interface or endpoint does not exist or
is not enabled". Now there's something in the 'dmesg' output for
the device that looks a bit suspicious to me but which I am not
sure if it's relevant:
usb 1-3: new high speed USB device using ehci_hcd and address 17
usb 1-3: config 1 interface 0 altsetting 0 bulk endpoint 0x2 has invalid maxpacket 64
usb 1-3: config 1 interface 0 altsetting 0 bulk endpoint 0x4 has invalid maxpacket 64
usb 1-3: config 1 interface 0 altsetting 0 bulk endpoint 0x86 has invalid maxpacket 64
usb 1-3: config 1 interface 0 altsetting 0 bulk endpoint 0x88 has invalid maxpacket 64
usb 1-3: configuration #1 chosen from 1 choice
usb 1-3: New USB device found, idVendor=184c, idProduct=0000
usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-3: Product: Clear Shot II Camera
usb 1-3: Manufacturer: Centice Corporation
usb 1-3: SerialNumber: 0000044
In contrast to this output the documentation for the camera expli-
citely says that 64 is the max packet size for all endpoints. Could
this explain why reading from the device fails with ENOENT? (But
why is a writing data to it working then?)
In order to make sure you get all relevant information here's also
the output of 'lsusb -v' for the device:
Bus 001 Device 017: ID 184c:0000
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x184c
idProduct 0x0000
bcdDevice 1.00
iManufacturer 1 Centice Corporation
iProduct 2 Clear Shot II Camera
iSerial 3 0000044
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 46
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 High Speed
bmAttributes 0xc0
Self Powered
MaxPower 0mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 4
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 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 0x04 EP 4 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 0x88 EP 8 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
(Bus Powered)
Finally one more question out of mere curiosity: how does one
deduce from the device data if a configuration is low, full or
high speed? Is all one can go by the maximum packet size or is
this information somewhere in the output of lsusb and I'm just
too stupid to figure it out?
Thank you for your attention and best regards, Jens
--
\ Jens Thoms Toerring ________ jt...@to...
\_______________________________ http://toerring.de
|