usb-1.3.0.6: Communicate with USB devices

Copyright(c) 2009–2017 Bas van Dijk
LicenseBSD3 (see the file LICENSE)
MaintainerBas van Dijk <v.dijk.bas@gmail.com>
StabilityExperimental
Safe HaskellTrustworthy
LanguageHaskell98

System.USB.IO.Transfers

Contents

Description

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.

Synopsis

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.

newReadTransfer Source #

Arguments

:: 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.

newWriteTransfer Source #

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 #

Arguments

:: 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 #

Arguments

:: 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.