usb-safe: Type-safe communication with USB devices.
The usb
package provides a standard Haskell abstraction layer over
bindings-libusb
providing: abstract types instead of Ptr
s, automatic
marshalling and unmarshalling, automatic garbage collection,
exceptions instead of integer return codes, etc..
While all that is very nice there are still some things that you can do wrong. For example doing I/O with a closed device or reading from or writing to an endpoint which doesn't belong to the claimed interface. Or reading from an Out endpoint or writing to an In endpoint.
usb-safe
provides the following guarantees:
You can't reference handles to devices that are closed. In other words: no I/O with closed handles is possible.
The programmer specifies the region in which devices should remain open. On exit from the region the opened devices will be closed automatically.
You can't reference handles to configurations that have not been set.
You can't reference handles to interfaces that have not been claimed.
Just like with devices, the programmer can specify the region in which interfaces should remain claimed. On exit from the region the claimed interfaces will be released automatically.
You can't reference handles to alternates that have not been set.
You can't reference endpoints that don't belong to a setted alternate.
You can't read from an endpoint with an Out transfer direction.
You can't write to an endpoint with an In transfer direction.
The primary technique used in usb-safe is called "Lightweight monadic regions" which was invented by Oleg Kiselyov and Chung-chieh Shan. See:
http://okmij.org/ftp/Haskell/regions.html#light-weight
This technique is implemented in the regions
package which is
re-exported from usb-safe
.
See the usb-safe-examples
package for examples how to use this library:
git clone https://github.com/basvandijk/usb-safe-examples
[Skip to Readme]
Downloads
- usb-safe-0.14.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1, 0.2, 0.3, 0.4, 0.4.1, 0.5, 0.5.1, 0.5.1.1, 0.6, 0.7, 0.8, 0.9, 0.10, 0.11, 0.11.0.1, 0.11.0.2, 0.12, 0.13, 0.14 |
---|---|
Change log | NEWS |
Dependencies | base (>=4 && <4.5), base-unicode-symbols (>=0.1.1 && <0.3), bindings-libusb (>=1.3 && <1.5), bytestring (>=0.9 && <0.10), iteratee (>=0.4 && <0.9), regions (>=0.11 && <0.12), text (>=0.5 && <0.12), transformers (>=0.2 && <0.3), usb (>=1.0 && <1.1) [details] |
License | BSD-3-Clause |
Copyright | 2009–2010 Bas van Dijk |
Author | Bas van Dijk <v.dijk.bas@gmail.com> |
Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
Category | System, Monadic Regions |
Home page | https://github.com/basvandijk/usb-safe/ |
Bug tracker | https://github.com/basvandijk/usb-safe/issues |
Source repo | head: git clone git://github.com/basvandijk/usb-safe.git |
Uploaded | by BasVanDijk at 2011-09-23T10:11:31Z |
Distributions | |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Downloads | 12503 total (62 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs uploaded by user Build status unknown [no reports yet] |