QUsbTransfer Class
This class handles transfers between endpoints and the host. More...
Header: | #include <QUsbTransfer> |
qmake: | QT += usb |
Inherits: | QIODevice |
Note: All functions in this class are reentrant.
Public Types
enum | Status { transferCompleted, transferError, transferTimeout, transferCanceled, ..., transferOverflow } |
enum | Type { controlTransfer, isochronousTransfer, bulkTransfer, interruptTransfer, streamTransfer } |
enum | bRequest { requestGetStatus, requestClearFeature, requestSetFeature, requestSetAddress, ..., requestIsochDelay } |
enum | bmRequestType { requestStandard, requestClass, requestVendor, requestReserved, ..., recipientOther } |
Properties
- endpointIn : const QUsbDevice::Endpoint
- endpointOut : const QUsbDevice::Endpoint
- polling : bool
- type : const Type
- 1 property inherited from QObject
Public Functions
QUsbTransfer(QUsbDevice *dev, Type type, QUsbDevice::Endpoint in, QUsbDevice::Endpoint out) | |
~QUsbTransfer() | |
QUsbDevice::Endpoint | endpointIn() const |
QUsbDevice::Endpoint | endpointOut() const |
void | makeControlPacket(char *buffer, QUsbTransfer::bmRequestType bmRequestType, QUsbTransfer::bRequest bRequest, quint16 wValue, quint16 wIndex, quint16 wLength) const |
bool | poll() |
bool | polling() |
void | setPolling(bool enable) |
Status | status() const |
Type | type() const |
Reimplemented Public Functions
virtual qint64 | bytesAvailable() const |
virtual qint64 | bytesToWrite() const |
virtual void | close() |
virtual bool | isSequential() const |
virtual bool | open(QIODevice::OpenMode mode) |
virtual bool | waitForBytesWritten(int msecs) |
virtual bool | waitForReadyRead(int msecs) |
Public Slots
void | cancelTransfer() |
- 1 public slot inherited from QObject
Signals
void | error(Status error) |
Reimplemented Protected Functions
virtual qint64 | readData(char *data, qint64 maxSize) |
virtual qint64 | writeData(const char *data, qint64 maxSize) |
Additional Inherited Members
- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 5 protected functions inherited from QIODevice
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject
Detailed Description
This class handles transfers between endpoints and the host.
It works on top of libusb's async module. The QUsbDevice is set as parent object.
Member Type Documentation
enum QUsbTransfer::Status
This enum describres the last transfer status.
Constant | Value | Description |
---|---|---|
QUsbTransfer::transferCompleted | 0 | Transfer completed without errors. At least one byte transfered. |
QUsbTransfer::transferError | 1 | Transfer completed with unknown error. |
QUsbTransfer::transferTimeout | 2 | Transfer timed out. |
QUsbTransfer::transferCanceled | 3 | Transfer canceled. |
QUsbTransfer::transferStall | 4 | Transfer stalled (most likely hardware issue). |
QUsbTransfer::transferNoDevice | 5 | Device not found. |
QUsbTransfer::transferOverflow | 6 | More data received than requested. |
enum QUsbTransfer::Type
This enum describres the type of transfer this object handles.
Constant | Value |
---|---|
QUsbTransfer::controlTransfer | 0 |
QUsbTransfer::isochronousTransfer | 1 |
QUsbTransfer::bulkTransfer | 2 |
QUsbTransfer::interruptTransfer | 3 |
QUsbTransfer::streamTransfer | 4 |
enum QUsbTransfer::bRequest
This enum describres a bRequest packet.
Constant | Value |
---|---|
QUsbTransfer::requestGetStatus | 0x00 |
QUsbTransfer::requestClearFeature | 0x01 |
QUsbTransfer::requestSetFeature | 0x03 |
QUsbTransfer::requestSetAddress | 0x05 |
QUsbTransfer::requestGetDescriptor | 0x06 |
QUsbTransfer::requestSetDescriptor | 0x07 |
QUsbTransfer::requestGetConfiguration | 0x08 |
QUsbTransfer::requestSetConfiguration | 0x09 |
QUsbTransfer::requestGetInterface | 0x0A |
QUsbTransfer::requestSetInterface | 0x0B |
QUsbTransfer::requestSynchFrame | 0x0C |
QUsbTransfer::requestSetSel | 0x30 |
QUsbTransfer::requestIsochDelay | 0x31 |
enum QUsbTransfer::bmRequestType
This enum describres a bmRequestType packet.
Constant | Value |
---|---|
QUsbTransfer::requestStandard | ( 0x00<5 ) |
QUsbTransfer::requestClass | ( 0x01<5 ) |
QUsbTransfer::requestVendor | ( 0x02<5 ) |
QUsbTransfer::requestReserved | ( 0x03<5 ) |
QUsbTransfer::recipientDevice | 0x00 |
QUsbTransfer::recipientInterface | 0x01 |
QUsbTransfer::recipientEndpoint | 0x02 |
QUsbTransfer::recipientOther | 0x03 |
Property Documentation
endpointIn : const QUsbDevice::Endpoint
IN endpoint.
Access functions:
QUsbDevice::Endpoint | endpointIn() const |
endpointOut : const QUsbDevice::Endpoint
OUT endpoint.
Access functions:
QUsbDevice::Endpoint | endpointOut() const |
polling : bool
polling status.
Access functions:
bool | polling() |
void | setPolling(bool enable) |
type : const Type
Transfer type.
Access functions:
Type | type() const |
Member Function Documentation
QUsbTransfer::QUsbTransfer(QUsbDevice *dev, Type type, QUsbDevice::Endpoint in, QUsbDevice::Endpoint out)
QUsbTransfer constructor.
This create an object of the given transfer type, using endpoints in and out.
dev will be set as parent object.
QUsbTransfer::~QUsbTransfer()
Will cancel all transfers on exit.
[virtual]
qint64 QUsbTransfer::bytesAvailable() const
Reimplemented from QIODevice::bytesAvailable().
Bytes available to read.
[virtual]
qint64 QUsbTransfer::bytesToWrite() const
Reimplemented from QIODevice::bytesToWrite().
Bytes left to write.
[slot]
void QUsbTransfer::cancelTransfer()
[virtual]
void QUsbTransfer::close()
Reimplemented from QIODevice::close().
Close the transfer.
This will cancel any ongoing transfers.
QUsbDevice::Endpoint QUsbTransfer::endpointIn() const
Returns the transfer IN
endpoint.
Note: Getter function for property endpointIn.
QUsbDevice::Endpoint QUsbTransfer::endpointOut() const
Returns the
transfer OUT endpoint.
Note: Getter function for property endpointOut.
[signal]
void QUsbTransfer::error(Status error)
emits a signal on any transfer error.
[virtual]
bool QUsbTransfer::isSequential() const
Reimplemented from QIODevice::isSequential().
Always returns true
.
void QUsbTransfer::makeControlPacket(char *buffer, QUsbTransfer::bmRequestType bmRequestType, QUsbTransfer::bRequest bRequest, quint16 wValue, quint16 wIndex, quint16 wLength) const
Create a control packet using buffer, bmRequestType, bRequest, wValue, bRequest, wIndex, wLength.
[virtual]
bool QUsbTransfer::open(QIODevice::OpenMode mode)
Reimplemented from QIODevice::open().
Open the transfer with mode.
Returns true
on success.
bool QUsbTransfer::poll()
Manual IN (read) polling.
return true
if successful.
bool QUsbTransfer::polling()
Get polling status.
return true
if enabled.
Note: Getter function for property polling.
See also setPolling().
[virtual protected]
qint64 QUsbTransfer::readData(char *data, qint64 maxSize)
Reimplemented from QIODevice::readData().
/reimp
Read maxSize bytes from the internal buffer to data.
Returns read
bytes.
void QUsbTransfer::setPolling(bool enable)
enable or disable automating polling.
Note: Setter function for property polling.
See also polling().
Status QUsbTransfer::status() const
Get the transfer status
.
Type QUsbTransfer::type() const
Returns the
transfer type.
Note: Getter function for property type.
[virtual]
bool QUsbTransfer::waitForBytesWritten(int msecs)
Reimplemented from QIODevice::waitForBytesWritten().
Wait for at least one byte to be written for msecs milliseconds.
Returns true
if any data was written before timeout.
[virtual]
bool QUsbTransfer::waitForReadyRead(int msecs)
Reimplemented from QIODevice::waitForReadyRead().
Wait for at least one byte to be available for msecs milliseconds.
Returns true
if any data was read before timeout.
[virtual protected]
qint64 QUsbTransfer::writeData(const char *data, qint64 maxSize)
Reimplemented from QIODevice::writeData().
Copies maxSize bytes from data to the internal write buffer and schedules an OUT transfer.
Returns bytes
written to the buffer.