usb-0.1: Communicate with USB devicesSource codeContentsIndex
System.USB.Descriptors
Contents
Device descriptor
Querying device descriptors
Configuration descriptor
Querying configuration descriptors
Interface descriptor
Querying interface descriptors
Endpoint descriptor
Querying endpoint descriptors
String descriptors
Synopsis
data DeviceDesc
getDeviceDesc :: Device -> IO DeviceDesc
deviceUSBSpecReleaseNumber :: DeviceDesc -> BCD4
type BCD4 = (Int, Int, Int, Int)
deviceClass :: DeviceDesc -> Word8
deviceSubClass :: DeviceDesc -> Word8
deviceProtocol :: DeviceDesc -> Word8
deviceMaxPacketSize0 :: DeviceDesc -> Word8
deviceVendorId :: DeviceDesc -> VendorId
type VendorId = Word16
deviceProductId :: DeviceDesc -> ProductId
type ProductId = Word16
deviceReleaseNumber :: DeviceDesc -> BCD4
deviceManufacturerStrIx :: DeviceDesc -> StrIx
deviceProductStrIx :: DeviceDesc -> StrIx
deviceSerialNumberStrIx :: DeviceDesc -> StrIx
deviceNumConfigs :: DeviceDesc -> Word8
data ConfigDesc
getActiveConfigDesc :: Device -> IO ConfigDesc
getConfigDesc :: Device -> Word8 -> IO ConfigDesc
getConfigDescByValue :: Device -> ConfigValue -> IO ConfigDesc
configValue :: ConfigDesc -> ConfigValue
configStrIx :: ConfigDesc -> StrIx
configAttribs :: ConfigDesc -> ConfigAttribs
type ConfigAttribs = DeviceStatus
data DeviceStatus = DeviceStatus {
remoteWakeup :: Bool
selfPowered :: Bool
}
configMaxPower :: ConfigDesc -> Word8
configNumInterfaces :: ConfigDesc -> Word8
configInterfaces :: ConfigDesc -> [[InterfaceDesc]]
configExtra :: ConfigDesc -> ByteString
data InterfaceDesc
interfaceNumber :: InterfaceDesc -> InterfaceNumber
interfaceAltSetting :: InterfaceDesc -> InterfaceAltSetting
interfaceClass :: InterfaceDesc -> Word8
interfaceSubClass :: InterfaceDesc -> Word8
interfaceProtocol :: InterfaceDesc -> Word8
interfaceStrIx :: InterfaceDesc -> StrIx
interfaceNumEndpoints :: InterfaceDesc -> Word8
interfaceEndpoints :: InterfaceDesc -> [EndpointDesc]
interfaceExtra :: InterfaceDesc -> ByteString
data EndpointDesc
endpointAddress :: EndpointDesc -> EndpointAddress
data EndpointAddress = EndpointAddress {
endpointNumber :: Int
endpointDirection :: TransferDirection
}
data TransferDirection
= Out
| In
endpointAttribs :: EndpointDesc -> EndpointAttribs
type EndpointAttribs = TransferType
data TransferType
= Control
| Isochronous Synchronization Usage
| Bulk
| Interrupt
data Synchronization
= NoSynchronization
| Asynchronous
| Adaptive
| Synchronous
data Usage
= Data
| Feedback
| Implicit
endpointMaxPacketSize :: EndpointDesc -> MaxPacketSize
data MaxPacketSize = MaxPacketSize {
maxPacketSize :: Int
transactionOpportunities :: TransactionOpportunities
}
data TransactionOpportunities
= NoAdditionalTransactions
| OneAdditionlTransaction
| TwoAdditionalTransactions
endpointInterval :: EndpointDesc -> Word8
endpointRefresh :: EndpointDesc -> Word8
endpointSynchAddress :: EndpointDesc -> Word8
endpointExtra :: EndpointDesc -> ByteString
getLanguages :: DeviceHandle -> IO [LangId]
type LangId = (PrimaryLangId, SubLangId)
type PrimaryLangId = Word16
type SubLangId = Word16
type StrIx = Word8
getStrDesc :: DeviceHandle -> StrIx -> LangId -> Size -> IO String
getStrDescFirstLang :: DeviceHandle -> StrIx -> Size -> IO String
Device descriptor
data DeviceDesc Source

A structure representing the standard USB device descriptor.

