gP^      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~|DA decoded 16 bits Binary Coded Decimal using 4 bits for each digit. Type of USB exceptions. Other exception. 1Operation not supported or unimplemented on this  platform. Insufficient memory. 1System call interrupted (perhaps due to signal). Pipe exception.  Overflow. Operation timed out. Resource busy. Entity not found. 0No such device (it may have been disconnected). *Access denied (insufficient permissions). Invalid parameter. Input/output exception. Number of bytes transferred. 9A timeout in milliseconds. Use 0 to indicate no timeout. &Type of indici of string descriptors. .Can be retrieved by all the *StrIx functions. DThe language ID consists of the primary language identifier and the *sublanguage identififier as described in:  2http://www.usb.org/developers/docs/USB_LANGIDs.pdf 0For a mapping between IDs and languages see the usb-id-database package at:  2http://hackage.haskell.org/package/usb-id-database  To see which  s are supported by a device see . 51Direction of data transfer relative to the host. 6Device to host. 7Host to device. :Must be >= 0 and <= 15 <?A structure representing the standard USB endpoint descriptor. QThis descriptor is documented in section 9.6.3 of the USB 2.0 specification. All <multiple-byte fields are represented in host-endian format. &This structure can be retrieved using L. =&The address of the endpoint described  by this descriptor. >Attributes which apply to the ( endpoint when it is configured using  the T. ?%Maximum packet size this endpoint is  capable of sending/ receiving. @"Interval for polling endpoint for ' data transfers. Expressed in frames # or microframes depending on the ( device operating speed (i.e., either # 1 millisecond or 125 s units). AFor audio devices only: the rate at % which synchronization feedback is  provided. BFor audio devices only: the address  if the synch endpoint. CExtra descriptors. If libusb  encounters unknown endpoint  descriptors, it will store ! them here, should you wish to  parse them. D@A structure representing the standard USB interface descriptor. MThis descriptor is documented in section 9.6.5 of the USB 2.0 specification. &This structure can be retrieved using Y. ENumber of this  interface. FValue used to select  this alternate setting  for this interface. GUSB-IF class code for  this interface. HUSB-IF subclass code for  this interface,  qualified by the  G value. IUSB-IF protocol code for  this interface,  qualified by the  G and  H  values. JIndex of string  descriptor describing  this interface. KNumber of endpoints used  by this interface  (excluding the control  endpoint). LList of endpoint  descriptors. Note that  the length of this list  should equal  K. MExtra descriptors. If  libusb encounters  unknown interface  descriptors, it will  store them here, should  you wish to parse them. P.The Remote Wakeup field indicates whether the 1 device is currently enabled to request remote - wakeup. The default mode for devices that & support remote wakeup is disabled. Q-The Self Powered field indicates whether the $ device is currently self-powered SDA structure representing the standard USB configuration descriptor. MThis descriptor is documented in section 9.6.3 of the USB 2.0 specification. #This structure can be retrieved by ,  or . TIdentifier value for this  configuration. UIndex of string descriptor " describing this configuration. VConfiguration characteristics. W!Maximum power consumption of the $ USB device from this bus in this $ configuration when the device is $ fully operational. Expressed in # 2 mA units (i.e., 50 = 100 mA). X"Number of interfaces supported by  this configuration. Y List of interfaces supported by $ this configuration. An interface  is represented as a list of ! alternate interface settings. % Note that the length of this list  should equal  X. ZExtra descriptors. If libusb $ encounters unknown configuration # descriptors, it will store them " here, should you wish to parse  them. \3For a database of USB vendors and products see the usb-id-database  package at:  2http://hackage.haskell.org/package/usb-id-database ]=A structure representing the standard USB device descriptor. MThis descriptor is documented in section 9.6.1 of the USB 2.0 specification. #This structure can be retrieved by . ^USB specification release  number in binary-coded  decimal. _USB-IF class code for the  device. `USB-IF subclass code for the  device, qualified by the  _ value. aUSB-IF protocol code for the  device, qualified by the  _ and  ` values. bMaximum packet size for  endpoint 0. cUSB-IF vendor ID. dUSB-IF product ID. eDevice release number in  binary-coded decimal. fIndex of string descriptor  describing manufacturer. gIndex of string descriptor  describing product. hIndex of string descriptor  containing device serial  number. iNumber of possible  configurations. j-Identifier for interface alternate settings. Can be retrieved by F. kIdentifier for interfaces. Can be retrieved by E. lIdentifier for configurations. Can be retrieved by  or by T. mIAbstract type representing a handle on a USB device, usually originating from |. $A device handle is used to perform I/+O and other operations. When finished with .a device handle, you should close it by apply } to it. n Retrieve the o from the m. oHAbstract type representing a USB device detected on the system, usually originating from x. ICertain operations can be performed on a device, but in order to do any I/O you will have to first obtain a m using |. NJust because you have a reference to a device does not mean it is necessarily Kusable. The device may have been unplugged, you may not have permission to Koperate such device, or another program or driver may be using the device. This reference to the u is needed so that it  won')t get garbage collected so the finalizer  # only gets run when all references  to Devices are gone. pMessage verbosity q.Informational messages are printed to stdout, 4 warning and error messages are printed to stderr r1Warning and error messages are printed to stderr s%Error messages are printed to stderr t,No messages are ever printed by the library u*Abstract type representing a USB session. OThe concept of individual sessions allows your program to use multiple threads Lthat can independently use this library without interfering with eachother. (Sessions are created and initialized by v and are automatically closed when garbage collected. v)Create and initialize a new USB context. This function may throw s. wSet message verbosity. The default level is t#, which means no messages are ever Qprinted. If you choose to increase the message verbosity level, ensure that your %application does not close the stdout/stderr file descriptors. You are advised to set level r". libusb is conservative with its Pmessage logging and most of the time, will only log messages that explain error Gconditions and other oddities. This will help you debug your software. NIf the LIBUSB_DEBUG environment variable was set when libusb was initialized, Othis function does nothing: the message verbosity is fixed to the value in the environment variable. PIf libusb was compiled without any message logging, this function does nothing: you'll never get any messages. NIf libusb was compiled with verbose debug message logging, this function does  nothing: you'(ll always get messages from all levels. x@Returns a list of USB devices currently attached to the system. ?This is your entry point into finding a USB device to operate.  Exceptions:  ! on a memory allocation failure. y9Get the number of the bus that a device is connected to. z=Get the address of the device on the bus it is connected to. {;Convenience function to retrieve the max packet size for a 8particular endpoint in the active device configuration. 5This is useful for setting up isochronous transfers.  Exceptions:   ! if the endpoint does not exist.   on another exception. |*Open a device and obtain a device handle.  A handle allows you to perform I/O on the device in question. DThis is a non-blocking function; no requests are sent over the bus. It is advised to use ~% because it automatically closes the (device when the computation terminates.  Exceptions:  * if there is a memory allocation failure.   + if the user has insufficient permissions.   & if the device has been disconnected.  Another . }Close a device handle. DShould be called on all open handles before your application exits. DThis is a non-blocking function; no requests are sent over the bus. ~withDeviceHandle dev act opens the o dev and passes (the resulting handle to the computation act$. The handle will be closed on exit from withDeviceHandle0 whether by normal termination or by raising an  exception. :Determine the bConfigurationValue of the currently active configuration. MYou could formulate your own control request to obtain this information, but Pthis function has the advantage that it may be able to retrieve the information "from operating system caches (no I/ O involved). QIf the OS does not cache this information, then this function will block while a ;control transfer is submitted to retrieve the information. OThis function will return a value of 0 if the device is in unconfigured state.  Exceptions:   & if the device has been disconnected.  Aanother . +Set the active configuration for a device. PThe operating system may or may not have already set an active configuration on Pthe device. It is up to your application to ensure the correct configuration is Nselected before you attempt to claim interfaces and perform other operations. KIf you call this function on a device already configured with the selected Mconfiguration, then this function will act as a lightweight device reset: it Pwill issue a SET_CONFIGURATION request using the current configuration, causing Nmost USB-related device state to be reset (altsetting reset to zero, endpoint halts cleared, toggles reset). You cannot change/?reset configuration if your application has claimed interfaces - you should free them with  first. You cannot change/reset Hconfiguration if other applications or drivers have claimed interfaces. OA configuration value of -1 will put the device in unconfigured state. The USB Nspecifications state that a configuration value of 0 does this, however buggy 5devices exist which actually have a configuration 0. EYou should always use this function rather than formulating your own LSET_CONFIGURATION control request. This is because the underlying operating /system needs to know when such changes happen. This is a blocking function.  Exceptions:   0 if the requested configuration does not exist.   & if interfaces are currently claimed.   % if the device has been disconnected  Another . -Claim an interface on a given device handle. EYou must claim the interface you wish to use before you can perform I/ O on any of its endpoints. LIt is legal to attempt to claim an already-claimed interface, in which case ,libusb just returns without doing anything. LClaiming of interfaces is a purely logical operation; it does not cause any Mrequests to be sent over the bus. Interface claiming is used to instruct the Nunderlying operating system that your application wishes to take ownership of the interface. !This is a non-blocking function. It is advised to use & because it automatically releases an +interface when the computation terminates.  Exceptions:   , if the requested interface does not exist.   9 if another program or driver has claimed the interface.   & if the device has been disconnected.  Another . -Release an interface previously claimed with . JYou should release all claimed interfaces before closing a device handle. QThis is a blocking function. A SET_INTERFACE control request will be sent to the Bdevice, resetting interface state to the first alternate setting.  Exceptions:   # if the interface was not claimed.   % if the device has been disconnected  Another .  withInterface6 claims the interface on the given device handle then -executes the given computation. On exit from , the interface is Creleased whether by normal termination or by raising an exception. 0Activate an alternate setting for an interface. 5The interface must have been previously claimed with  or . EYou should always use this function rather than formulating your own OSET_INTERFACE control request. This is because the underlying operating system (needs to know when such changes happen. This is a blocking function.  Exceptions:   3 if the interface was not claimed or the requested % alternate setting does not exist.   & if the device has been disconnected.  Another . Clear the halt/!stall condition for an endpoint. QEndpoints with halt status are unable to receive or transmit data until the halt condition is stalled. LYou should cancel all pending transfers before attempting to clear the halt  condition. This is a blocking function.  Exceptions:   ! if the endpoint does not exist.   & if the device has been disconnected.  Another . 3Perform a USB port reset to reinitialize a device. LThe system will attempt to restore the previous configuration and alternate (settings after the reset has completed. LIf the reset fails, the descriptors change, or the previous state cannot be Prestored, the device will appear to be disconnected and reconnected. This means Othat the device handle is no longer valid (you should close it) and rediscover the device. A  ( is raised to indicate that this is the case. EThis is a blocking function which usually incurs a noticeable delay.  Exceptions:   * if re-enumeration is required, or if the ! device has been disconnected.  Another . 8Determine if a kernel driver is active on an interface. QIf a kernel driver is active, you cannot claim the interface, and libusb will be unable to perform I/O.  Exceptions:   & if the device has been disconnected.  Another . *Detach a kernel driver from an interface. IIf successful, you will then be able to claim the interface and perform I/O.  Exceptions:   ! if no kernel driver was active.   " if the interface does not exist.   & if the device has been disconnected.  Another . Re-attach an interface'&s kernel driver, which was previously detached using .  Exceptions:   ! if no kernel driver was active.   " if the interface does not exist.   & if the device has been disconnected.   8 if the driver cannot be attached because the interface & is claimed by a program or driver.  Another . FIf a kernel driver is active on the specified interface the driver is Pdetached and the given action is executed. If the action terminates, whether by Mnormal termination or by raising an exception, the kernel driver is attached Qagain. If a kernel driver is not active on the specified interface the action is just executed.  Exceptions:   & if the device has been disconnected.  Another . 2Get the USB device descriptor for a given device. LThis is a non-blocking function; the device descriptor is cached in memory. This function may throw s. >Get the USB configuration descriptor for the currently active configuration. OThis is a non-blocking function which does not involve any requests being sent to the device.  Exceptions:   ) if the device is in unconfigured state.  Another . 7Get a USB configuration descriptor based on its index. OThis is a non-blocking function which does not involve any requests being sent to the device.  Exceptions:   & if the configuration does not exist.  Another . 3Get a USB configuration descriptor with a specific T. OThis is a non-blocking function which does not involve any requests being sent to the device.  Exceptions:   & if the configuration does not exist.  Another . (Retrieve a list of supported languages. This function may throw s. /putStrDesc devHndl strIx langId maxSize dataPtr retrieves the string descriptor strIx in the language langId from the devHndl and writes at most maxSize* bytes from that string descriptor to the location that dataPtr. points to. So ensure there is at least space for maxSize8 bytes there. Next, the header of the string descriptor !is checked for correctness. If it's incorrect an  is >thrown. Finally, the size reported in the header is returned. ,Retrieve a string descriptor from a device. PThis is a convenience function which formulates the appropriate control message Oto retrieve the descriptor. The string returned is Unicode, as detailed in the USB specifications. This function may throw s. ERetrieve a string descriptor from a device using the first supported  language. PThis is a convenience function which formulates the appropriate control message Oto retrieve the descriptor. The string returned is Unicode, as detailed in the USB specifications. This function may throw s. Perform a USB control& request that does not transfer data. The value and index3 values should be given in host-endian byte order.  Exceptions:   if the transfer timed out.  8 if the control request was not supported by the device   & if the device has been disconnected.  Another . Perform a USB control read. The value and index3 values should be given in host-endian byte order.  Exceptions:   if the transfer timed out.  8 if the control request was not supported by the device   & if the device has been disconnected.  Another . Perform a USB control write. The value and index3 values should be given in host-endian byte order.  Exceptions:   if the transfer timed out.  8 if the control request was not supported by the device   & if the device has been disconnected.  Another . Perform a USB bulk read.  Exceptions:   if the transfer timed out.   if the endpoint halted.  " if the device offered more data,  see Packets and overflows in the libusb documentation:   9http://libusb.sourceforge.net/api-1.0/packetoverflow.html.   & if the device has been disconnected.  Another . Perform a USB bulk write.  Exceptions:   if the transfer timed out.   if the endpoint halted.  " if the device offered more data,  see Packets and overflows in the libusb documentation:   9http://libusb.sourceforge.net/api-1.0/packetoverflow.html.   & if the device has been disconnected.  Another . Perform a USB  interrupt read.  Exceptions:   if the transfer timed out.   if the endpoint halted.  " if the device offered more data,  see Packets and overflows in the libusb documentation:   9http://libusb.sourceforge.net/api-1.0/packetoverflow.html.   & if the device has been disconnected.  Another . Perform a USB  interrupt write.  Exceptions:   if the transfer timed out.   if the endpoint halted.  " if the device offered more data,  see Packets and overflows in the libusb documentation:   9http://libusb.sourceforge.net/api-1.0/packetoverflow.html.   & if the device has been disconnected.  Another . handleUSBException action executes action. If action returned an  error code other than 'c\'LIBUSB_SUCCESS', the error is converted to a   and thrown. checkUSBException action executes action. If action returned a 0 negative integer the integer is converted to a  and thrown. If  not, the integer is returned.  Convert a 'C\'libusb_error' to a  . If the C'libusb_error is  unknown an   is thrown. Association list mapping  s to s. decodeBCD bitsInDigit n" decodes the Binary Coded Decimal n to a list of its encoded digits.  bitsInDigit,, which is usually 4, is the number of bits $used to encode a single digit. See:  1http://en.wikipedia.org/wiki/Binary-coded_decimal  bits s e b extract bit s to e (including) from b. 0Execute the given action but ignore the result. A generalized   that works on any   type. A generalized   that returns any   type. input  doWrite first converts the input  ByteString to an  array of Word8s, then doWrite* is executed by pointing it to this array 4 and the size of this array. Finally, the result of doWrite is returned. @Make sure not to return the pointer to the array from @doWrite@! KNote that the converion from the @ByteString@ to the @Word8@ array is O(1).   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   !  !"#$%#$%&)(''()*.-,++,-./3210012345766789:;9:;<=>?@ABC=>?@ABCD EFGHIJKLMEFGHIJKLMNOPQOPQRSTUVWXYZTUVWXYZ[\] ^_`abcdefghi^_`abcdefghijklmnnoptsrqqrstuvwxyz{|}~  X !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi{]^_`abcdefghi^_`abc\d[efghiSTUVWXYZTUVRNOPQWXYZDEFGHIJKLMEFGHIJKLM<=>?@ABC=89:;576>4/3210*.-,+&)('?"#$%! @ABCjklmnoxyz{|}~oxyz{mn|}~nlkjpqrstuvwuvwptsrq  Experimental#Bas van Dijk <v.dijk.bas@gmail.com>  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  !"#$%&'()*+,-.//0123456789:;<=>?@ABCDDEFGHIJKLMNOPQRSTUVWXYYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     usb-0.1.0.1System.USB.DescriptorsSystem.USB.ExceptionsSystem.USB.IO.Synchronous'System.USB.DeviceHandlingAndEnumerationSystem.USB.InitializationSystem.USB.Internalbindings-libusb-1.2.Bindings.Libusb.InitializationDeinitializationbasePreludeBindings.Libusb.Miscellaneous System.USBBCD4 USBExceptionOtherExceptionNotSupportedExceptionNoMemExceptionInterruptedException PipeExceptionOverflowExceptionTimeoutException BusyExceptionNotFoundExceptionNoDeviceExceptionAccessExceptionInvalidParamException IOException RecipientToOther ToEndpoint ToInterfaceToDevice RequestTypeVendorClassStandardSizeTimeoutStrIx SubLangId PrimaryLangIdLangIdTransactionOpportunitiesTwoAdditionalTransactionsOneAdditionlTransactionNoAdditionalTransactions MaxPacketSize maxPacketSizetransactionOpportunitiesUsageImplicitFeedbackDataSynchronization SynchronousAdaptive AsynchronousNoSynchronization TransferType InterruptBulk IsochronousControlEndpointAttribsTransferDirectionInOutEndpointAddressendpointNumberendpointDirection EndpointDescendpointAddressendpointAttribsendpointMaxPacketSizeendpointIntervalendpointRefreshendpointSynchAddress endpointExtra InterfaceDescinterfaceNumberinterfaceAltSettinginterfaceClassinterfaceSubClassinterfaceProtocolinterfaceStrIxinterfaceNumEndpointsinterfaceEndpointsinterfaceExtra DeviceStatus remoteWakeup selfPowered ConfigAttribs ConfigDesc configValue configStrIx configAttribsconfigMaxPowerconfigNumInterfacesconfigInterfaces configExtra ProductIdVendorId DeviceDescdeviceUSBSpecReleaseNumber deviceClassdeviceSubClassdeviceProtocoldeviceMaxPacketSize0deviceVendorIddeviceProductIddeviceReleaseNumberdeviceManufacturerStrIxdeviceProductStrIxdeviceSerialNumberStrIxdeviceNumConfigsInterfaceAltSettingInterfaceNumber ConfigValue DeviceHandle getDeviceDevice Verbosity PrintInfo PrintWarnings PrintErrors PrintNothingCtxnewCtxsetDebug getDevices getBusNumbergetDeviceAddressgetMaxPacketSize openDevice closeDevicewithDeviceHandle getConfig setConfigclaimInterfacereleaseInterface withInterfacesetInterfaceAltSetting clearHalt resetDevicekernelDriverActivedetachKernelDriverattachKernelDriverwithDetachedKernelDriver getDeviceDescgetActiveConfigDesc getConfigDescgetConfigDescByValue getLanguages getStrDescgetStrDescFirstLangcontrol readControl writeControlreadBulk writeBulk readInterruptwriteInterrupt _devGetCtx p'libusb_exit putStrDeschandleUSBExceptioncheckUSBExceptionconvertUSBExceptionGHC.Errerrorlibusb_error_to_USBExceptionC'libusb_error decodeBCDbitsignore genToEnumGHC.EnumtoEnumGHC.RealIntegral genFromEnumfromEnum writeWith