summaryrefslogtreecommitdiffstats
path: root/examples/serialport/creaderasync/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/serialport/creaderasync/main.cpp')
-rw-r--r--examples/serialport/creaderasync/main.cpp29
1 files changed, 3 insertions, 26 deletions
diff --git a/examples/serialport/creaderasync/main.cpp b/examples/serialport/creaderasync/main.cpp
index 96fecddf..5befaca1 100644
--- a/examples/serialport/creaderasync/main.cpp
+++ b/examples/serialport/creaderasync/main.cpp
@@ -67,34 +67,11 @@ int main(int argc, char *argv[])
QString serialPortName = argumentList.at(1);
serialPort.setPortName(serialPortName);
- if (!serialPort.open(QIODevice::ReadOnly)) {
- 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;
+ if (!serialPort.open(QIODevice::ReadOnly)) {
+ standardOutput << QObject::tr("Failed to open port %1, error: %2").arg(serialPortName).arg(serialPort.errorString()) << endl;
return 1;
}