From: Peter S. <stu...@cd...> - 2004-11-10 07:39:10
|
Hi Martin, On Tue, Nov 09, 2004 at 12:12:41PM -0500, Martin Vaillancourt wrote: > Note that I have renamed the mass storage driver, eg the usb-storage.ko. > I do not want it to claim the interface! Yup. I remember you're doing some factory testing of storage devices. > 1) By doing this, I lost communication with the device > o Step1: Usb_open() > o Step2: Claim the interface > o Step2a: Send CBW Command (The Test Unit Ready: 55 53 42 43 01 > 02 03 04 00 00 00 00 00 00 06 00.) > o Step3: Release the interface > o Step4: Usb_close() > o Loop on step1. > NB: By doing only the release without the usb_close, the next claim > return -19.(With or Without the CBW Command). > > I'm using a CATC USB2.0, eg a usb sniffer on the USB Bus to see > if there is some activity. > The step3, the usb_release_interface() send a SET_INTERFACE > bRequest Command on the USB Bus with DATA0 PID???? This is a fairly low-level matter. All of these USB "details" are handled by the Linux USB subsystem core. libusb is a utility library that abstracts the USB subsystem API of several different operating systems and it doesn't have to deal with things that are this "deep" in the stack. That said; I've taken a look at the relevant kernel USB code. The SET_INTERFACE you see is sent when the usbfs kernel USB driver unbinds from the function interface. usbfs is the userspace API to things USB in Linux, this is what libusb communicates with. usbfs is a kernel USB driver, much like any other kernel USB driver, only it takes instructions from userspace via /proc/usb rather than being written for some specific device. > The CATC show my that there is a Data Toggle ERROR. [..] > If I send only one CBW, the CBW uses DATA0 perfectly, the release > send again on DATA0?? I re-open, re-claim and the next CBW is still > on DATA0?? > How the DATA Toggle is it done? I'm using the usb_bulk_write() and > usb_bulk_read() functions. The data toggle is done inside the kernel. It looks like you're missing step 1.5: usb_set_configuration() This will eventually lead to either usb_set_configuration() or usb_reset_configuration() in /usr/src/linux/drivers/usb/core/message.c being called; --8<-- usb_reset_configuration - lightweight device reset @dev: the device whose configuration is being reset This issues a standard SET_CONFIGURATION request to the device using the current configuration. The effect is to reset most USB-related state in the device, including interface altsettings (reset to zero), endpoint halts (cleared), and data toggle (only for bulk and interrupt endpoints). Other usbcore state is unchanged, including bindings of usb device drivers to interfaces. -->8-- Hope this helps. //Peter |