60 TInt&
AoFlags() {
return ((TInt*)&iStatus)[1]; }
91 TInt err =
d->ost.Connect();
92 if (!err) err =
d->ost.Open();
93 const TVersion KRequiredVersion(1,1,0);
94 TVersion version =
d->ost.Version();
95 if (version.iMajor < KRequiredVersion.iMajor ||
96 (version.iMajor == KRequiredVersion.iMajor && version.iMinor < KRequiredVersion.iMinor)) {
97 setErrorString(
"CODA version too old. At least version 4.0.18 (without TRK) is required.");
101 if (!err) err =
d->ost.RegisterProtocolID((
TOstProtIds)ostProtocolId, EFalse);
103 d->ost.ReadMessage(
d->iStatus,
d->readBuf);
114 if (iStatus == KErrNone) {
119 ost.ReadMessage(iStatus, readBuf);
128 q->setErrorString(
QString(
"Error %1 from RUsbOstComm::ReadMessage()").arg(iStatus.Int()));
144 if (
d->ost.Handle()) {
152 if (
d->dataBuf.length() == 0 && !
d->IsActive())
155 memcpy(data,
d->dataBuf.constData(), available);
156 d->dataBuf.remove(0, available);
165 TPtrC8
ptr((
const TUint8*)data, (TInt)maxSize);
166 while (ptr.Length()) {
170 d->ost.WriteMessage(stat, fragment);
171 User::WaitForRequest(stat);
172 if (stat.Int() != KErrNone) {
176 ptr.Set(ptr.Mid(fragment.Length()));
186 return d->dataBuf.length();
194 TInt err = timer.CreateLocal();
195 if (err)
return false;
196 TRequestStatus timeoutStat;
197 timer.After(timeoutStat, msecs*1000);
198 User::WaitForRequest(timeoutStat,
d->iStatus);
199 if (timeoutStat != KRequestPending) {
206 User::WaitForRequest(timeoutStat);
212 User::WaitForRequest(
d->iStatus);
216 TInt err =
d->iStatus.Int();
218 TRAP_IGNORE(
d->RunL());
219 return err == KErrNone;
bool waitForReadyRead(int msecs)
Blocks until new data is available for reading and the readyRead() signal has been emitted...
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
qint64 writeData(const char *data, qint64 maxSize)
Writes up to maxSize bytes from data to the device.
QByteArray & append(char c)
Appends the character ch to this byte array.
The QByteArray class provides an array of bytes.
QOstDevicePrivate * d_ptr
void bytesWritten(qint64 bytes)
This signal is emitted every time a payload of data has been written to the device.
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
bool isOpen() const
Returns true if the device is open; otherwise returns false.
qint64 readData(char *data, qint64 maxSize)
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
static QByteArray fromRawData(const char *, int size)
Constructs a QByteArray that uses the first size bytes of the data array.
static const char * data(const QByteArray &arr)
bool open(int ostProtocolId)
const T * ptr(const T &t)
qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
#define Q_DECLARE_PUBLIC(Class)
void setErrorString(const QString &errorString)
Sets the human readable description of the last device error that occurred to str.
virtual bool open(OpenMode mode)
Opens the device and sets its OpenMode to mode.
The QIODevice class is the base interface class of all I/O devices in Qt.
QOstDevice(QObject *parent=0)
static const TInt KMaxOstPacketLen
void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.