ret = read(fd, (void *)&dev->descriptor, sizeof(dev->descriptor))
sizeof(dev->descriptor) is returning 20 instead of 18!!! I have no idea why this might be happening as everything checks out and the sum of all the sizeof(dev->descriptor.*) adds up to 18!!!
Anyway the hack is to subtract 2 from the amount to be read from fd and everything is golden again... any ideas???
Regards, David
David Mattes wrote:
Ludovic Rousseau wrote:
Le Tuesday 27 April 2004 � 08:59:53, David Mattes a �crit:And good day to you again!
Hi,
Hello,
I have a Sharp Zaurus SL6000. Yes, it has a USB host controller!!! I am trying to use a CCID smartcard reader (tried both GemPCTwin and SCM SCR331) on it and have built pcsc-lite-1.2.0, libusb-0.1.8, and ccid-0.4.1 for the Intel ARM XScale processor on the zaurus. When I attach the reader to the zaurus, however, the reader can't be initialized. Can you suggest debugging techniques, or what might be happening? BTW, I have this entire system working on my x86 linux laptop.
ccid_usb.c:259:OpenUSBByName Can't find a CCID interface on 001/007
The problem comes from (I think) the function get_ccid_usb_interface() in src/ccid_usb.c
Can you add lines like "printf("%s:%d\n", __FILE__, __LINE__);" in the code to see what happens in this function.
The execution should not take the branch "if (dev->config->bNumInterfaces > 1)"
and "dev->config->interface" should not be NULL in the other branch.
Bye,
Well, I added some more debugging, and turned on libusb debugging. I think the problem is in the libusb layer. In usb_os_find_devices(), there seems to be a problem reading the device descriptor. If this fails, the device config never gets read by usb_parse_configuration(). [code snippet below]. Do you agree?
I thought about endian issues. There is the USB_LE16_TO_CPU macro which is #defined either for big or little endian, and I tried switching it to little endian (it was set to big endian, which I believe is correct for ARM XScale), but that made no difference.
Here's the output from pcscd -d stdout:
------------------------------------------------------------------------------------
# /opt/Qtopia/local/pkgs/zaurus-cross/pcsc-lite/sbin/pcscd -d stdout
pcscdaemon.c:265 main: debug messages to stdout
pcscdaemon.c:427 main: warning: no reader.conf found
pcscdaemon.c:445 main: pcsc-lite daemon ready.
hotplug_libusb.c:344 Adding USB device: 001:031
readerfactory.c:1391 RFInitializeReader: Attempting startup of GemPC
Twin 0 0.
readerfactory.c:1133 RFBindFunctions: Loading IFD Handler 2.0
ifdhandler.c:117:IFDHCreateChannel lun: 0
ccid_usb.c:110:OpenUSBByName Lun: 0, Device: (null)
usb_set_debug: Setting debugging level to 10 (on)
usb_os_find_busses: Skipping non bus directory devices
usb_os_find_busses: Skipping non bus directory drivers
usb_os_find_busses: Found 001
usb_os_find_devices: Found 030 on 001
usb_os_find_devices: Next config descriptor too short (expected 257, got 15)
usb_os_find_devices: Found 031 on 001
usb_os_find_devices: Next config descriptor too short (expected 257, got 83)
ccid_usb.c:157:OpenUSBByName Manufacturer: Ludovic Rousseau
([EMAIL PROTECTED])
ccid_usb.c:165:OpenUSBByName ProductString: Generic CCID reader v0.4.1
ccid_usb.c:169:OpenUSBByName Copyright: This driver is protected by
terms of the GNU General Public License version 2, or (at your option)
any later version.
ccid_usb.c:183:OpenUSBByName vendorID: 8E6
ccid_usb.c:188:OpenUSBByName productID: 3437
ccid_usb.c:216:OpenUSBByName dev->descriptor.idVendor: 8E6
ccid_usb.c:217:OpenUSBByName dev->descriptor.idProduct: 3437
ccid_usb.c:218:OpenUSBByName dev->config: 27B78
ccid_usb.c:244:OpenUSBByName Trying to open USB bus/device: 001/031
usb_os_open: filename: /proc/bus/usb/001/031
usb_open: udev->fd: 7
usb_open: udev->config: FFFFFFFF
usb_open: dev->config: 27B78
usb_open: udev->altsetting: FFFFFFFF
ccid_usb.c:247:OpenUSBByName dev_handle: 28018
ccid_usb.c:257:OpenUSBByName dev->config: 27B78
ccid_usb.c:258:OpenUSBByName dev->config->interface: 0
ccid_usb.c:500:get_ccid_usb_interface dev->config: 27B78
ccid_usb.c:501:get_ccid_usb_interface dev->config->bLength: 0
ccid_usb.c:502:get_ccid_usb_interface dev->config->bDescriptorType: 0
ccid_usb.c:503:get_ccid_usb_interface dev->config->wTotalLength: 0
ccid_usb.c:504:get_ccid_usb_interface dev->config->number of usb
interfaces: 0
ccid_usb.c:505:get_ccid_usb_interface dev->config->bConfigurationValue: 0
ccid_usb.c:506:get_ccid_usb_interface dev->config->iConfiguration: 0
ccid_usb.c:507:get_ccid_usb_interface dev->config->bmAttributes: 0
ccid_usb.c:508:get_ccid_usb_interface dev->config->MaxPower: 0
ccid_usb.c:528:get_ccid_usb_interface using default interface:
dev->config->interface: 0
ccid_usb.c:270:OpenUSBByName Can't find a CCID interface on 001/031
ifdhandler.c:135:IFDHCreateChannel failed
readerfactory.c:1428 RFInitializeReader: Open Port 200000 Failed
readerfactory.c:1263 RFUnloadReader: Unloading reader driver.
readerfactory.c:245 RFAddReader: GemPC Twin init failed.
---------------------------------------------------------------------------------
Here's the snippet of code that contains the usb_os_find_devices() function:
------------ code snippet from libusb-0.1.8/linux.c------------------------------------- for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { char buffer[8], *bigbuffer; struct usb_config_descriptor *desc = (struct usb_config_descriptor *)buffer;
/* Get the first 8 bytes so we can figure out what the total length is */ ret = read(fd, (void *)buffer, 8); if (ret < 8) { if (usb_debug >= 1) { if (ret < 0) fprintf(stderr, "Unable to get descriptor (%d)\n", ret); else fprintf(stderr, "usb_os_find_devices: Initial config descriptor too short (expected %d, got %d)\n", 8, ret); }
goto err; }
USB_LE16_TO_CPU(desc->wTotalLength);
bigbuffer = malloc(desc->wTotalLength); if (!bigbuffer) { if (usb_debug >= 1) fprintf(stderr, "Unable to allocate memory for descriptors\n"); goto err; }
/* Copy over the first 8 bytes we read */ memcpy(bigbuffer, buffer, 8);
ret = read(fd, (void *)(bigbuffer + 8), desc->wTotalLength - 8); if (ret < desc->wTotalLength - 8) { if (usb_debug >= 1) { if (ret < 0) fprintf(stderr, "Unable to get descriptor (%d)\n", ret); else fprintf(stderr, "usb_os_find_devices: Next config descriptor too short (expected %d, got %d)\n", desc->wTotalLength, ret); }
free(bigbuffer); goto err; }
ret = usb_parse_configuration(&dev->config[i], bigbuffer); if (usb_debug >= 2) { if (ret > 0) fprintf(stderr, "Descriptor data still left\n"); else if (ret < 0) fprintf(stderr, "Unable to parse descriptors\n"); }
free(bigbuffer);
}
------------------ end snippet --------------------------------------------
_______________________________________________ Muscle mailing list [EMAIL PROTECTED] http://lists.drizzle.com/mailman/listinfo/muscle
-- ----------------------------------------------------------------------- David Mattes The Boeing Company PO Box 3707 MC 7L-40 Phantom Works Seattle, WA 98124-2207 M&CT 425-865-4166 Advanced Manufacturing Systems 206-797-6884 (pgr) 425-865-2965 (fax) [EMAIL PROTECTED]
_______________________________________________ Muscle mailing list [EMAIL PROTECTED] http://lists.drizzle.com/mailman/listinfo/muscle
