summaryrefslogtreecommitdiff
path: root/src/serialport/qserialport_unix.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-14 14:07:32 +0200
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-14 14:07:32 +0200
commit3bb682ea29ffaf72ff73e6eb57abdc5c59524e8a (patch)
tree4d8e828da7ea6115c6ffe26cec2d024bad60aa91 /src/serialport/qserialport_unix.cpp
parent14fe584d2abb1ae0776f0973b245baa79d0468d2 (diff)
parent62dfdeb3642250bdb642dbf607a8c7b95e57835e (diff)
downloadqtserialport-3bb682ea29ffaf72ff73e6eb57abdc5c59524e8a.tar.gz
Merge remote-tracking branch 'origin/5.3' into 5.4
Change-Id: Id7e66059233e8d07ba44cad19048d9cddc68e250
Diffstat (limited to 'src/serialport/qserialport_unix.cpp')
-rw-r--r--src/serialport/qserialport_unix.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index afdc640..9979256 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -369,10 +369,9 @@ bool QSerialPortPrivate::setBreakEnabled(bool set)
return true;
}
-void QSerialPortPrivate::startWriting()
+qint64 QSerialPortPrivate::readData(char *data, qint64 maxSize)
{
- if (!isWriteNotificationEnabled())
- setWriteNotificationEnabled(true);
+ return readBuffer.read(data, maxSize);
}
bool QSerialPortPrivate::waitForReadyRead(int msecs)
@@ -496,9 +495,6 @@ QSerialPortPrivate::setCustomBaudRate(qint32 baudRate, QSerialPort::Directions d
if (::ioctl(descriptor, TIOCGSERIAL, &currentSerialInfo) == -1)
return decodeSystemError();
- if (currentSerialInfo.baud_base % baudRate != 0)
- return QSerialPort::UnsupportedOperationError;
-
currentSerialInfo.flags &= ~ASYNC_SPD_MASK;
currentSerialInfo.flags |= (ASYNC_SPD_CUST /* | ASYNC_LOW_LATENCY*/);
currentSerialInfo.custom_divisor = currentSerialInfo.baud_base / baudRate;
@@ -506,6 +502,13 @@ QSerialPortPrivate::setCustomBaudRate(qint32 baudRate, QSerialPort::Directions d
if (currentSerialInfo.custom_divisor == 0)
return QSerialPort::UnsupportedOperationError;
+ if (currentSerialInfo.custom_divisor * baudRate != currentSerialInfo.baud_base) {
+ qWarning("Baud rate of serial port %s is set to %d instead of %d: divisor %f unsupported",
+ qPrintable(systemLocation),
+ currentSerialInfo.baud_base / currentSerialInfo.custom_divisor,
+ baudRate, (float)currentSerialInfo.baud_base / baudRate);
+ }
+
if (::ioctl(descriptor, TIOCSSERIAL, &currentSerialInfo) == -1)
return decodeSystemError();
@@ -868,6 +871,19 @@ inline bool QSerialPortPrivate::initialize(QIODevice::OpenMode mode)
return true;
}
+qint64 QSerialPortPrivate::bytesToWrite() const
+{
+ return writeBuffer.size();
+}
+
+qint64 QSerialPortPrivate::writeData(const char *data, qint64 maxSize)
+{
+ ::memcpy(writeBuffer.reserve(maxSize), data, maxSize);
+ if (!writeBuffer.isEmpty() && !isWriteNotificationEnabled())
+ setWriteNotificationEnabled(true);
+ return maxSize;
+}
+
bool QSerialPortPrivate::updateTermios()
{
Q_Q(QSerialPort);