This descriptor is documented in section 9.6.1 of the USB 2.0 specification.

This structure can be retrieved by getDeviceDesc.

show/hide Instances
getDeviceDesc :: Device -> IO DeviceDescSource

Get the USB device descriptor for a given device.

This is a non-blocking function; the device descriptor is cached in memory.

This function may throw USBExceptions.

Querying device descriptors
deviceUSBSpecReleaseNumber :: DeviceDesc -> BCD4Source
USB specification release number in binary-coded decimal.
type BCD4 = (Int, Int, Int, Int)Source
A decoded 16 bits Binary Coded Decimal using 4 bits for each digit.
deviceClass :: DeviceDesc -> Word8Source
USB-IF class code for the device.
deviceSubClass :: DeviceDesc -> Word8Source
USB-IF subclass code for the device, qualified by the deviceClass value.
deviceProtocol :: DeviceDesc -> Word8Source
USB-IF protocol code for the device, qualified by the deviceClass and deviceSubClass values.
deviceMaxPacketSize0 :: DeviceDesc -> Word8Source
Maximum packet size for endpoint 0.
deviceVendorId :: DeviceDesc -> VendorIdSource
USB-IF vendor ID.
type VendorId = Word16Source
For a database of USB vendors and products see the usb-id-database package at: http://hackage.haskell.org/package/usb-id-database
deviceProductId :: DeviceDesc -> ProductIdSource
USB-IF product ID.
type ProductId = Word16Source
deviceReleaseNumber :: DeviceDesc -> BCD4Source
Device release number in binary-coded decimal.
deviceManufacturerStrIx :: DeviceDesc -> StrIxSource
Index of string descriptor describing manufacturer.
deviceProductStrIx :: DeviceDesc -> StrIxSource
Index of string descriptor describing product.
deviceSerialNumberStrIx :: DeviceDesc -> StrIxSource
Index of string descriptor containing device serial number.
deviceNumConfigs :: DeviceDesc -> Word8Source
Number of possible configurations.
Configuration descriptor
data ConfigDesc Source

A structure representing the standard USB configuration descriptor.

This descriptor is documented in section 9.6.3 of the USB 2.0 specification.

This structure can be retrieved by getActiveConfigDesc, getConfigDesc or getConfigDescByValue.

show/hide Instances
getActiveConfigDesc :: Device -> IO ConfigDescSource

Get the USB configuration descriptor for the currently active configuration.

This is a non-blocking function which does not involve any requests being sent to the device.

Exceptions:

getConfigDesc :: Device -> Word8 -> IO ConfigDescSource

Get a USB configuration descriptor based on its index.

This is a non-blocking function which does not involve any requests being sent to the device.

Exceptions:

getConfigDescByValue :: Device -> ConfigValue -> IO ConfigDescSource

Get a USB configuration descriptor with a specific configValue.

This is a non-blocking function which does not involve any requests being sent to the device.

Exceptions:

Querying configuration descriptors
configValue :: ConfigDesc -> ConfigValueSource
Identifier value for this configuration.
configStrIx :: ConfigDesc -> StrIxSource
Index of string descriptor describing this configuration.
configAttribs :: ConfigDesc -> ConfigAttribsSource
Configuration characteristics.
type ConfigAttribs = DeviceStatusSource
data DeviceStatus Source
Constructors
DeviceStatus
remoteWakeup :: BoolThe Remote Wakeup field indicates whether the device is currently enabled to request remote wakeup. The default mode for devices that support remote wakeup is disabled.
selfPowered :: BoolThe Self Powered field indicates whether the device is currently self-powered
show/hide Instances
configMaxPower :: ConfigDesc -> Word8Source
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).
configNumInterfaces :: ConfigDesc -> Word8Source
Number of interfaces supported by this configuration.
configInterfaces :: ConfigDesc -> [[InterfaceDesc]]Source
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 configNumInterfaces.
configExtra :: ConfigDesc -> ByteStringSource
Extra descriptors. If libusb encounters unknown configuration descriptors, it will store them here, should you wish to parse them.
Interface descriptor
data InterfaceDesc Source

A structure representing the standard USB interface descriptor.

This descriptor is documented in section 9.6.5 of the USB 2.0 specification.

This structure can be retrieved using configInterfaces.

