usb-0.3: Communicate with USB devicesSource codeContentsIndex
System.USB.IO.Synchronous
MaintainerBas van Dijk <v.dijk.bas@gmail.com>
Contents
Control transfers
Standard Device Requests
Bulk transfers
Interrupt transfers
Description
Synopsis
type ReadAction = Timeout -> Size -> IO (ByteString, Bool)
type WriteAction = Timeout -> ByteString -> IO (Size, Bool)
type Timeout = Int
type Size = Int
data RequestType
= Standard
| Class
| Vendor
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 an indication if the 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 indication if the transfer timed out.

type Timeout = IntSource
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.
type Size = IntSource
Number of bytes transferred.
Control transfers
data RequestType Source
Constructors
Standard
Class
Vendor
show/hide Instances
data Recipient Source
Constructors
ToDevice
ToInterface
ToEndpoint
ToOther
show/hide Instances
controlSource
:: DeviceHandleA handle for the device to communicate with.
-> RequestTypeThe type of request.
-> RecipientThe recipient of the request.
-> Word8Request.
-> Word16Value.
-> Word16Index.
-> TimeoutTimeout (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:

readControlSource
:: DeviceHandleA handle for the device to communicate with.
-> RequestTypeThe type of request.
-> RecipientThe recipient of the request.
-> Word8Request.
-> Word16Value.
-> Word16Index.
-> ReadAction

Perform a USB control read.

The value and index values should be given in host-endian byte order.

Exceptions:

writeControlSource
:: DeviceHandleA handle for the device to communicate with.
-> RequestTypeThe type of request.
-> RecipientThe recipient of the request.
-> Word8Request.
-> Word16Value.
-> Word16Index.
-> WriteAction

Perform a USB control write.

The value and index values should be given in host-endian byte order.

Exceptions:

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?
data TestMode Source
See: USB 2.0 Spec. table 9-7
Constructors
Test_J
Test_K
Test_SE0_NAK
Test_Packet
Test_Force_Enable
show/hide Instances
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
readBulkSource
:: DeviceHandleA handle for the device to communicate with.
-> EndpointAddressThe address of a valid In and Bulk endpoint to communicate with. Make sure the endpoint belongs to the current alternate setting of a claimed interface which belongs to the device.
-> ReadAction

Perform a USB bulk read.

Exceptions:

writeBulkSource
:: DeviceHandleA handle for the device to communicate with.
-> EndpointAddressThe address of a valid Out and Bulk endpoint to communicate with. Make sure the endpoint belongs to the current alternate setting of a claimed interface which belongs to the device.
-> WriteAction

Perform a USB bulk write.

Exceptions:

Interrupt transfers
readInterruptSource
:: DeviceHandleA handle for the device to communicate with.
-> EndpointAddressThe address of a valid In and Interrupt endpoint to communicate with. Make sure the endpoint belongs to the current alternate setting of a claimed interface which belongs to the device.
-> ReadAction

Perform a USB interrupt read.

Exceptions:

writeInterruptSource
:: DeviceHandleA handle for the device to communicate with.
-> EndpointAddressThe address of a valid Out and Interrupt endpoint to communicate with. Make sure the endpoint belongs to the current alternate setting of a claimed interface which belongs to the device.
-> WriteAction

Perform a USB interrupt write.

Exceptions:

Produced by Haddock version 2.4.2