Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
---|
This module provides functionality for performing control, bulk and interrupt transfers.
- type ReadAction = Timeout -> Size -> IO (ByteString, Bool)
- type WriteAction = Timeout -> ByteString -> IO (Size, Bool)
- type Timeout = Int
- type Size = Int
- data RequestType
- data Recipient
- = ToDevice
- | ToInterface
- | ToEndpoint
- | ToOther
- control :: DeviceHandle -> RequestType -> Recipient -> Word8 -> Word16 -> Word16 -> Timeout -> IO ()
- readControl :: DeviceHandle -> RequestType -> Recipient -> Word8 -> Word16 -> Word16 -> ReadAction
- writeControl :: DeviceHandle -> RequestType -> Recipient -> Word8 -> Word16 -> Word16 -> WriteAction
- setHalt :: DeviceHandle -> EndpointAddress -> Timeout -> IO ()
- clearRemoteWakeup :: DeviceHandle -> Timeout -> IO ()
- setRemoteWakeup :: DeviceHandle -> Timeout -> IO ()
- setStandardTestMode :: DeviceHandle -> TestMode -> Timeout -> IO ()
- data TestMode
- = Test_J
- | Test_K
- | Test_SE0_NAK
- | Test_Packet
- | Test_Force_Enable
- getInterfaceAltSetting :: DeviceHandle -> InterfaceNumber -> Timeout -> IO InterfaceAltSetting
- getDeviceStatus :: DeviceHandle -> Timeout -> IO DeviceStatus
- getEndpointStatus :: DeviceHandle -> EndpointAddress -> Timeout -> IO Bool
- setDeviceAddress :: DeviceHandle -> Word16 -> Timeout -> IO ()
- synchFrame :: DeviceHandle -> EndpointAddress -> Timeout -> IO Int
- readBulk :: DeviceHandle -> EndpointAddress -> ReadAction
- writeBulk :: DeviceHandle -> EndpointAddress -> WriteAction
- readInterrupt :: DeviceHandle -> EndpointAddress -> ReadAction
- writeInterrupt :: DeviceHandle -> EndpointAddress -> WriteAction
Documentation
type ReadAction = Timeout -> Size -> IO (ByteString, Bool)Source
Handy type synonym for read transfers.
A ReadAction
is a function which takes a Timeout
and a Size
which defines
how many bytes to read. The function returns an IO
action which, when
executed, performs the actual read and returns the ByteString
that was read
paired with a flag which indicates whether a transfer timed out.
type WriteAction = Timeout -> ByteString -> IO (Size, Bool)Source
Handy type synonym for write transfers.
A WriteAction
is a function which takes a Timeout
and the ByteString
to
write. The function returns an IO
action which, when exectued, returns the
number of bytes that were actually written paired with an flag which indicates
whether a transfer timed out.
A timeout in millseconds. A timeout defines how long a transfer should wait before giving up due to no response being received. For no timeout, use value 0.
Control transfers
data RequestType Source
:: DeviceHandle | A handle for the device to communicate with. |
-> RequestType | The type of request. |
-> Recipient | The recipient of the request. |
-> Word8 | Request. |
-> Word16 | Value. |
-> Word16 | Index. |
-> Timeout | Timeout (in milliseconds) that this function should wait before giving up due to no response being received. For no timeout, use value 0. |
-> IO () |
Perform a USB control request that does not transfer data.
The value and index values should be given in host-endian byte order.
Exceptions:
-
TimeoutException
if the transfer timed out. -
PipeException
if the control request was not supported by the device -
NoDeviceException
if the device has been disconnected. - Another
USBException
.
:: DeviceHandle | A handle for the device to communicate with. |
-> RequestType | The type of request. |
-> Recipient | The recipient of the request. |
-> Word8 | Request. |
-> Word16 | Value. |
-> Word16 | Index. |
-> ReadAction |
Perform a USB control read.
The value and index values should be given in host-endian byte order.
Exceptions:
-
PipeException
if the control request was not supported by the device -
NoDeviceException
if the device has been disconnected. - Another
USBException
.
:: DeviceHandle | A handle for the device to communicate with. |
-> RequestType | The type of request. |
-> Recipient | The recipient of the request. |
-> Word8 | Request. |
-> Word16 | Value. |
-> Word16 | Index. |
-> WriteAction |
Perform a USB control write.
The value and index values should be given in host-endian byte order.
Exceptions:
-
PipeException
if the control request was not supported by the device -
NoDeviceException
if the device has been disconnected. - Another
USBException
.
Standard Device Requests
setHalt :: DeviceHandle -> EndpointAddress -> Timeout -> IO ()Source
See: USB 2.0 Spec. section 9.4.9
clearRemoteWakeup :: DeviceHandle -> Timeout -> IO ()Source
See: USB 2.0 Spec. section 9.4.1
setRemoteWakeup :: DeviceHandle -> Timeout -> IO ()Source
See: USB 2.0 Spec. section 9.4.9
setStandardTestMode :: DeviceHandle -> TestMode -> Timeout -> IO ()Source
See: USB 2.0 Spec. section 9.4.9 TODO: What about vendor-specific test modes?
See: USB 2.0 Spec. table 9-7
getInterfaceAltSetting :: DeviceHandle -> InterfaceNumber -> Timeout -> IO InterfaceAltSettingSource
See: USB 2.0 Spec. section 9.4.4
getDeviceStatus :: DeviceHandle -> Timeout -> IO DeviceStatusSource
See: USB 2.0 Spec. section 9.4.5
getEndpointStatus :: DeviceHandle -> EndpointAddress -> Timeout -> IO BoolSource
See: USB 2.0 Spec. section 9.4.5
setDeviceAddress :: DeviceHandle -> Word16 -> Timeout -> IO ()Source
See: USB 2.0 Spec. section 9.4.6
synchFrame :: DeviceHandle -> EndpointAddress -> Timeout -> IO IntSource
See: USB 2.0 Spec. section 9.4.11
Bulk transfers
:: DeviceHandle | A handle for the device to communicate with. |
-> EndpointAddress | The address of a valid |
-> ReadAction |
Perform a USB bulk read.
Exceptions:
-
PipeException
if the endpoint halted. -
OverflowException
if the device offered more data, see Packets and overflows in thelibusb
documentation: http://libusb.sourceforge.net/api-1.0/packetoverflow.html. -
NoDeviceException
if the device has been disconnected. - Another
USBException
.
:: DeviceHandle | A handle for the device to communicate with. |
-> EndpointAddress | The address of a valid |
-> WriteAction |
Perform a USB bulk write.
Exceptions:
-
PipeException
if the endpoint halted. -
OverflowException
if the device offered more data, see Packets and overflows in thelibusb
documentation: http://libusb.sourceforge.net/api-1.0/packetoverflow.html. -
NoDeviceException
if the device has been disconnected. - Another
USBException
.
Interrupt transfers
:: DeviceHandle | A handle for the device to communicate with. |
-> EndpointAddress | The address of a valid |
-> ReadAction |
Perform a USB interrupt read.
Exceptions:
-
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. -
NoDeviceException
if the device has been disconnected. - Another
USBException
.
:: DeviceHandle | A handle for the device to communicate with. |
-> EndpointAddress | The address of a valid |
-> WriteAction |
Perform a USB interrupt write.
Exceptions:
-
PipeException
if the endpoint halted. -
OverflowException
if the device offered more data, see Packets and overflows in thelibusb
documentation: http://libusb.sourceforge.net/api-1.0/packetoverflow.html. -
NoDeviceException
if the device has been disconnected. - Another
USBException
.