Hello people,
i am trying to achieve programmatically an async read on a IO node file which receives the outputs of a NMEA GPS.
i have tried to subclass QIODevice like this (For testing):
#include "QIOGpsReader.h"
#include <QIODevice>
qDebug("QIOGpsReader::ctor");
}
QIOGpsReader::~QIOGpsReader (void) {
qDebug("QIOGpsReader::~ctor");
}
qint64 QIOGpsReader::readData (char *data, qint64 maxSize) {
qDebug("QIOGpsReader::readData");
strcpy(data, "1");
return 1;
}
qint64 QIOGpsReader::writeData (const char *data, qint64 maxSize) {
qDebug("QIOGpsReader::writeData");
return 0;
}
qint64 QIOGpsReader::bytesAvailable (void) const {
qDebug("QIOGpsReader::bytesAvailable");
return 1;
}
#include "QIOGpsReader.h"
#include <QIODevice>
QIOGpsReader::QIOGpsReader (QString node, QObject *parent) : QIODevice(parent) {
qDebug("QIOGpsReader::ctor");
}
QIOGpsReader::~QIOGpsReader (void) {
qDebug("QIOGpsReader::~ctor");
}
qint64 QIOGpsReader::readData (char *data, qint64 maxSize) {
qDebug("QIOGpsReader::readData");
strcpy(data, "1");
return 1;
}
qint64 QIOGpsReader::writeData (const char *data, qint64 maxSize) {
qDebug("QIOGpsReader::writeData");
return 0;
}
qint64 QIOGpsReader::bytesAvailable (void) const {
qDebug("QIOGpsReader::bytesAvailable");
return 1;
}
To copy to clipboard, switch view to plain text mode
Then in my main routine i instanciate a QIOGpsReader object and just connect the readyRead signal to a slot. Then i do a open(QIODevice::ReadOnly) "just to do it".
What i dont understand is, on what is based the "readReady" signal? When i look to my debug, i don't see any of my qDebug messages... What will make the QIODevice trigger a readyRead signal? i thought at a first that returning always 1 from readData and bytesAvailable would "tell" the QIODevice that it has to trigger, but it doesnt...
Basically, what is the method i have to reimplement which will tell the QIODevice object to signal a readReady event?
Thanks,
Pierre.
[EDIT:] i think it will not help but anyway here is my .h for my subclass:
#ifndef QIOGpsReader_h
#define QIOGpsReader_h
#include <QIODevice>
Q_OBJECT
public:
~QIOGpsReader (void);
protected:
qint64 readData (char*, qint64);
qint64 writeData (const char *data, qint64 maxSize);
qint64 bytesAvailable (void) const;
};
#endif
#ifndef QIOGpsReader_h
#define QIOGpsReader_h
#include <QIODevice>
class QIOGpsReader : public QIODevice {
Q_OBJECT
public:
QIOGpsReader (QString node, QObject *parent);
~QIOGpsReader (void);
protected:
qint64 readData (char*, qint64);
qint64 writeData (const char *data, qint64 maxSize);
qint64 bytesAvailable (void) const;
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks