C++ (Qt)//! [7] //! [8] // read request QByteArray requestData = serial.readAll(); while (serial.waitForReadyRead(10)) requestData += serial.readAll();//! [8] //! [10]
while (!time.hasExpired(200)){ if ( serialPort->waitForReadyRead(30) ) { QByteArray tempbuff = serialPort->readAll(); ... buff.append(tempbuff); ... // проверка CRC // если все данные получены, то выход из цикла } }
export QTEST_SERIALPORT_RECEIVER=ttyS0 export QTEST_SERIALPORT_SENDER=ttyS0 ./tst_qserialport
********* Start testing of tst_QSerialPort *********Config: Using QTest library 4.8.5, Qt 4.8.5PASS : tst_QSerialPort::initTestCase()FAIL! : tst_QSerialPort::synchronousLoopbackDataVerificationTest() 'receiverPort.open(QSerialPort::ReadOnly)' returned FALSE. () Loc: [../../../../qt-qtserialport/tests/benchmarks/qserialport/tst_qserialport.cpp(127)]PASS : tst_QSerialPort::cleanupTestCase()Totals: 2 passed, 1 failed, 0 skipped********* Finished testing of tst_QSerialPort *********