SMARTCARD USB Reader

Luca Pizzamiglio l.pizzamiglio at bally-wulff.de
Mon May 16 14:55:22 UTC 2011


Hi List!
I'm Luca and I'm trying to write a kind of driver for USB SMARTCARD 
Reader on FreeBSD 8.2-STABLE.

The approach adopted is to use libusb20, but I've some problem using 
interrupt end point...

I successfully implemented a find_device() routine scanning all device 
and it works well.
Then I want to use all 3 endpoints provided by this calls of devices:
1 BULK OUT endpoint (to send messages)
1 BULK IN endpoint (to read replies)
1 IRQ IN endpoint (to read the change of the slot status)

I have no problem to open BULK endpoints, but the IRQ endpoint open fails.
The procedure I follow is:

libusb20_dev_open( pdev, 32 )
libusb20_dev_set_config_index( pdev, 0)
bin_ep = libusb20_tr_get_pointer( pdev, 0 );
libusb20_tr_open( bin_ep, 4096, 1, bin_ep_num );
bout_ep = libusb20_tr_get_pointer( pdev, 1 );
libusb20_tr_open( bout_ep, 4096, 1, bout_ep_num );
irq_ep = libusb20_tr_get_pointer( pdev, 2 );
libusb20_tr_open( irq_ep, 4096, 1, irq_ep_num );

The last open fails and I don't understand why. LIBUSB20 error code is 
-2 (LIBUSB20_ERROR_INVALID_PARAM) and errno is 22 (EINVAL).
The smartcard reader devices has 1 configuration, 1 interface and 3 
endpoints. These data are confirmed by my find_device routine and by 
usbconfig utility. The irq ep is the number 2 and the unique interface 
has bNumEndpoints = 0x0003.

Scanning the source code, I guess the error code comes form the ioctl( 
USB_FS_OPEN )

u.popen->ep_index >= f->fs_ep_max

Am I missing some initialization? Should I configure something else? Any 
help is really appreciated!

Thanks in advance

Luca

PS There is some examples of usage of libusb20? I read usbconfig source 
code and it's a great source of information, but I didn't found examples 
about transfers...


More information about the freebsd-usb mailing list