׭      !"#$%&'()*+,-./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. See: USB 2.0 Spec. table 9-7 Number of bytes transferred. LA timeout in millseconds. A timeout defines how long a transfer should wait O before giving up due to no response being received. For no timeout, use value  0. (Handy type synonym for write transfers. A  WriteAction is a function which takes a  and the  to write. The function returns an * action which, when exectued, returns the Onumber of bytes that were actually written paired with an flag which indicates whether a transfer timed out. !'Handy type synonym for read transfers. A  ReadAction is a function which takes a  and a  which defines 0how many bytes to read. The function returns an  action which, when 3executed, performs the actual read and returns the  that was read Apaired with a flag which indicates whether a transfer timed out. "&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 . &#Number of additional transactions. '()*+,-./01234567?Describes what types of transfers are allowed on the endpoint. 8=Interrupt transfers are typically non-periodic, small device  " initiated"* communication requiring bounded latency. 92Bulk transfers can be used for large bursty data. :;Isochronous transfers occur continuously and periodically. ;<Control transfers are typically used for command and status  operations. <FThe USB 2.0 specification specifies that the endpoint attributes only & describe the endpoint transfer type. =5The direction of data transfer relative to the host. >,In transfer direction (device -> host) used  for reading. ?-Out transfer direction (host -> device) used  for writing. @The address of an endpoint. ABMust be >= 0 and <= 15 CD?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. EF9The address of the endpoint described by the descriptor. GGAttributes which apply to the endpoint when it is configured using the  _. H6Maximum packet size the endpoint is capable of sending/ receiving. IFInterval for polling endpoint for data transfers. Expressed in frames H or microframes depending on the device operating speed (i.e., either 1  millisecond or 125  s units). JFor audio devices only:, the rate at which synchronization feedback  is provided. KFor audio devices only:$ the address if the synch endpoint. LExtra descriptors. If libusb* encounters unknown endpoint descriptors, 9 it will store them here, should you wish to parse them. M@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 d. NONumber of the interface. P>Value used to select the alternate setting for the interface. Q%USB-IF class code for the interface. R9USB-IF subclass code for the interface, qualified by the  Q value. S9USB-IF protocol code for the interface, qualified by the  Q and R values. T5Index of string descriptor describing the interface. U.List of endpoints supported by the interface. VExtra descriptors. If libusb encounters unknown interface F descriptors, it will store them here, should you wish to parse them. WXY.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. Z-The Self Powered field indicates whether the $ device is currently self-powered [LThe USB 2.0 specification specifices that the configuration attributes only  describe the device status. \GAn interface is represented as a list of alternate interface settings. ]DA 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 v. ^_(Identifier value for the configuration. `9Index of string descriptor describing the configuration. aConfiguration characteristics. b@Maximum power consumption of the USB device from the bus in the H configuration when the device is fully operational. Expressed in 2 mA  units (i.e., 50 = 100 mA). c5Number of interfaces supported by the configuration. dBList of interfaces supported by the configuration. Note that the " length of this list should equal c. eExtra descriptors. If libusb" encounters unknown configuration F descriptors, it will store them here, should you wish to parse them. fgh=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 }. ij:USB specification release number in binary-coded decimal. k"USB-IF class code for the device. l6USB-IF subclass code for the device, qualified by the k  value. m6USB-IF protocol code for the device, qualified by the k  and l values. n$Maximum packet size for endpoint 0. oUSB-IF vendor ID. pUSB-IF product ID. q/Device release number in binary-coded decimal. r4Index of string descriptor describing manufacturer. s/Index of string descriptor describing product. t<Index of string descriptor containing device serial number. u#Number of possible configurations. v0List of configurations supported by the device. w-Identifier for interface alternate settings. Can be retrieved by P. xIdentifier for interfaces. Can be retrieved by O. yIdentifier for configurations. Can be retrieved by  or by _. z5Abstract type representing a handle of a USB device. You can acquire a handle from . $A device handle is used to perform I/+O and other operations. When finished with 0a device handle you should close it by applying  to it. { Retrieve the | from the z. |@Abstract type representing a USB device detected on the system. *You can only obtain a USB device from the  function. ICertain operations can be performed on a device, but in order to do any I/O you will have to first obtain a z using . Alternatively you  can use the usb-safe8 package which provides type-safe device handling. See:  +http://hackage.haskell.org/package/usb-safe 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 Joperate such device or another process or driver may be using the device. MTo get additional information about a device you can retrieve its descriptor using }. This reference to the  is needed so that it won't ( get garbage collected. The finalizer  p'libusb_exit is # run only when all references to Devices are gone. }"Get the descriptor of the device. ~Message verbosity .Informational messages are printed to stdout, 4 warning and error messages are printed to stderr 1Warning and error messages are printed to stderr %Error messages are printed to stderr ,No messages are ever printed by the library *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  and are automatically closed !when they are garbage collected. "The only functions that receive a Ctx are  and . )Create and initialize a new USB context. This function may throw s. Set message verbosity. The default level is ". This means no messages are ever Oprinted. If you choose to increase the message verbosity level you must ensure )that your application does not close the stdout/stderr file descriptors. *You are advised to set the debug level to  . Libusb is Iconservative with its message logging. Most of the time it will only log Nmessages that explain error conditions and other oddities. This will help you debug your software. LThe LIBUSB_DEBUG environment variable overrules the debug level set by this Ifunction. The message verbosity is fixed to the value in the environment variable if it is defined. If libusbG was compiled without any message logging, this function does nothing: you'll never get any messages. If libusbE was compiled with verbose debug message logging, this function does  nothing: you'(ll always get messages from all levels. @Returns a list of USB devices currently attached to the system. 4This is your entry point into finding a USB device.  Exceptions:  ! on a memory allocation failure. 5The number of the bus that a device is connected to. 9The address of the device on the bus it is connected to. *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 advisable 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 | 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 value 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). OIf 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.  Another . +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. NA configuration value of -1 will put the device in an unconfigured state. The LUSB specification states that a configuration value of 0 does this, however ;buggy devices 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. QIt is legal to attempt to claim an already-claimed interface, in which case this .function 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.  Exceptions:   , if the requested interface does not exist.   & if the interface is already claimed.   & 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 . withClaimedInterface6 claims the interface on the given device handle then -executes the given computation. On exit from withClaimedInterface, the Pinterface is released 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 withInterfaceHandle. 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 . (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 . -A handle for the device to communicate with. The type of request. The recipient of the request.  Request. Value. Index. 4Timeout (in milliseconds) that this function should 2 wait before giving up due to no response being + received. For no timeout, use value 0. Perform a USB control read. The value and index3 values should be given in host-endian byte order.  Exceptions:  8 if the control request was not supported by the device   & if the device has been disconnected.  Another . -A handle for the device to communicate with. The type of request. The recipient of the request.  Request. Value. Index. Perform a USB control write. The value and index3 values should be given in host-endian byte order.  Exceptions:  8 if the control request was not supported by the device   & if the device has been disconnected.  Another . -A handle for the device to communicate with. The type of request. The recipient of the request.  Request. Value. Index. !See: USB 2.0 Spec. section 9.4.9 !See: USB 2.0 Spec. section 9.4.1 !See: USB 2.0 Spec. section 9.4.9 !See: USB 2.0 Spec. section 9.4.9 . TODO: What about vendor-specific test modes? !See: USB 2.0 Spec. section 9.4.4 !See: USB 2.0 Spec. section 9.4.5 !See: USB 2.0 Spec. section 9.4.5 !See: USB 2.0 Spec. section 9.4.6 "See: USB 2.0 Spec. section 9.4.11 Perform a USB bulk read.  Exceptions:   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 . -A handle for the device to communicate with. The address of a valid > and 9 endpoint / to communicate with. Make sure the endpoint 1 belongs to the current alternate setting of a 2 claimed interface which belongs to the device. Perform a USB bulk write.  Exceptions:   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 . -A handle for the device to communicate with. The address of a valid ? and 9 / endpoint to communicate with. Make sure the - endpoint belongs to the current alternate 3 setting of a claimed interface which belongs to  the device. Perform a USB  interrupt read.  Exceptions:   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 . 'A handle for the device to communicate  with. The address of a valid > and 8 / endpoint to communicate with. Make sure the - endpoint belongs to the current alternate ( setting of a claimed interface which  belongs to the device. Perform a USB  interrupt write.  Exceptions:   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 . 'A handle for the device to communicate  with. The address of a valid ? and  8 endpoint to communicate + with. Make sure the endpoint belongs to . the current alternate setting of a claimed * interface which belongs to the device. 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.  Decode a Word163 as a Binary Coded Decimal using 4 bits per digit. 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.  between n b e tests if n is between the given bounds b and e  (including). 0Execute the given action but ignore the result. A generalized  that works on any  type. A generalized  that returns any  type. mapPeekArray f n a applies the monadic function f to each of the n  elements of the array a$ and returns the results in a list. input  doWrite first converts the input  ByteString to an  array of Word8s, then doWrite+ is executed by pointing it to the size of 9 this array and the array itself. 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). Monadic if...then...else...   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~    !"#$%&)(''()*+,-+,-.10//012654334567;:9889:;<=?>>?@ABCABCDEFGHIJKLEFGHIJKLM NOPQRSTUVNOPQRSTUVWXYZXYZ[\]^_`abcde^_`abcdefghijklmnopqrstuvijklmnopqrstuvwxyz{{|}}~#Bas van Dijk <v.dijk.bas@gmail.com>  #Bas van Dijk <v.dijk.bas@gmail.com># !#! #Bas van Dijk <v.dijk.bas@gmail.com>Y"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvYhijklmnopqrstuvgf]^_`abcde\[WXYZMNOPQRSTUVDEFGHIJKL@ABC=?><7;:9826543.10/*+,-&)('%$#"#Bas van Dijk <v.dijk.bas@gmail.com>wxyz{z{{yxw#Bas van Dijk <v.dijk.bas@gmail.com>-A handle for the device to communicate with. The address of a valid In and Bulk / endpoint to communicate with. Make sure the - endpoint belongs to the current alternate 0 setting of a claimed interface which belongs  to the device. -Timeout (in milliseconds) that this function / should wait for each chunk before giving up . due to no response being received. For no  timeout, use value 0. +Chunk size. A good value for this would be  the endpointMaxPacketSize. 'A handle for the device to communicate  with. The address of a valid In and   Interrupt endpoint to communicate + with. Make sure the endpoint belongs to & the current alternate setting of a * claimed interface which belongs to the  device. $Timeout (in milliseconds) that this ' function should wait for each chunk ' before giving up due to no response ( being received. For no timeout, use  value 0. (Chunk size. A good value for this would  be the endpointMaxPacketSize. #Bas van Dijk <v.dijk.bas@gmail.com>|}|}}#Bas van Dijk <v.dijk.bas@gmail.com>~~ #Bas van Dijk <v.dijk.bas@gmail.com>  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     !"#$%&'()*+,-./01234456789:;<=>?@ABCDEFGHIIJKLLMNOPQRSTTUVWXYZ[\]]^_`abbcdefghijkllmnopqrstuvwxyz{|}~} usb-0.3.1System.USB.DescriptorsSystem.USB.ExceptionsSystem.USB.IO.SynchronousSystem.USB.DeviceHandlingSystem.USB.EnumerationSystem.USB.Initialization$System.USB.IO.Synchronous.EnumeratorSystem.USB.Internal System.USBBCD4 USBExceptionOtherExceptionNotSupportedExceptionNoMemExceptionInterruptedException PipeExceptionOverflowExceptionTimeoutException BusyExceptionNotFoundExceptionNoDeviceExceptionAccessExceptionInvalidParamException IOExceptionTestModeTest_Force_Enable Test_Packet Test_SE0_NAKTest_KTest_J RecipientToOther ToEndpoint ToInterfaceToDevice RequestTypeVendorClassStandardSizeTimeout WriteAction ReadActionStrIx SubLangId PrimaryLangIdLangIdTransactionOpportunitiesTwoOneZero MaxPacketSize maxPacketSizetransactionOpportunitiesUsageImplicitFeedbackDataSynchronization SynchronousAdaptive AsynchronousNoSynchronization TransferType InterruptBulk IsochronousControlEndpointAttribsTransferDirectionInOutEndpointAddressendpointNumbertransferDirection EndpointDescendpointAddressendpointAttribsendpointMaxPacketSizeendpointIntervalendpointRefreshendpointSynchAddress endpointExtra InterfaceDescinterfaceNumberinterfaceAltSettinginterfaceClassinterfaceSubClassinterfaceProtocolinterfaceStrIxinterfaceEndpointsinterfaceExtra DeviceStatus remoteWakeup selfPowered ConfigAttribs Interface ConfigDesc configValue configStrIx configAttribsconfigMaxPowerconfigNumInterfacesconfigInterfaces configExtra ProductIdVendorId DeviceDescdeviceUSBSpecReleaseNumber deviceClassdeviceSubClassdeviceProtocoldeviceMaxPacketSize0deviceVendorIddeviceProductIddeviceReleaseNumberdeviceManufacturerStrIxdeviceProductStrIxdeviceSerialNumberStrIxdeviceNumConfigs deviceConfigsInterfaceAltSettingInterfaceNumber ConfigValue DeviceHandle getDeviceDevice deviceDesc Verbosity PrintInfo PrintWarnings PrintErrors PrintNothingCtxnewCtxsetDebug getDevices busNumber deviceAddress openDevice closeDevicewithDeviceHandle getConfig setConfigclaimInterfacereleaseInterfacewithClaimedInterfacesetInterfaceAltSetting clearHalt resetDevicekernelDriverActivedetachKernelDriverattachKernelDriverwithDetachedKernelDriver getLanguages getStrDescgetStrDescFirstLangcontrol readControl writeControlsetHaltclearRemoteWakeupsetRemoteWakeupsetStandardTestModegetInterfaceAltSettinggetDeviceStatusgetEndpointStatussetDeviceAddress synchFramereadBulk writeBulk readInterruptwriteInterrupt enumReadBulkenumReadInterruptC'TransferFuncbytestring-0.9.1.7Data.ByteString.Internal ByteStringghc-prim GHC.TypesIO getDevHndlPtr_ctx getDevFrgnPtrunCtx withCtxPtr withDevicePtr getDeviceDescconvertDeviceDesc getConfigDescconvertConfigDescunmarshalConfigAttribsgetExtraconvertInterfaceconvertInterfaceDescconvertEndpointDescunmarshalEndpointAddressmarshalEndpointAddressunmarshalEndpointAttribsunmarshalMaxPacketSizestrDescHeaderSize putStrDescunmarshalLangId marshalLangIdmarshalRequestTyperemoteWakeupFeature haltFeaturetestModeFeature readTransfer writeTransfertransferhandleUSBExceptioncheckUSBExceptionconvertUSBExceptionbaseGHC.ErrerrorunknownLibUsbErrorlibusb_error_to_USBExceptionbindings-libusb-1.4Bindings.Libusb.MiscellaneousC'libusb_error unmarshalBCD4 decodeBCDbitsbetweenvoid genToEnumGHC.EnumtoEnumGHC.RealIntegral genFromEnumfromEnum mapPeekArray writeWithifMenumRead genAllocagenAllocaBytes bracketIO