[Interest] Parsing data from serialport

Zielinski, Mariusz UTC CCS Mariusz.Zielinski at fs.utc.com
Tue Apr 2 10:52:11 CEST 2019


Hi,

If I understand documentation correctly, it suggests to connect QIODevice::readyRead() signal to slot that will contain:

if(QIODevice::canReadLine)
{
QByteArray oneLine=QIODevice::ReadLine();
// process data here
}

--
Mariusz Zieliński different results.”

From: Martin Marmsoler [mailto:martin.marmsoler at gmail.com]
Sent: 31 marca 2019 23:49
To: interest at qt-project.org
Subject: [Interest] Parsing data from serialport


Hello,

I'm trying to implement a serial connection with QIODevice (SerialPort). I would like to parse line by line (each line consists of multiple columns of data) and for this I found canReadLine().
But as I understand I have to use startTransaction, because otherwise the buffer will not be used. I'm I correct?

bool QIODevice::canReadLine() const

{

    Q_D(const QIODevice);

    return d->buffer.indexOf('\n', d->buffer.size(),

                             d->isSequential() ? d->transactionPos : Q_INT64_C(0)) >= 0;

}

So to read a full line, I have to open a QSerialPort and then start a Transaction. Then I have to wait a little bit (till data is in the buffer) and then I can use canReadLine. Am I correct? Is there a better way instead to wait a little bit? Or is it the wrong way to go?



Best regards,

Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190402/688c74eb/attachment.html>


More information about the Interest mailing list