From fdd3876111605e84a1f7c31206e20cd99e13f1fb Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Sat, 30 Nov 2013 19:21:37 +0000 Subject: Deprecate further Unknown* property values similarly to UnknownParity Task-number: QTBUG-35215 Change-Id: Id8175af00c431cc8f80f05d518b3a2ee0e8ac71b Reviewed-by: Sergey Belyashov Reviewed-by: Denis Shienkov --- dist/changes-5.2.0 | 8 ++--- src/serialport/qserialport.cpp | 30 +++++++++++-------- src/serialport/qserialport.h | 55 +++++++++++++++++++++------------- src/serialport/qserialport_symbian.cpp | 12 +++++--- src/serialport/qserialport_unix.cpp | 11 ++++--- src/serialport/qserialport_win.cpp | 14 +++++---- 6 files changed, 80 insertions(+), 50 deletions(-) diff --git a/dist/changes-5.2.0 b/dist/changes-5.2.0 index a51701e..dae347e 100644 --- a/dist/changes-5.2.0 +++ b/dist/changes-5.2.0 @@ -64,9 +64,6 @@ now. - [QTBUG-33774] Document that the serial port parameters cannot be set before opening. -- Add an "UnknownSignal" value for the pinout signals. This is now the returned -value when the pinout state of the signals cannot be detected properly. - - No more unnecessary syscalls (parameter settings, pinout signal query, etc) in the backend when the port is closed. This also means no improper errors are set accordingly. @@ -128,6 +125,7 @@ support the enumeration of such devices. - [QTBUG-35184] Mark the isValid() method in QSerialPortInfo deprecated because it has no common use case. -- [QTBUG-35215] Mark the QSerialPort::UnknownParity method in QSerialPort +- [QTBUG-35215] Mark the QSerialPort::Unknown* enumeration values in QSerialPort deprecated because it has no use case, and was added mistakenly. There is no -such a "standard" serial port parity behavior. +such "standard" serial port behavior general for these as "unknown". It is an +implementation detail for error reporting, and hence not recommended anymore. diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 9155be9..87f4c0c 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -70,10 +70,10 @@ QSerialPortPrivateData::QSerialPortPrivateData(QSerialPort *q) , error(QSerialPort::NoError) , inputBaudRate(0) , outputBaudRate(0) - , dataBits(QSerialPort::UnknownDataBits) + , dataBits(QSerialPort::Data8) , parity(QSerialPort::NoParity) - , stopBits(QSerialPort::UnknownStopBits) - , flow(QSerialPort::UnknownFlowControl) + , stopBits(QSerialPort::OneStop) + , flow(QSerialPort::NoFlowControl) , policy(QSerialPort::IgnorePolicy) , settingsRestoredOnClose(true) , q_ptr(q) @@ -198,7 +198,9 @@ int QSerialPortPrivateData::timeoutValue(int msecs, int elapsed) \value Baud38400 38400 baud. \value Baud57600 57600 baud. \value Baud115200 115200 baud. - \value UnknownBaud Unknown baud. + \value UnknownBaud Unknown baud. This value is obsolete. It is provided to + keep old source code working. We strongly advise against + using it in new code. \sa QSerialPort::baudRate */ @@ -212,7 +214,9 @@ int QSerialPortPrivateData::timeoutValue(int msecs, int elapsed) \value Data6 Six bits. \value Data7 Seven bits \value Data8 Eight bits. - \value UnknownDataBits Unknown number of bits. + \value UnknownDataBits Unknown number of bits. This value is obsolete. It + is provided to keep old source code working. We + strongly advise against using it in new code. \sa QSerialPort::dataBits */ @@ -242,7 +246,9 @@ int QSerialPortPrivateData::timeoutValue(int msecs, int elapsed) \value OneStop 1 stop bit. \value OneAndHalfStop 1.5 stop bits. \value TwoStop 2 stop bits. - \value UnknownStopBits Unknown number of stop bit. + \value UnknownStopBits Unknown number of stop bit. This value is obsolete. + It is provided to keep old source code working. We + strongly advise against using it in new code. \sa QSerialPort::stopBits */ @@ -255,7 +261,9 @@ int QSerialPortPrivateData::timeoutValue(int msecs, int elapsed) \value NoFlowControl No flow control. \value HardwareControl Hardware flow control (RTS/CTS). \value SoftwareControl Software flow control (XON/XOFF). - \value UnknownFlowControl Unknown flow control. + \value UnknownFlowControl Unknown flow control. This value is obsolete. It + is provided to keep old source code working. We + strongly advise against using it in new code. \sa QSerialPort::flowControl */ @@ -276,7 +284,6 @@ int QSerialPortPrivateData::timeoutValue(int msecs, int elapsed) \value ClearToSendSignal CTS (Clear To Send). \value SecondaryTransmittedDataSignal STD (Secondary Transmitted Data). \value SecondaryReceivedDataSignal SRD (Secondary Received Data). - \value UnknownSignal Unknown line state. This value was introduced in QtSerialPort 5.2. \sa pinoutSignals(), QSerialPort::dataTerminalReady, QSerialPort::requestToSend @@ -623,7 +630,7 @@ qint32 QSerialPort::baudRate(Directions directions) const Q_D(const QSerialPort); if (directions == QSerialPort::AllDirections) return d->inputBaudRate == d->outputBaudRate ? - d->inputBaudRate : QSerialPort::UnknownBaud; + d->inputBaudRate : -1; return directions & QSerialPort::Input ? d->inputBaudRate : d->outputBaudRate; } @@ -955,8 +962,7 @@ bool QSerialPort::isRequestToSend() operating systems cannot provide proper notifications about the changes. \note The serial port has to be open before trying to get the pinout - signals; otherwise returns UnknownSignal and sets the NotOpenError error - code. + signals; otherwise returns NoSignal and sets the NotOpenError error code. \sa isDataTerminalReady(), isRequestToSend, setDataTerminalReady(), setRequestToSend() @@ -968,7 +974,7 @@ QSerialPort::PinoutSignals QSerialPort::pinoutSignals() if (!isOpen()) { setError(QSerialPort::NotOpenError); qWarning("%s: device not open", Q_FUNC_INFO); - return QSerialPort::UnknownSignal; + return QSerialPort::NoSignal; } return d->pinoutSignals(); diff --git a/src/serialport/qserialport.h b/src/serialport/qserialport.h index 66e262b..92cf79a 100644 --- a/src/serialport/qserialport.h +++ b/src/serialport/qserialport.h @@ -96,16 +96,20 @@ public: Baud19200 = 19200, Baud38400 = 38400, Baud57600 = 57600, - Baud115200 = 115200, - UnknownBaud = -1 + Baud115200 = 115200 +#if !defined(Q_CC_GNU) && !defined(Q_CC_CLANG) + , UnknownBaud = -1 +#endif }; enum DataBits { Data5 = 5, Data6 = 6, Data7 = 7, - Data8 = 8, - UnknownDataBits = -1 + Data8 = 8 +#if !defined(Q_CC_GNU) && !defined(Q_CC_CLANG) + , UnknownDataBits = -1 +#endif }; enum Parity { @@ -113,34 +117,46 @@ public: EvenParity = 2, OddParity = 3, SpaceParity = 4, - MarkParity = 5, + MarkParity = 5 #if !defined(Q_CC_GNU) && !defined(Q_CC_CLANG) - UnknownParity = -1 + , UnknownParity = -1 #endif }; -#if QT_DEPRECATED_SINCE(5, 2) -#if defined(Q_CC_GNU) || defined(Q_CC_CLANG) - QT_DEPRECATED static const Parity UnknownParity = Parity(-1); -#elif defined _MSC_VER -#pragma deprecated(UnknownParity) -#endif -#endif - enum StopBits { OneStop = 1, OneAndHalfStop = 3, - TwoStop = 2, - UnknownStopBits = -1 + TwoStop = 2 +#if !defined(Q_CC_GNU) && !defined(Q_CC_CLANG) + , UnknownStopBits = -1 +#endif }; enum FlowControl { NoFlowControl, HardwareControl, - SoftwareControl, - UnknownFlowControl = -1 + SoftwareControl +#if !defined(Q_CC_GNU) && !defined(Q_CC_CLANG) + , UnknownFlowControl = -1 +#endif }; +#if QT_DEPRECATED_SINCE(5, 2) +#if defined(Q_CC_GNU) || defined(Q_CC_CLANG) + QT_DEPRECATED static const BaudRate UnknownBaud = BaudRate(-1); + QT_DEPRECATED static const DataBits UnknownDataBits = DataBits(-1); + QT_DEPRECATED static const Parity UnknownParity = Parity(-1); + QT_DEPRECATED static const StopBits UnknownStopBits = StopBits(-1); + QT_DEPRECATED static const FlowControl UnknownFlowControl = FlowControl(-1); +#elif defined _MSC_VER +#pragma deprecated(UnknownBaud) +#pragma deprecated(UnknownDataBits) +#pragma deprecated(UnknownParity) +#pragma deprecated(UnknownStopBits) +#pragma deprecated(UnknownFlowControl) +#endif +#endif + enum PinoutSignal { NoSignal = 0x00, TransmittedDataSignal = 0x01, @@ -152,8 +168,7 @@ public: RequestToSendSignal = 0x40, ClearToSendSignal = 0x80, SecondaryTransmittedDataSignal = 0x100, - SecondaryReceivedDataSignal = 0x200, - UnknownSignal = -1 + SecondaryReceivedDataSignal = 0x200 }; Q_DECLARE_FLAGS(PinoutSignals, PinoutSignal) diff --git a/src/serialport/qserialport_symbian.cpp b/src/serialport/qserialport_symbian.cpp index 1c03565..44faeb4 100644 --- a/src/serialport/qserialport_symbian.cpp +++ b/src/serialport/qserialport_symbian.cpp @@ -433,7 +433,8 @@ void QSerialPortPrivate::detectDefaultSettings() dataBits = QSerialPort::Data8; break; default: - dataBits = QSerialPort::UnknownDataBits; + qWarning("%s: Unexpected data bits settings", Q_FUNC_INFO); + dataBits = QSerialPort::Data8; break; } @@ -469,7 +470,8 @@ void QSerialPortPrivate::detectDefaultSettings() stopBits = QSerialPort::TwoStop; break; default: - stopBits = QSerialPort::UnknownStopBits; + qWarning("%s: Unexpected stop bits settings", Q_FUNC_INFO); + stopBits = QSerialPort::OneStop; break; } @@ -482,8 +484,10 @@ void QSerialPortPrivate::detectDefaultSettings() flow = QSerialPort::HardwareControl; else if (currentSettings().iHandshake & KConfigFailDSR) flow = QSerialPort::NoFlowControl; - else - flow = QSerialPort::UnknownFlowControl; + else { + qWarning("%s: Unexpected flow control settings", Q_FUNC_INFO); + flow = QSerialPort::NoFlowControl; + } } QSerialPort::SerialPortError QSerialPortPrivate::decodeSystemError() const diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 8b3d94b..d04145e 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -305,7 +305,7 @@ QSerialPort::PinoutSignals QSerialPortPrivate::pinoutSignals() if (::ioctl(descriptor, TIOCMGET, &arg) == -1) { q->setError(decodeSystemError()); - return QSerialPort::UnknownSignal; + return QSerialPort::NoSignal; } QSerialPort::PinoutSignals ret = QSerialPort::NoSignal; @@ -921,7 +921,8 @@ void QSerialPortPrivate::detectDefaultSettings() dataBits = QSerialPort::Data8; break; default: - dataBits = QSerialPort::UnknownDataBits; + qWarning("%s: Unexpected data bits settings", Q_FUNC_INFO); + dataBits = QSerialPort::Data8; break; } @@ -953,8 +954,10 @@ void QSerialPortPrivate::detectDefaultSettings() flow = QSerialPort::SoftwareControl; else if ((currentTermios.c_cflag & CRTSCTS) && (!(currentTermios.c_iflag & (IXON | IXOFF | IXANY)))) flow = QSerialPort::HardwareControl; - else - flow = QSerialPort::UnknownFlowControl; + else { + qWarning("%s: Unexpected flow control settings", Q_FUNC_INFO); + flow = QSerialPort::NoFlowControl; + } } QSerialPort::SerialPortError QSerialPortPrivate::decodeSystemError() const diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index f5daabc..7bd5539 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -326,7 +326,7 @@ QSerialPort::PinoutSignals QSerialPortPrivate::pinoutSignals() if (!::GetCommModemStatus(descriptor, &modemStat)) { q->setError(decodeSystemError()); - return QSerialPort::UnknownSignal; + return QSerialPort::NoSignal; } QSerialPort::PinoutSignals ret = QSerialPort::NoSignal; @@ -890,7 +890,8 @@ void QSerialPortPrivate::detectDefaultSettings() dataBits = QSerialPort::Data8; break; default: - dataBits = QSerialPort::UnknownDataBits; + qWarning("%s: Unexpected data bits settings", Q_FUNC_INFO); + dataBits = QSerialPort::Data8; break; } @@ -922,7 +923,8 @@ void QSerialPortPrivate::detectDefaultSettings() stopBits = QSerialPort::TwoStop; break; default: - stopBits = QSerialPort::UnknownStopBits; + qWarning("%s: Unexpected stop bits settings", Q_FUNC_INFO); + stopBits = QSerialPort::OneStop; break; } @@ -936,8 +938,10 @@ void QSerialPortPrivate::detectDefaultSettings() } else if (currentDcb.fOutxCtsFlow && (currentDcb.fRtsControl == RTS_CONTROL_HANDSHAKE) && !currentDcb.fInX && !currentDcb.fOutX) { flow = QSerialPort::HardwareControl; - } else - flow = QSerialPort::UnknownFlowControl; + } else { + qWarning("%s: Unexpected flow control settings", Q_FUNC_INFO); + flow = QSerialPort::NoFlowControl; + } } QSerialPort::SerialPortError QSerialPortPrivate::decodeSystemError() const -- cgit v1.2.1