QUsbEndpoint Class

This class handles transfers between endpoints and the host. More...

Header: #include <QUsbEndpoint>
qmake: QT += usb
Inherits: QIODevice

Note: All functions in this class are reentrant.

Public Types

enum Status { transferCompleted, transferError, transferTimeout, transferCanceled, transferStall, …, transferOverflow }
enum Type { controlEndpoint, isochronousEndpoint, bulkEndpoint, interruptEndpoint, streamEndpoint }
enum bRequest { requestGetStatus, requestClearFeature, requestSetFeature, requestSetAddress, requestGetDescriptor, …, requestIsochDelay }
enum bmRequestType { requestStandard, requestClass, requestVendor, requestReserved, recipientDevice, …, recipientOther }

Properties

Public Functions

QUsbEndpoint(QUsbDevice *dev, QUsbEndpoint::Type type, quint8 ep)
virtual ~QUsbEndpoint()
quint8 endpoint() const
void makeControlPacket(char *buffer, QUsbEndpoint::bmRequestType bmRequestType, QUsbEndpoint::bRequest bRequest, quint16 wValue, quint16 wIndex, quint16 wLength) const
bool poll()
bool polling()
void setPolling(bool enable)
QUsbEndpoint::Status status() const
QUsbEndpoint::Type type() const

Reimplemented Public Functions

virtual qint64 bytesAvailable() const override
virtual qint64 bytesToWrite() const override
virtual void close() override
virtual bool isSequential() const override
virtual bool open(QIODevice::OpenMode mode) override
virtual bool waitForBytesWritten(int msecs) override
virtual bool waitForReadyRead(int msecs) override

Public Slots

Signals

void error(QUsbEndpoint::Status error)

Reimplemented Protected Functions

virtual qint64 readData(char *data, qint64 maxSize) override
virtual qint64 writeData(const char *data, qint64 maxSize) override

Detailed Description

It works on top of libusb's async module. The QUsbDevice is set as parent object. You need one object per endpoint and direction.

Member Type Documentation

enum QUsbEndpoint::Status

This enum describres the last transfer status.

ConstantValueDescription
QUsbEndpoint::transferCompleted0Transfer completed without errors. At least one byte transfered.
QUsbEndpoint::transferError1Transfer completed with unknown error.
QUsbEndpoint::transferTimeout2Transfer timed out.
QUsbEndpoint::transferCanceled3Transfer canceled.
QUsbEndpoint::transferStall4Transfer stalled (most likely hardware issue).
QUsbEndpoint::transferNoDevice5Device not found.
QUsbEndpoint::transferOverflow6More data received than requested.

enum QUsbEndpoint::Type

This enum describres the type of endpoint this object handles.

ConstantValue
QUsbEndpoint::controlEndpoint0
QUsbEndpoint::isochronousEndpoint1
QUsbEndpoint::bulkEndpoint2
QUsbEndpoint::interruptEndpoint3
QUsbEndpoint::streamEndpoint4

enum QUsbEndpoint::bRequest

This enum describres a bRequest packet.

ConstantValue
QUsbEndpoint::requestGetStatus0x00
QUsbEndpoint::requestClearFeature0x01
QUsbEndpoint::requestSetFeature0x03
QUsbEndpoint::requestSetAddress0x05
QUsbEndpoint::requestGetDescriptor0x06
QUsbEndpoint::requestSetDescriptor0x07
QUsbEndpoint::requestGetConfiguration0x08
QUsbEndpoint::requestSetConfiguration0x09
QUsbEndpoint::requestGetInterface0x0A
QUsbEndpoint::requestSetInterface0x0B
QUsbEndpoint::requestSynchFrame0x0C
QUsbEndpoint::requestSetSel0x30
QUsbEndpoint::requestIsochDelay0x31

enum QUsbEndpoint::bmRequestType

This enum describres a bmRequestType packet.

