Copyright | (c) 2009–2017 Bas van Dijk |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
Stability | Experimental |
Safe Haskell | Trustworthy |
Language | Haskell98 |
WARNING: This module is experimental and untested. The API will likely change in future releases.
WARNING: This module is only available on systems which support the GHC
EventManager
.
WARNING: You need to enable the threaded runtime (-threaded
) when using
this module. The functions throw a runtime error otherwise!
This modules provides alternative I/O operations than the ones in System.USB.IO. The difference is that this module separates the construction from the execution of a USB transfer. This has the advantage that a transfer can be constructed once and executed multiple times thereby saving repeated allocation costs.
- data ControlTransfer
- newControlTransfer :: DeviceHandle -> ControlSetup -> Timeout -> IO ControlTransfer
- performControlTransfer :: ControlTransfer -> IO ()
- setControlTransferDeviceHandle :: ControlTransfer -> DeviceHandle -> IO ()
- setControlTransferTimeout :: ControlTransfer -> Timeout -> IO ()
- setControlSetup :: ControlTransfer -> ControlSetup -> IO ()
- getControlTransferDeviceHandle :: ControlTransfer -> IO DeviceHandle
- getControlTransferTimeout :: ControlTransfer -> IO Timeout
- data ControlReadTransfer
- newControlReadTransfer :: DeviceHandle -> ControlSetup -> Size -> Timeout -> IO ControlReadTransfer
- performControlReadTransfer :: ControlReadTransfer -> IO (ByteString, Status)
- setControlReadTransferDeviceHandle :: ControlReadTransfer -> DeviceHandle -> IO ()
- setControlReadTransferTimeout :: ControlReadTransfer -> Timeout -> IO ()
- setControlReadSetup :: ControlReadTransfer -> ControlSetup -> Size -> IO ()
- getControlReadTransferDeviceHandle :: ControlReadTransfer -> IO DeviceHandle
- getControlReadTransferTimeout :: ControlReadTransfer -> IO Timeout
- data ControlWriteTransfer
- newControlWriteTransfer :: DeviceHandle -> ControlSetup -> ByteString -> Timeout -> IO ControlWriteTransfer
- performControlWriteTransfer :: ControlWriteTransfer -> IO (Size, Status)
- setControlWriteTransferDeviceHandle :: ControlWriteTransfer -> DeviceHandle -> IO ()
- setControlWriteTransferTimeout :: ControlWriteTransfer -> Timeout -> IO ()
- setControlWriteSetup :: ControlWriteTransfer -> ControlSetup -> ByteString -> IO ()
- getControlWriteTransferDeviceHandle :: ControlWriteTransfer -> IO DeviceHandle
- getControlWriteTransferTimeout :: ControlWriteTransfer -> IO Timeout
- data RepeatableTransferType
- data ReadTransfer
- newReadTransfer :: RepeatableTransferType -> DeviceHandle -> EndpointAddress -> Size -> Timeout -> IO ReadTransfer
- performReadTransfer :: ReadTransfer -> IO (ByteString, Status)
- setReadTransferType :: ReadTransfer -> RepeatableTransferType -> IO ()
- setReadTransferDeviceHandle :: ReadTransfer -> DeviceHandle -> IO ()
- setReadTransferEndpointAddress :: ReadTransfer -> EndpointAddress -> IO ()
- setReadTransferTimeout :: ReadTransfer -> Timeout -> IO ()
- setReadTransferSize :: ReadTransfer -> Size -> IO ()
- getReadTransferType :: ReadTransfer -> IO RepeatableTransferType
- getReadTransferDeviceHandle :: ReadTransfer -> IO DeviceHandle
- getReadTransferEndpointAddress :: ReadTransfer -> IO EndpointAddress
- getReadTransferTimeout :: ReadTransfer -> IO Timeout
- getReadTransferSize :: ReadTransfer -> IO Size
- data WriteTransfer
- newWriteTransfer :: RepeatableTransferType -> DeviceHandle -> EndpointAddress -> ByteString -> Timeout -> IO WriteTransfer
- performWriteTransfer :: WriteTransfer -> IO (Size, Status)
- setWriteTransferType :: WriteTransfer -> RepeatableTransferType -> IO ()
- setWriteTransferDeviceHandle :: WriteTransfer -> DeviceHandle -> IO ()
- setWriteTransferEndpointAddress :: WriteTransfer -> EndpointAddress -> IO ()
- setWriteTransferTimeout :: WriteTransfer -> Timeout -> IO ()
- setWriteTransferInput :: WriteTransfer -> ByteString -> IO ()
- getWriteTransferType :: WriteTransfer -> IO RepeatableTransferType
- getWriteTransferDeviceHandle :: WriteTransfer -> IO DeviceHandle
- getWriteTransferEndpointAddress :: WriteTransfer -> IO EndpointAddress
- getWriteTransferTimeout :: WriteTransfer -> IO Timeout
- getWriteTransferInput :: WriteTransfer -> IO ByteString
- data IsochronousReadTransfer
- newIsochronousReadTransfer :: DeviceHandle -> EndpointAddress -> Vector Size -> Timeout -> IO IsochronousReadTransfer
- performIsochronousReadTransfer :: IsochronousReadTransfer -> IO (Vector ByteString)
- setIsochronousReadTransferDeviceHandle :: IsochronousReadTransfer -> DeviceHandle -> IO ()
- setIsochronousReadTransferEndpointAddress :: IsochronousReadTransfer -> EndpointAddress -> IO ()
- setIsochronousReadTransferSizes :: IsochronousReadTransfer -> Vector Size -> IO ()
- getIsochronousReadTransferDeviceHandle :: IsochronousReadTransfer -> IO DeviceHandle
- getIsochronousReadTransferEndpointAddress :: IsochronousReadTransfer -> IO EndpointAddress
- getIsochronousReadTransferSizes :: IsochronousReadTransfer -> IO (Vector Size)
- data IsochronousWriteTransfer
- newIsochronousWriteTransfer :: DeviceHandle -> EndpointAddress -> Vector ByteString -> Timeout -> IO IsochronousWriteTransfer
- performIsochronousWriteTransfer :: IsochronousWriteTransfer -> IO (Vector Size)
- setIsochronousWriteTransferDeviceHandle :: IsochronousWriteTransfer -> DeviceHandle -> IO ()
- setIsochronousWriteTransferEndpointAddress :: IsochronousWriteTransfer -> EndpointAddress -> IO ()
- setIsochronousWriteTransferPackets :: IsochronousWriteTransfer -> Vector ByteString -> IO ()
- getIsochronousWriteTransferDeviceHandle :: IsochronousWriteTransfer -> IO DeviceHandle
- getIsochronousWriteTransferEndpointAddress :: IsochronousWriteTransfer -> IO EndpointAddress
- getIsochronousWriteTransferPackets :: IsochronousWriteTransfer -> IO (Vector ByteString)
Control transfers
No data transfer
data ControlTransfer Source #
A control transfer which doesn't transfer data.
newControlTransfer :: DeviceHandle -> ControlSetup -> Timeout -> IO ControlTransfer Source #
Create a new control transfer which doesn't transfer data.
performControlTransfer :: ControlTransfer -> IO () Source #
Execute a control transfer which doesn't transfer data.
Setting
setControlTransferDeviceHandle :: ControlTransfer -> DeviceHandle -> IO () Source #
Update the device handle of a control transfer.
setControlTransferTimeout :: ControlTransfer -> Timeout -> IO () Source #
Update the timeout of a control transfer.
setControlSetup :: ControlTransfer -> ControlSetup -> IO () Source #
Update the setup parameters of a control transfer.
Getting
getControlTransferDeviceHandle :: ControlTransfer -> IO DeviceHandle Source #
Retrieve the device handle of a control transfer.
getControlTransferTimeout :: ControlTransfer -> IO Timeout Source #
Retrieve the timeout of a control transfer.
Reading
data ControlReadTransfer Source #
A control transfer which reads data from a device.
newControlReadTransfer :: DeviceHandle -> ControlSetup -> Size -> Timeout -> IO ControlReadTransfer Source #
Create a new control transfer which can read data from a device.
performControlReadTransfer :: ControlReadTransfer -> IO (ByteString, Status) Source #
Execute a control transfer to read data from the device.
Setting
setControlReadTransferDeviceHandle :: ControlReadTransfer -> DeviceHandle -> IO () Source #
Update the device handle of a control transfer that reads data from a device.
setControlReadTransferTimeout :: ControlReadTransfer -> Timeout -> IO () Source #
Update the timeout of a control transfer that reads data from a device.
setControlReadSetup :: ControlReadTransfer -> ControlSetup -> Size -> IO () Source #
Update the setup parameters of a control transfer that reads data from a device..
Getting
getControlReadTransferDeviceHandle :: ControlReadTransfer -> IO DeviceHandle Source #
Retrieve the device handle of a control transfer that reads data from a device.
getControlReadTransferTimeout :: ControlReadTransfer -> IO Timeout Source #
Retrieve the timeout of a control transfer that reads data from a device.
Writing
data ControlWriteTransfer Source #
A control transfer which writes data to a device.
newControlWriteTransfer :: DeviceHandle -> ControlSetup -> ByteString -> Timeout -> IO ControlWriteTransfer Source #
Create a new control transfer which can write data to a device.
performControlWriteTransfer :: ControlWriteTransfer -> IO (Size, Status) Source #
Execute a control transfer to write the data to the device.
Setting
setControlWriteTransferDeviceHandle :: ControlWriteTransfer -> DeviceHandle -> IO () Source #
Update the device handle of a control transfer that writes data to a device.
setControlWriteTransferTimeout :: ControlWriteTransfer -> Timeout -> IO () Source #
Update the timeout of a control transfer that writes data to a device.
setControlWriteSetup :: ControlWriteTransfer -> ControlSetup -> ByteString -> IO () Source #
Update the setup parameters of a control transfer that writes data to a device.
Getting
getControlWriteTransferDeviceHandle :: ControlWriteTransfer -> IO DeviceHandle Source #
Retrieve the device handle of a control transfer that writes data to a device.
getControlWriteTransferTimeout :: ControlWriteTransfer -> IO Timeout Source #
Retrieve the timeout of a control transfer that writes data to a device.
Bulk / Interrupt transfers
data RepeatableTransferType Source #
Type of ReadTransfer
or WriteTransfer
which can either be
bulk or interrupt.
Note that isochronous transfers are handled differently using the
IsochronousReadTransfer
or IsochronousWriteTransfer
types.
Reading
data ReadTransfer Source #
A bulk or interrupt read transfer.
:: RepeatableTransferType | |
-> DeviceHandle | |
-> EndpointAddress | |
-> Size | Number of bytes to read. |
-> Timeout | |
-> IO ReadTransfer |
Create a new bulk or interrupt transfer that can read data from a device.
performReadTransfer :: ReadTransfer -> IO (ByteString, Status) Source #
Execute a bulk or interrupt transfer to read data from a device.
Setting
setReadTransferType :: ReadTransfer -> RepeatableTransferType -> IO () Source #
Specify whether the transfer should perform bulk or interrupt reads.
setReadTransferDeviceHandle :: ReadTransfer -> DeviceHandle -> IO () Source #
Update the device handle of a bulk or interrupt read transfer.
setReadTransferEndpointAddress :: ReadTransfer -> EndpointAddress -> IO () Source #
Update the endpoint address of a bulk or interrupt read transfer.
setReadTransferTimeout :: ReadTransfer -> Timeout -> IO () Source #
Update the timeout of a bulk or interrupt read transfer.
setReadTransferSize :: ReadTransfer -> Size -> IO () Source #
Update the number of bytes to read for a bulk or interrupt transfer.
Getting
getReadTransferType :: ReadTransfer -> IO RepeatableTransferType Source #
Check if this transfer does bulk or interrupt reads.
getReadTransferDeviceHandle :: ReadTransfer -> IO DeviceHandle Source #
Retrieve the device handle of a bulk or interrupt read transfer.
getReadTransferEndpointAddress :: ReadTransfer -> IO EndpointAddress Source #
Retrieve the endpoint address of a bulk or interrupt read transfer.
getReadTransferTimeout :: ReadTransfer -> IO Timeout Source #
Retrieve the timeout of a bulk or interrupt read transfer.
getReadTransferSize :: ReadTransfer -> IO Size Source #
Retreive the number of bytes to read for a bulk or interrupt transfer.
Writing
data WriteTransfer Source #
A bulk or interrupt write transfer.
:: RepeatableTransferType | |
-> DeviceHandle | |
-> EndpointAddress | |
-> ByteString | Bytes to write. |
-> Timeout | |
-> IO WriteTransfer |
Create a new bulk or interrupt transfer that can write data to a device.
performWriteTransfer :: WriteTransfer -> IO (Size, Status) Source #
Execute a bulk or interrupt transfer to write data to a device.
Setting
setWriteTransferType :: WriteTransfer -> RepeatableTransferType -> IO () Source #
Specify whether the transfer should perform bulk or interrupt writes.
setWriteTransferDeviceHandle :: WriteTransfer -> DeviceHandle -> IO () Source #
Update the device handle of a bulk or interrupt write transfer.
setWriteTransferEndpointAddress :: WriteTransfer -> EndpointAddress -> IO () Source #
Update the endpoint address of a bulk or interrupt write transfer.
setWriteTransferTimeout :: WriteTransfer -> Timeout -> IO () Source #
Update the timeout of a bulk or interrupt write transfer.
setWriteTransferInput :: WriteTransfer -> ByteString -> IO () Source #
Update the bytes to write for a bulk or interrupt transfer.
Getting
getWriteTransferType :: WriteTransfer -> IO RepeatableTransferType Source #
Check if this transfer does bulk or interrupt writes.
getWriteTransferDeviceHandle :: WriteTransfer -> IO DeviceHandle Source #
Retrieve the device handle of a bulk or interrupt write transfer.
getWriteTransferEndpointAddress :: WriteTransfer -> IO EndpointAddress Source #
Retrieve the endpoint address of a bulk or interrupt write transfer.
getWriteTransferTimeout :: WriteTransfer -> IO Timeout Source #
Retrieve the timeout of a bulk or interrupt write transfer.
getWriteTransferInput :: WriteTransfer -> IO ByteString Source #
Retreive the bytes to write from a bulk or interrupt transfer.
Isochronous transfers
Reading
data IsochronousReadTransfer Source #
An isochronous read transfer.
newIsochronousReadTransfer Source #
:: DeviceHandle | |
-> EndpointAddress | |
-> Vector Size | Sizes of isochronous packets to read. |
-> Timeout | |
-> IO IsochronousReadTransfer |
Create a new isochronous transfer that can read isochronous packets from a device.
performIsochronousReadTransfer :: IsochronousReadTransfer -> IO (Vector ByteString) Source #
Execute a transfer to read isochronous packets from a device.
Setting
setIsochronousReadTransferDeviceHandle :: IsochronousReadTransfer -> DeviceHandle -> IO () Source #
Update the device handle of an isochronous read transfer.
setIsochronousReadTransferEndpointAddress :: IsochronousReadTransfer -> EndpointAddress -> IO () Source #
Update the endpoint address of an isochronous read transfer.
setIsochronousReadTransferSizes :: IsochronousReadTransfer -> Vector Size -> IO () Source #
Update the size of packets to read for an isochronous transfer.
Getting
getIsochronousReadTransferDeviceHandle :: IsochronousReadTransfer -> IO DeviceHandle Source #
Retrieve the device handle of an isochronous read transfer.
getIsochronousReadTransferEndpointAddress :: IsochronousReadTransfer -> IO EndpointAddress Source #
Retrieve the endpoint address of an isochronous read transfer.
getIsochronousReadTransferSizes :: IsochronousReadTransfer -> IO (Vector Size) Source #
Retrieve the packets sizes to read for an isochronous transfer.
Writing
data IsochronousWriteTransfer Source #
An isochronous write transfer.
newIsochronousWriteTransfer Source #
:: DeviceHandle | |
-> EndpointAddress | |
-> Vector ByteString | Isochronous packets to write. |
-> Timeout | |
-> IO IsochronousWriteTransfer |
Create a new isochronous transfer that can write isochronous packets to a device.
performIsochronousWriteTransfer :: IsochronousWriteTransfer -> IO (Vector Size) Source #
Execute a transfer to write isochronous packets to a device.
Setting
setIsochronousWriteTransferDeviceHandle :: IsochronousWriteTransfer -> DeviceHandle -> IO () Source #
Update the device handle of an isochronous write transfer.
setIsochronousWriteTransferEndpointAddress :: IsochronousWriteTransfer -> EndpointAddress -> IO () Source #
Update the endpoint address of an isochronous write transfer.
setIsochronousWriteTransferPackets :: IsochronousWriteTransfer -> Vector ByteString -> IO () Source #
Update the packets to write for an isochronous transfer.
Getting
getIsochronousWriteTransferDeviceHandle :: IsochronousWriteTransfer -> IO DeviceHandle Source #
Retrieve the device handle of an isochronous write transfer.
getIsochronousWriteTransferEndpointAddress :: IsochronousWriteTransfer -> IO EndpointAddress Source #
Retrieve the endpoint address of an isochronous write transfer.
getIsochronousWriteTransferPackets :: IsochronousWriteTransfer -> IO (Vector ByteString) Source #
Retrieve the packets to write for an isochronous transfer.