summaryrefslogtreecommitdiffstats
path: root/examples/serialport/cwriterasync
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2014-03-07 02:39:47 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-17 07:29:00 +0100
commit5be9ea056632e54fa8390b4fe865950ca3370260 (patch)
tree70cf718ade7038d43d0d71bb3d63dd81eed3dbd0 /examples/serialport/cwriterasync
parent0e46e8d319d054c7325d00b97ba4d7bd30f97e7c (diff)
Set the port settings before open in the examples
Change-Id: I946a3f1d3a64a9b8c0d901347aa8ff5959ebc601 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'examples/serialport/cwriterasync')
-rw-r--r--examples/serialport/cwriterasync/main.cpp30
1 files changed, 2 insertions, 28 deletions
diff --git a/examples/serialport/cwriterasync/main.cpp b/examples/serialport/cwriterasync/main.cpp
index 4277914f..310d896b 100644
--- a/examples/serialport/cwriterasync/main.cpp
+++ b/examples/serialport/cwriterasync/main.cpp
@@ -67,36 +67,10 @@ int main(int argc, char *argv[])
QString serialPortName = argumentList.at(1);
serialPort.setPortName(serialPortName);
- if (!serialPort.open(QIODevice::WriteOnly)) {
- standardOutput << QObject::tr("Failed to open port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
- return 1;
- }
-
int serialPortBaudRate = (argumentCount > 2) ? argumentList.at(2).toInt() : QSerialPort::Baud9600;
- if (!serialPort.setBaudRate(serialPortBaudRate)) {
- standardOutput << QObject::tr("Failed to set 9600 baud for port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
- return 1;
- }
-
- if (!serialPort.setDataBits(QSerialPort::Data8)) {
- standardOutput << QObject::tr("Failed to set 8 data bits for port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
- return 1;
- }
+ serialPort.setBaudRate(serialPortBaudRate);
- if (!serialPort.setParity(QSerialPort::NoParity)) {
- standardOutput << QObject::tr("Failed to set no parity for port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
- return 1;
- }
-
- if (!serialPort.setStopBits(QSerialPort::OneStop)) {
- standardOutput << QObject::tr("Failed to set 1 stop bit for port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
- return 1;
- }
-
- if (!serialPort.setFlowControl(QSerialPort::NoFlowControl)) {
- standardOutput << QObject::tr("Failed to set no flow control for port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
- return 1;
- }
+ serialPort.open(QIODevice::WriteOnly);
QFile dataFile;
if (!dataFile.open(stdin, QIODevice::ReadOnly)) {