summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2013-11-20 18:39:50 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-25 11:00:10 +0100
commitdb549d815d5ca0a0075b571f9b0a22ad5db37c03 (patch)
treeb3cd4ba1ab722662854a33a8c935d73e12def3d6 /examples
parentd97a152bf14cd7b58e576bd6b4a5f304527f940e (diff)
downloadqtserialport-db549d815d5ca0a0075b571f9b0a22ad5db37c03.tar.gz
Drop the empty data check in favor of proper error code handling
Change-Id: Iad0f2c58a4f52daebd02a71fd7b404cb283602dc Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/serialport/creadersync/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/serialport/creadersync/main.cpp b/examples/serialport/creadersync/main.cpp
index cd10b8e..188d7b8 100644
--- a/examples/serialport/creadersync/main.cpp
+++ b/examples/serialport/creadersync/main.cpp
@@ -99,9 +99,12 @@ int main(int argc, char *argv[])
while (serialPort.waitForReadyRead(5000))
readData.append(serialPort.readAll());
- if (readData.isEmpty()) {
- standardOutput << QObject::tr("Either no data was currently available for reading, or an error occurred for port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
+ if (serialPort.error() == QSerialPort::ReadError) {
+ standardOutput << QObject::tr("Failed to read from port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
return 1;
+ } else if (serialPort.error() == QSerialPort::TimeoutError) {
+ standardOutput << QObject::tr("No data was currently available for reading from port %1").arg(serialPortName) << endl;
+ return 0;
}
standardOutput << QObject::tr("Data successfully received from port %1").arg(serialPortName) << endl;