Skip to content

Commit 94865be

Browse files
committed
Use waitForRead to wait for bytes, no need to wait for unbuffered write
1 parent 2a9d234 commit 94865be

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

plugins/robots/common/ev3Kit/src/communication/bluetoothRobotCommunicationThread.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ bool BluetoothRobotCommunicationThread::connect()
7373
mPort->setParity(QSerialPort::Parity::NoParity);
7474
mPort->setDataBits(QSerialPort::DataBits::Data8);
7575
mPort->setStopBits(QSerialPort::StopBits::TwoStop);
76-
// ??? mPort->setTimeout(3000);
77-
7876

7977
mPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
8078

@@ -122,7 +120,7 @@ bool BluetoothRobotCommunicationThread::send1(const QByteArray &buffer) const
122120

123121
QByteArray BluetoothRobotCommunicationThread::receive(int size) const
124122
{
125-
return mPort ? mPort->read(size) : QByteArray();
123+
return mPort && mPort->waitForReadyRead(3000) ? mPort->read(size) : QByteArray();
126124
}
127125

128126
void BluetoothRobotCommunicationThread::checkForConnection()

plugins/robots/common/nxtKit/src/communication/bluetoothRobotCommunicationThread.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ bool BluetoothRobotCommunicationThread::connect()
7676
mPort->setParity(QSerialPort::Parity::NoParity);
7777
mPort->setDataBits(QSerialPort::DataBits::Data8);
7878
mPort->setStopBits(QSerialPort::StopBits::TwoStop);
79-
// ??? mPort->setTimeout(3000);
8079

8180
mPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
8281

0 commit comments

Comments
 (0)