ConstantValue
QUsbEndpoint::requestStandard(0x00 << 5)
QUsbEndpoint::requestClass(0x01 << 5)
QUsbEndpoint::requestVendor(0x02 << 5)
QUsbEndpoint::requestReserved(0x03 << 5)
QUsbEndpoint::recipientDevice0x00
QUsbEndpoint::recipientInterface0x01
QUsbEndpoint::recipientEndpoint0x02
QUsbEndpoint::recipientOther0x03

Property Documentation

[read-only] endpoint : const quint8

endpoint.

Access functions:

quint8 endpoint() const

polling : bool

polling status.

Access functions:

bool polling()
void setPolling(bool enable)

[read-only] type : const Type

Transfer type.

Access functions:

QUsbEndpoint::Type type() const

Member Function Documentation

QUsbEndpoint::QUsbEndpoint(QUsbDevice *dev, QUsbEndpoint::Type type, quint8 ep)

QUsbEndpoint constructor.

This create an object of the given type for the ep endpoint.

dev will be set as parent object.

[slot] void QUsbEndpoint::cancelTransfer()

[signal] void QUsbEndpoint::error(QUsbEndpoint::Status error)

emits a signal on any transfer error.

[virtual] QUsbEndpoint::~QUsbEndpoint()

Will cancel all transfers on exit.

[override virtual] qint64 QUsbEndpoint::bytesAvailable() const

Reimplements: QIODevice::bytesAvailable() const.

Bytes available to read.

[override virtual] qint64 QUsbEndpoint::bytesToWrite() const

Reimplements: QIODevice::bytesToWrite() const.

Bytes left to write.

[override virtual] void QUsbEndpoint::close()

Reimplements: QIODevice::close().

Close the transfer.

This will cancel any ongoing transfers.

quint8 QUsbEndpoint::endpoint() const

Returns the transfer endpoint.

Note: Getter function for property endpoint.

[override virtual] bool QUsbEndpoint::isSequential() const

Reimplements: QIODevice::isSequential() const.

Always returns true.

void QUsbEndpoint::makeControlPacket(char *buffer, QUsbEndpoint::bmRequestType bmRequestType, QUsbEndpoint::bRequest bRequest, quint16 wValue, quint16 wIndex, quint16 wLength) const

Create a control packet using buffer, bmRequestType, bRequest, wValue, bRequest, wIndex, wLength.

[override virtual] bool QUsbEndpoint::open(QIODevice::OpenMode mode)

Open the endpoint with mode.

Returns true on success.

bool QUsbEndpoint::poll()

Manual IN (read) polling.

return true if successful.

bool QUsbEndpoint::polling()

Get polling status.

return true if enabled.

Note: Getter function for property polling.

See also setPolling().

[override virtual protected] qint64 QUsbEndpoint::readData(char *data, qint64 maxSize)

Reimplements: QIODevice::readData(char *data, qint64 maxSize).

/reimp

Read maxSize bytes from the internal buffer to data.

Returns read bytes.

void QUsbEndpoint::setPolling(bool enable)

enable or disable automating polling.

Note: Setter function for property polling.

See also polling().

QUsbEndpoint::Status QUsbEndpoint::status() const

Get the endpoint status.

QUsbEndpoint::Type QUsbEndpoint::type() const

Returns the transfer type.

Note: Getter function for property type.

[override virtual] bool QUsbEndpoint::waitForBytesWritten(int msecs)

Reimplements: QIODevice::waitForBytesWritten(int msecs).

Wait for at least one byte to be written for msecs milliseconds.

Returns true if any data was written before timeout.

[override virtual] bool QUsbEndpoint::waitForReadyRead(int msecs)

Reimplements: QIODevice::waitForReadyRead(int msecs).

Wait for at least one byte to be available for msecs milliseconds.

Returns true if any data was read before timeout.

[override virtual protected] qint64 QUsbEndpoint::writeData(const char *data, qint64 maxSize)

Reimplements: QIODevice::writeData(const char *data, qint64 maxSize).

Copies maxSize bytes from data to the internal write buffer and schedules an OUT transfer.

Returns bytes written to the buffer.