usb 1.1.0.2 → 1.1.0.3
raw patch · 13 files changed
+83/−81 lines, 13 filesdep +ghc-primdep ~basedep ~bytestring
Dependencies added: ghc-prim
Dependency ranges changed: base, bytestring
Files
- LICENSE +1/−1
- System/USB.hs +1/−1
- System/USB/Base.hs +44/−36
- System/USB/Descriptors.hs +1/−1
- System/USB/DeviceHandling.hs +1/−1
- System/USB/Enumeration.hs +1/−1
- System/USB/Exceptions.hs +1/−1
- System/USB/IO.hs +1/−1
- System/USB/IO/StandardDeviceRequests.hs +1/−1
- System/USB/Initialization.hs +1/−1
- System/USB/Internal.hs +1/−1
- Utils.hs +2/−2
- usb.cabal +27/−33
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2009–2011 Bas van Dijk+Copyright (c) 2009–2012 Bas van Dijk All rights reserved.
System/USB.hs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD-style (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
System/USB/Base.hs view
@@ -13,6 +13,10 @@ {-# LANGUAGE PatternGuards #-} #endif +#ifdef GENERICS+{-# LANGUAGE DeriveGeneric #-}+#endif+ module System.USB.Base where --------------------------------------------------------------------------------@@ -128,6 +132,15 @@ -------------------------------------------------------------------------------- +#ifdef GENERICS+import GHC.Generics ( Generic )+#define COMMON_INSTANCES Show, Read, Eq, Data, Typeable, Generic+#else+#define COMMON_INSTANCES Show, Read, Eq, Data, Typeable+#endif++--------------------------------------------------------------------------------+ #if MIN_VERSION_base(4,3,0) import Control.Exception ( mask, mask_ ) #else@@ -145,8 +158,6 @@ mask_ = block #endif -#define COMMON_INSTANCES Show, Read, Eq, Data, Typeable- -------------------------------------------------------------------------------- -- * Initialization --------------------------------------------------------------------------------@@ -169,9 +180,6 @@ getCtxFrgnPtr ∷ !(ForeignPtr C'libusb_context) } deriving Typeable --- | A function to wait for the termination of a submitted transfer.-type Wait = Timeout → Lock → Ptr C'libusb_transfer → IO ()- instance Eq Ctx where (==) = (==) `on` getCtxFrgnPtr withCtxPtr ∷ Ctx → (Ptr C'libusb_context → IO α) → IO α@@ -196,6 +204,9 @@ #else -------------------------------------------------------------------------------- +-- | A function to wait for the termination of a submitted transfer.+type Wait = Timeout → Lock → Ptr C'libusb_transfer → IO ()+ {-| Create and initialize a new USB context. This function may throw 'USBException's.@@ -354,9 +365,8 @@ Certain operations can be performed on a device, but in order to do any I/O you will have to first obtain a 'DeviceHandle' using 'openDevice'. Alternatively you-can use the @usb-safe@ package which provides type-safe device handling. See:--<http://hackage.haskell.org/package/usb-safe>+can use the <http://hackage.haskell.org/package/usb-safe usb-safe> package+which provides type-safe device handling. Just because you have a reference to a device does not mean it is necessarily usable. The device may have been unplugged, you may not have permission to@@ -1183,10 +1193,9 @@ } -- | Unmarshal a a 16bit word as a release number. The 16bit word should be--- encoded as a Binary Coded Decimal using 4 bits for each of the 4--- decimals. Also see:------ <http://en.wikipedia.org/wiki/Binary-coded_decimal>+-- encoded as a+-- <http://en.wikipedia.org/wiki/Binary-coded_decimal Binary Coded Decimal>+-- using 4 bits for each of the 4 decimals. unmarshalReleaseNumber ∷ Word16 → ReleaseNumber unmarshalReleaseNumber abcd = (a, b, c, d) where@@ -1394,9 +1403,8 @@ <http://www.usb.org/developers/docs/USB_LANGIDs.pdf> -For a mapping between IDs and languages see the @usb-id-database@ package at:--<http://hackage.haskell.org/package/usb-id-database>+For a mapping between IDs and languages see the+<http://hackage.haskell.org/package/usb-id-database usb-id-database> package. To see which 'LangId's are supported by a device see 'getLanguages'. -}@@ -1714,9 +1722,9 @@ * 'PipeException' if the endpoint halted. - * 'OverflowException' if the device offered more data,- see /Packets and overflows/ in the @libusb@ documentation:- <http://libusb.sourceforge.net/api-1.0/packetoverflow.html>.+ * 'OverflowException' if the device offered more data, see+ <http://libusb.sourceforge.net/api-1.0/packetoverflow.html Packets and overflows>+ in the @libusb@ documentation. * 'NoDeviceException' if the device has been disconnected. @@ -1736,9 +1744,9 @@ * 'PipeException' if the endpoint halted. - * 'OverflowException' if the device offered more data,- see /Packets and overflows/ in the @libusb@ documentation:- <http://libusb.sourceforge.net/api-1.0/packetoverflow.html>.+ * 'OverflowException' if the device offered more data, see+ <http://libusb.sourceforge.net/api-1.0/packetoverflow.html Packets and overflows>+ in the @libusb@ documentation. * 'NoDeviceException' if the device has been disconnected. @@ -1762,9 +1770,9 @@ * 'PipeException' if the endpoint halted. - * 'OverflowException' if the device offered more data,- see /Packets and overflows/ in the libusb documentation:- <http://libusb.sourceforge.net/api-1.0/packetoverflow.html>.+ * 'OverflowException' if the device offered more data, see+ <http://libusb.sourceforge.net/api-1.0/packetoverflow.html Packets and overflows>+ in the @libusb@ documentation. * 'NoDeviceException' if the device has been disconnected. @@ -1785,9 +1793,9 @@ * 'PipeException' if the endpoint halted. - * 'OverflowException' if the device offered more data,- see /Packets and overflows/ in the @libusb@ documentation:- <http://libusb.sourceforge.net/api-1.0/packetoverflow.html>.+ * 'OverflowException' if the device offered more data, see+ <http://libusb.sourceforge.net/api-1.0/packetoverflow.html Packets and overflows>+ in the @libusb@ documentation. * 'NoDeviceException' if the device has been disconnected. @@ -2030,9 +2038,9 @@ * 'PipeException' if the endpoint halted. - * 'OverflowException' if the device offered more data,- see /Packets and overflows/ in the @libusb@ documentation:- <http://libusb.sourceforge.net/api-1.0/packetoverflow.html>.+ * 'OverflowException' if the device offered more data, see+ <http://libusb.sourceforge.net/api-1.0/packetoverflow.html Packets and overflows>+ in the @libusb@ documentation. * 'NoDeviceException' if the device has been disconnected. @@ -2071,9 +2079,9 @@ * 'PipeException' if the endpoint halted. - * 'OverflowException' if the device offered more data,- see /Packets and overflows/ in the @libusb@ documentation:- <http://libusb.sourceforge.net/api-1.0/packetoverflow.html>.+ * 'OverflowException' if the device offered more data, see+ <http://libusb.sourceforge.net/api-1.0/packetoverflow.html Packets and overflows>+ in the @libusb@ documentation. * 'NoDeviceException' if the device has been disconnected. @@ -2218,9 +2226,9 @@ | NotFoundException -- ^ Entity not found. | BusyException -- ^ Resource busy. | TimeoutException -- ^ Operation timed out.- | OverflowException -- ^ If the device offered to much data.- -- See /Packets and overflows/ in the @libusb@ documentation:- -- <http://libusb.sourceforge.net/api-1.0/packetoverflow.html>+ | OverflowException -- ^ If the device offered to much data. See+ -- <http://libusb.sourceforge.net/api-1.0/packetoverflow.html Packets and overflows> in the @libusb@ documentation.+ -- | PipeException -- ^ Pipe exception. | InterruptedException -- ^ System call interrupted (perhaps due to signal). | NoMemException -- ^ Insufficient memory.
System/USB/Descriptors.hs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB.Descriptors--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD3 (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
System/USB/DeviceHandling.hs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB.Devices--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD3 (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
System/USB/Enumeration.hs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB.Devices--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD3 (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
System/USB/Exceptions.hs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB.Exceptions--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD3 (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
System/USB/IO.hs view
@@ -7,7 +7,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB.IO--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD3 (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
System/USB/IO/StandardDeviceRequests.hs view
@@ -7,7 +7,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB.IO.StandardDeviceRequests--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD3 (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
System/USB/Initialization.hs view
@@ -7,7 +7,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB.Init--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD3 (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
System/USB/Internal.hs view
@@ -7,7 +7,7 @@ -------------------------------------------------------------------------------- -- | -- Module : System.USB.Unsafe--- Copyright : (c) 2009–2011 Bas van Dijk+-- Copyright : (c) 2009–2012 Bas van Dijk -- License : BSD3 (see the file LICENSE) -- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com> --
Utils.hs view
@@ -11,7 +11,7 @@ -------------------------------------------------------------------------------- -- from base:-import Prelude ( (+), (-), Enum, toEnum, fromEnum, Integral, fromIntegral )+import Prelude ( Num, (+), (-), Enum, toEnum, fromEnum, Integral, fromIntegral ) #if __GLASGOW_HASKELL__ < 700 import Prelude ( fromInteger )@@ -39,7 +39,7 @@ -------------------------------------------------------------------------------- -- | @bits s e b@ extract bit @s@ to @e@ (including) from @b@.-bits ∷ Bits α ⇒ Int → Int → α → α+bits ∷ (Bits α, Num α) ⇒ Int → Int → α → α bits s e b = ((1 `shiftL` (e - s + 1)) - 1) .&. (b `shiftR` s) -- | @between n b e@ tests if @n@ is between the given bounds @b@ and @e@
usb.cabal view
@@ -1,5 +1,5 @@ name: usb-version: 1.1.0.2+version: 1.1.0.3 cabal-version: >=1.6 build-type: Custom license: BSD3@@ -13,8 +13,9 @@ synopsis: Communicate with USB devices description: This library enables you to communicate with USB devices from userspace. It is implemented as a high-level wrapper around- @bindings-libusb@ which is a low-level binding to the C library:- @libusb-1.*@.+ <http://hackage.haskell.org/package/bindings-libusb bindings-libusb>+ which is a low-level binding to the C library:+ <http://libusb.org/ libusb-1.*>. . The USB transfer functions in this library have a simple synchronous interface (they block) but are implemented using the @libusb@@@ -30,45 +31,34 @@ This documentation assumes knowledge of how to operate USB devices from a software standpoint (descriptors, configurations, interfaces, endpoints, control\/bulk\/interrupt\/isochronous- transfers, etc). Full information can be found in the USB 2.0- Specification.- .- For an example how to use this library see the @usb-example@- package at:- .- <https://github.com/basvandijk/usb-example>- .- or the @ls-usb@ package at:- .- <http://hackage.haskell.org/package/ls-usb>- .- Also see the @usb-safe@ package which wraps this package and- provides some strong safety guarantees for working with USB- devices:+ transfers, etc). Full information can be found in the+ <http://www.usb.org/developers/docs/ USB 2.0 specification>. .- <http://hackage.haskell.org/package/usb-safe>+ For an example how to use this library see the+ <https://github.com/basvandijk/usb-example usb-example> package+ or the <http://hackage.haskell.org/package/ls-usb ls-usb> package. .- Finally have a look at the @usb-iteratee@ package which- provides @iteratee@ enumerators for enumerating bulk, interrupt- and isochronous endpoints:+ Also see the <http://hackage.haskell.org/package/usb-safe usb-safe>+ package which wraps this package and provides some strong safety+ guarantees for working with USB devices. .- <http://hackage.haskell.org/package/usb-iteratee>+ Finally have a look at the+ <http://hackage.haskell.org/package/usb-iteratee usb-iteratee>+ package which provides @iteratee@ enumerators for enumerating+ bulk, interrupt and isochronous endpoints: . Besides this API documentation the following sources might be interesting: .- * The libusb 1.0 documentation at:- <http://libusb.sourceforge.net/api-1.0/>+ * <http://libusb.sourceforge.net/api-1.0/ The libusb 1.0 documentation>. .- * The USB 2.0 specification at:- <http://www.usb.org/developers/docs/>+ * <http://www.usb.org/developers/docs/ The USB 2.0 specification>. .- * The @bindings-libusb@ documentation at:- <http://hackage.haskell.org/package/bindings-libusb>+ * <http://hackage.haskell.org/package/bindings-libusb The bindings-libusb documentation>. .- * \"USB in a NutShell\" at:- <http://www.beyondlogic.org/usbnutshell/usb1.htm>+ * <http://www.beyondlogic.org/usbnutshell/usb1.htm "USB in a NutShell">. + extra-source-files: README.markdown, NEWS source-repository head@@ -78,10 +68,10 @@ Library GHC-Options: -Wall - build-depends: base >= 4 && < 4.6+ build-depends: base >= 4 && < 4.7 , base-unicode-symbols >= 0.1.1 && < 0.3 , bindings-libusb >= 1.4.4 && < 1.5- , bytestring >= 0.9 && < 0.10+ , bytestring >= 0.9 && < 0.11 , text >= 0.5 && < 0.12 exposed-modules: System.USB@@ -99,3 +89,7 @@ cpp-options: -DHAS_EVENT_MANAGER other-modules: Poll, Event, SystemEventManager, Timeval build-depends: containers >= 0.1 && < 0.6++ if impl(ghc >= 7.2.1)+ cpp-options: -DGENERICS+ build-depends: ghc-prim >= 0.2 && < 0.4