show/hide Instances
Querying interface descriptors
interfaceNumber :: InterfaceDesc -> InterfaceNumberSource
Number of this interface.
interfaceAltSetting :: InterfaceDesc -> InterfaceAltSettingSource
Value used to select this alternate setting for this interface.
interfaceClass :: InterfaceDesc -> Word8Source
USB-IF class code for this interface.
interfaceSubClass :: InterfaceDesc -> Word8Source
USB-IF subclass code for this interface, qualified by the interfaceClass value.
interfaceProtocol :: InterfaceDesc -> Word8Source
USB-IF protocol code for this interface, qualified by the interfaceClass and interfaceSubClass values.
interfaceStrIx :: InterfaceDesc -> StrIxSource
Index of string descriptor describing this interface.
interfaceNumEndpoints :: InterfaceDesc -> Word8Source
Number of endpoints used by this interface (excluding the control endpoint).
interfaceEndpoints :: InterfaceDesc -> [EndpointDesc]Source
List of endpoint descriptors. Note that the length of this list should equal interfaceNumEndpoints.
interfaceExtra :: InterfaceDesc -> ByteStringSource
Extra descriptors. If libusb encounters unknown interface descriptors, it will store them here, should you wish to parse them.
Endpoint descriptor
data EndpointDesc Source

A structure representing the standard USB endpoint descriptor.

This 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 interfaceEndpoints.

show/hide Instances
Querying endpoint descriptors
endpointAddress :: EndpointDesc -> EndpointAddressSource
The address of the endpoint described by this descriptor.
data EndpointAddress Source
Constructors
EndpointAddress
endpointNumber :: IntMust be >= 0 and <= 15
endpointDirection :: TransferDirection
show/hide Instances
data TransferDirection Source
Direction of data transfer relative to the host.
Constructors
OutHost to device.
InDevice to host.
show/hide Instances
endpointAttribs :: EndpointDesc -> EndpointAttribsSource
Attributes which apply to the endpoint when it is configured using the configValue.
type EndpointAttribs = TransferTypeSource
data TransferType Source
Constructors
Control
Isochronous Synchronization Usage
Bulk
Interrupt
show/hide Instances
data Synchronization Source
Constructors
NoSynchronization
Asynchronous
Adaptive
Synchronous
show/hide Instances
data Usage Source
Constructors
Data
Feedback
Implicit
show/hide Instances
endpointMaxPacketSize :: EndpointDesc -> MaxPacketSizeSource
Maximum packet size this endpoint is capable of sending/receiving.
data MaxPacketSize Source
Constructors
MaxPacketSize
maxPacketSize :: Int
transactionOpportunities :: TransactionOpportunities
show/hide Instances
data TransactionOpportunities Source
Constructors
NoAdditionalTransactions
OneAdditionlTransaction
TwoAdditionalTransactions
show/hide Instances
endpointInterval :: EndpointDesc -> Word8Source
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).
endpointRefresh :: EndpointDesc -> Word8Source
For audio devices only: the rate at which synchronization feedback is provided.
endpointSynchAddress :: EndpointDesc -> Word8Source
For audio devices only: the address if the synch endpoint.
endpointExtra :: EndpointDesc -> ByteStringSource
Extra descriptors. If libusb encounters unknown endpoint descriptors, it will store them here, should you wish to parse them.
String descriptors
getLanguages :: DeviceHandle -> IO [LangId]Source

Retrieve a list of supported languages.

This function may throw USBExceptions.

type LangId = (PrimaryLangId, SubLangId)Source

The language ID consists of the primary language identifier and the sublanguage identififier as described in:

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

To see which LangIds are supported by a device see getLanguages.

type PrimaryLangId = Word16Source
type SubLangId = Word16Source
type StrIx = Word8Source

Type of indici of string descriptors.

Can be retrieved by all the *StrIx functions.

getStrDesc :: DeviceHandle -> StrIx -> LangId -> Size -> IO StringSource

Retrieve a string descriptor from a device.

This is a convenience function which formulates the appropriate control message to retrieve the descriptor. The string returned is Unicode, as detailed in the USB specifications.

This function may throw USBExceptions.

getStrDescFirstLang :: DeviceHandle -> StrIx -> Size -> IO StringSource

Retrieve a string descriptor from a device using the first supported language.

This is a convenience function which formulates the appropriate control message to retrieve the descriptor. The string returned is Unicode, as detailed in the USB specifications.

This function may throw USBExceptions.

Produced by Haddock version 2.4.2