Changes between Version 5 and Version 6 of FAQ


Ignore:
Timestamp:
01/19/11 14:13:32 (2 years ago)
Author:
pbatard
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FAQ

    v5 v6  
    1111Yes, libusb can be used for low-level communication with USB Mass Storage Class devices. But in order to access a file on such a device you must first implement Mass Storage Class, SCSI and the particular filesystem used on the device, most commonly FAT32. No, we can not do this for you. Please study existing open source implementations to learn about this, one minimal implementation exists in [http://www.coreboot.org/Libpayload libpayload] from the coreboot project, or simply mount the storage device if you just want to read the file. For an example of how to read a data block through Mass Storage using libusb, you can also have a look at the mass_storage test from the [http://git.libusb.org/?p=libusb-pbatard.git;a=blob;f=examples/xusb.c xusb.c] sample, in the [http://git.libusb.org/?p=libusb-pbatard.git;a=tree;f=examples examples/] directory from the libusb-pbatard branch. 
    1212 
    13 == Can I create a driverless device using HID class? == 
    14 Yes, sortof, but the device will only be really easy to access on Microsoft Windows. 
     13== Can I create a "driverless" device using HID class? == 
     14Yes, sortof, but the device will only be really easy to access on Microsoft Windows (and Linux, if you can temporarily replace the driver, which libusb provides an API for). 
    1515 
    1616It is important to remember that USB devices are never driverless, rather quite the opposite. Multiple kernel drivers are always involved: USB stack with USB core, USB hub drivers, maybe a composite class driver, and then ultimately a class- or device-specific driver. This is true for every operating system, and also when using libusb. 
    1717 
    18 On Windows it is trivial to program HID class devices directly, because the HID class-specific driver in Windows exposes a simple file-like API. For some applications this can be sufficient, but it is a tradeoff which means that most features of USB can not be used by the device, since the HID class only allows interrupt endpoints and since the format of communication over the endpoints is specified in the HID class as reports. 
     18On Windows it is trivial to program HID class devices directly, because the HID class-specific driver in Windows exposes a simple file-like API. For some applications this can be sufficient, but it is a tradeoff which means that some features of USB can not be used by the device. For instance, the HID class only allows interrupt endpoints and the format of communication over the endpoints is specified in the HID class as reports, so all data must be encapsulated. 
    1919 
    20 Besides the USB protocol restrictions, using the HID class is much more inconvenient on systems other than Windows. For what is probably historical reasons, the generic file-like API exposed by the Windows HID class-specific driver is unique. On other systems, the HID class driver does not offer the same simple API. 
     20Besides the USB protocol restrictions, using the HID class is much more inconvenient on systems other than Windows. On other systems, the HID class driver does not offer a similar simple generic API so it is not accessible from libusb. On Linux however, libusb does provide the ability temporarily replace the HID driver (which might require setting up udev rules if running as non root), so that generic access can be achieved in a transparent manner. 
    2121 
    22 If the broadest platform compatiblity is important (this may be why you look toward libusb in the first place) then a much more neutral alternative is to use the ''Vendor Specific'' device class (0xff). This requires that a kernel driver is installed on Windows, but two generic USB drivers exist (libusb0.sys from the libusb-win32 project, see #49, and WinUSB.sys from Microsoft) which can be used as-is, and the installation process can be automated completely using [wiki:libwdi]. 
     22If the broadest platform compatiblity is important (this may be why you look toward libusb in the first place) then a much more neutral alternative is to use the ''Vendor Specific'' device class (0xff). This requires that a kernel driver is installed on Windows, but two generic USB drivers exist (libusb0.sys from the libusb-win32 project, see #49, and WinUSB.sys from Microsoft) which can be used as-is, and the installation process can be automated using [wiki:libwdi] (with some restrictions). 
    2323 
    2424On the other systems supported by libusb there is no need for interaction with kernel drivers at all when using the Vendor Specific device class. Both Linux and Mac OS X come with a generic USB driver built-in, which libusb uses automatically.