From owner-freebsd-usb@FreeBSD.ORG Mon May 16 14:55:22 2011 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 56EC51065744 for ; Mon, 16 May 2011 14:55:22 +0000 (UTC) (envelope-from l.pizzamiglio@bally-wulff.de) Received: from mail2.bally-wulff-berlin.de (mail2.bally-wulff-berlin.de [212.144.118.9]) by mx1.freebsd.org (Postfix) with ESMTP id 151268FC0C for ; Mon, 16 May 2011 14:55:21 +0000 (UTC) Received: from bwex.bally-wulff.de (unknown [192.9.204.106]) by mail2.bally-wulff-berlin.de (Postfix) with ESMTP id 3F50399052 for ; Mon, 16 May 2011 16:29:08 +0200 (CEST) Received: from pizzamig.bally.de ([192.9.205.30]) by bwex.bally-wulff.de with Microsoft SMTPSVC(6.0.3790.4675); Mon, 16 May 2011 16:29:08 +0200 Message-ID: <4DD134A7.1070208@bally-wulff.de> Date: Mon, 16 May 2011 16:28:55 +0200 From: Luca Pizzamiglio User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.17) Gecko/20110506 Thunderbird/3.1.10 MIME-Version: 1.0 To: freebsd-usb@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 16 May 2011 14:29:08.0301 (UTC) FILETIME=[9DC83FD0:01CC13D5] Subject: SMARTCARD USB Reader X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2011 14:55:22 -0000 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...