usb- Communicate with USB devicesSource codeContentsIndex
MaintainerBas van Dijk <>
This module provides functionality for initializing this usb library.
data Ctx
newCtx :: IO Ctx
setDebug :: Ctx -> Verbosity -> IO ()
data Verbosity
= PrintNothing
| PrintErrors
| PrintWarnings
| PrintInfo
data Ctx Source

Abstract type representing a USB session.

The concept of individual sessions allows your program to use multiple threads that can independently use this library without interfering with eachother.

Sessions are created and initialized by newCtx and are automatically closed when garbage collected.

The only functions that receive a Ctx are setDebug and getDevices.

newCtx :: IO CtxSource

Create and initialize a new USB context.

This function may throw USBExceptions.

setDebug :: Ctx -> Verbosity -> IO ()Source

Set message verbosity.

The default level is PrintNothing, which means no messages are ever printed. 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 PrintWarnings. libusb is conservative with its message logging and most of the time, will only log messages that explain error conditions and other oddities. This will help you debug your software.

If the LIBUSB_DEBUG environment variable was set when libusb was initialized, this function does nothing: the message verbosity is fixed to the value in the environment variable.

If libusb was compiled without any message logging, this function does nothing: you'll never get any messages.

If libusb was compiled with verbose debug message logging, this function does nothing: you'll always get messages from all levels.

data Verbosity Source
Message verbosity
PrintNothingNo messages are ever printed by the library
PrintErrorsError messages are printed to stderr
PrintWarningsWarning and error messages are printed to stderr
PrintInfoInformational messages are printed to stdout, warning and error messages are printed to stderr
show/hide Instances
Produced by Haddock version 2.6.0