summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-25 10:25:00 +0100
committerLiang Qi <liang.qi@qt.io>2017-01-25 10:25:00 +0100
commit4156b8a637783e6e3d54359275c28ea0c6a493b6 (patch)
tree7c8ec17ceb0c61aecb13deaf77a358bb2ddf9542
parent96406689fa3be46b1e7f4193c2d82b0407f543ad (diff)
parent6cb07fb512082bac7df5b50048d7ade111b575e0 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: .qmake.conf Change-Id: Ie8bb65e2f51726a9a6108619d881263de1899b9c
-rw-r--r--.gitignore3
-rw-r--r--src/plugins/canbus/socketcan/socketcanbackend.cpp19
-rw-r--r--src/plugins/canbus/vectorcan/vectorcanbackend.h2
-rw-r--r--src/serialbus/doc/src/tinycan.qdoc4
-rw-r--r--src/serialbus/qcanbusdevice.cpp7
-rw-r--r--src/serialbus/qcanbusframe.cpp2
-rw-r--r--src/serialbus/qmodbusrtuserialslave_p.h20
7 files changed, 31 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index 98ece5a..07d658f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ examples/serialbus/modbus/slave/modbusslave
*.pch
.rcc
src/serialbus/doc/snippets/serialbus_cppsnippet
+src/serialbus/QtSerialBus.version*
examples/serialbus/can/can
tests/auto/qcanbus/tst_qcanbus
tests/auto/qcanbusdevice/tst_qcanbusdevice
@@ -23,8 +24,10 @@ tests/auto/qmodbusclient/tst_qmodbusclient
tests/auto/qmodbuscommevent/tst_qmodbuscommevent
tests/auto/qmodbusdataunit/tst_qmodbusdataunit
tests/auto/qmodbusdevice/tst_qmodbusdevice
+tests/auto/qmodbusdeviceidentification/tst_qmodbusdeviceidentification
tests/auto/qmodbuspdu/tst_qmodbuspdu
tests/auto/qmodbusreply/tst_qmodbusreply
+tests/auto/qmodbusrtuserialmaster/tst_qmodbusrtuserialmaster
tests/auto/qmodbusserver/tst_qmodbusserver
*_resource.rc
*.exe
diff --git a/src/plugins/canbus/socketcan/socketcanbackend.cpp b/src/plugins/canbus/socketcan/socketcanbackend.cpp
index f65e42a..509008d 100644
--- a/src/plugins/canbus/socketcan/socketcanbackend.cpp
+++ b/src/plugins/canbus/socketcan/socketcanbackend.cpp
@@ -427,25 +427,17 @@ bool SocketCanBackend::writeFrame(const QCanBusFrame &newData)
canId |= CAN_ERR_FLAG;
}
-
- int payloadSize = newData.payload().size();
- if ((!canFdOptionEnabled && payloadSize > CAN_MAX_DLEN)
- || (canFdOptionEnabled && payloadSize > CANFD_MAX_DLEN)) {
- qWarning() << QString("payload (%1 bytes) is too large for chosen frame size of "
- "maximal %2 bytes. Frame is discarded.").
- arg(payloadSize).arg(canFdOptionEnabled ? CANFD_MAX_DLEN : CAN_MAX_DLEN);
- if (!canFdOptionEnabled && newData.hasFlexibleDataRateFormat())
- setError(tr("Sending CAN FD frame although CAN FD option not enabled."),
- QCanBusDevice::WriteError);
- else
- setError(tr("Frame payload exceeds maximum CAN frame payload length."),
- QCanBusDevice::WriteError);
+ if (Q_UNLIKELY(!canFdOptionEnabled && newData.hasFlexibleDataRateFormat())) {
+ const QString error = tr("Sending CAN FD frame although CAN FD option not enabled.");
+ qDebug("%ls", qUtf16Printable(error));
+ setError(error, QCanBusDevice::WriteError);
return false;
}
qint64 bytesWritten = 0;
if (newData.hasFlexibleDataRateFormat()) {
canfd_frame frame;
+ memset(&frame, 0, sizeof(frame));
frame.len = newData.payload().size();
frame.can_id = canId;
frame.flags = newData.hasBitrateSwitch() ? CANFD_BRS : 0;
@@ -455,6 +447,7 @@ bool SocketCanBackend::writeFrame(const QCanBusFrame &newData)
bytesWritten = ::write(canSocket, &frame, sizeof(frame));
} else {
can_frame frame;
+ memset(&frame, 0, sizeof(frame));
frame.can_dlc = newData.payload().size();
frame.can_id = canId;
::memcpy(frame.data, newData.payload().constData(), frame.can_dlc);
diff --git a/src/plugins/canbus/vectorcan/vectorcanbackend.h b/src/plugins/canbus/vectorcan/vectorcanbackend.h
index d956634..ff8fcfe 100644
--- a/src/plugins/canbus/vectorcan/vectorcanbackend.h
+++ b/src/plugins/canbus/vectorcan/vectorcanbackend.h
@@ -56,7 +56,7 @@ class VectorCanBackend : public QCanBusDevice
Q_DISABLE_COPY(VectorCanBackend)
public:
explicit VectorCanBackend(const QString &name, QObject *parent = nullptr);
- ~VectorCanBackend() override;
+ ~VectorCanBackend();
bool open() override;
void close() override;
diff --git a/src/serialbus/doc/src/tinycan.qdoc b/src/serialbus/doc/src/tinycan.qdoc
index a504198..13cf05b 100644
--- a/src/serialbus/doc/src/tinycan.qdoc
+++ b/src/serialbus/doc/src/tinycan.qdoc
@@ -33,6 +33,10 @@
The TinyCAN plugin encapsulates the low-level API to work with the
\l{http://www.mhs-elektronik.de/}{MHS Elektronik} CAN adapters.
+ \note The TinyCAN adapters use virtual serial ports. To communicate with
+ TinyCAN adapters in Linux, the user must have appropriate access rights.
+ Usually these rights are given to all users in the group "dialout".
+
\section1 Creating CAN Bus Devices
At first it is necessary to check that QCanBus provides the desired plugin:
diff --git a/src/serialbus/qcanbusdevice.cpp b/src/serialbus/qcanbusdevice.cpp
index 1475732..19984e8 100644
--- a/src/serialbus/qcanbusdevice.cpp
+++ b/src/serialbus/qcanbusdevice.cpp
@@ -409,7 +409,12 @@ qint64 QCanBusDevice::framesAvailable() const
}
/*!
- Returns the number of frames waiting to be written.
+ For buffered devices, this function returns the number of frames waiting to be written.
+ For unbuffered devices, this function always returns zero.
+
+ \note There may be additional buffering in the CAN driver and CAN hardware layer.
+ Therefore, if this function returns zero, that does not mean all CAN frames are
+ already written to the CAN bus.
\sa writeFrame()
*/
diff --git a/src/serialbus/qcanbusframe.cpp b/src/serialbus/qcanbusframe.cpp
index 4f00c88..f700595 100644
--- a/src/serialbus/qcanbusframe.cpp
+++ b/src/serialbus/qcanbusframe.cpp
@@ -352,7 +352,7 @@ QT_BEGIN_NAMESPACE
/*!
Returns the CAN frame as a formatted string.
- The output contains the CAN identfier in hexadecimal format, right
+ The output contains the CAN identifier in hexadecimal format, right
adjusted to 32 bit, followed by the data length in square brackets
and the payload in hexadecimal format.
diff --git a/src/serialbus/qmodbusrtuserialslave_p.h b/src/serialbus/qmodbusrtuserialslave_p.h
index 4c5f885..32a4dc2 100644
--- a/src/serialbus/qmodbusrtuserialslave_p.h
+++ b/src/serialbus/qmodbusrtuserialslave_p.h
@@ -94,7 +94,7 @@ public:
qCWarning(QT_MODBUS) << "(RTU server) Incomplete ADU received, ignoring";
// The quantity of CRC errors encountered by the remote device since its last
- // restart, clear counters operation, or power–up. In case of a message
+ // restart, clear counters operation, or power-up. In case of a message
// length < 4 bytes, the receiving device is not able to calculate the CRC.
incrementCounter(QModbusServerPrivate::Counter::BusCommunicationError);
storeModbusCommEvent(event | QModbusCommEvent::ReceiveFlag::CommunicationError);
@@ -113,7 +113,7 @@ public:
qCWarning(QT_MODBUS) << "(RTU server) ADU does not match expected size, ignoring";
// The quantity of messages addressed to the remote device that it could not
// handle due to a character overrun condition, since its last restart, clear
- // counters operation, or power–up. A character overrun is caused by data
+ // counters operation, or power-up. A character overrun is caused by data
// characters arriving at the port faster than they can be stored, or by the loss
// of a character due to a hardware malfunction.
incrementCounter(QModbusServerPrivate::Counter::BusCharacterOverrun);
@@ -130,14 +130,14 @@ public:
<< adu.checksum<quint16>() << ", calculated CRC:"
<< QModbusSerialAdu::calculateCRC(adu.data(), adu.size());
// The quantity of CRC errors encountered by the remote device since its last
- // restart, clear counters operation, or power–up.
+ // restart, clear counters operation, or power-up.
incrementCounter(QModbusServerPrivate::Counter::BusCommunicationError);
storeModbusCommEvent(event | QModbusCommEvent::ReceiveFlag::CommunicationError);
return;
}
// The quantity of messages that the remote device has detected on the communications
- // system since its last restart, clear counters operation, or power–up.
+ // system since its last restart, clear counters operation, or power-up.
incrementCounter(QModbusServerPrivate::Counter::BusMessage);
// If we do not process a Broadcast ...
@@ -159,14 +159,14 @@ public:
if (q->value(QModbusServer::DeviceBusy).value<quint16>() == 0xffff) {
// is busy, update the quantity of messages addressed to the remote device for
// which it returned a Server Device Busy exception response, since its last
- // restart, clear counters operation, or power–up.
+ // restart, clear counters operation, or power-up.
incrementCounter(QModbusServerPrivate::Counter::ServerBusy);
response = QModbusExceptionResponse(req.functionCode(),
QModbusExceptionResponse::ServerDeviceBusy);
} else {
// is not busy, update the quantity of messages addressed to the remote device,
// or broadcast, that the remote device has processed since its last restart,
- // clear counters operation, or power–up.
+ // clear counters operation, or power-up.
incrementCounter(QModbusServerPrivate::Counter::ServerMessage);
response = q->processRequest(req);
}
@@ -181,7 +181,7 @@ public:
|| q->value(QModbusServer::ListenOnlyMode).toBool()) {
// The quantity of messages addressed to the remote device for which it has
// returned no response (neither a normal response nor an exception response),
- // since its last restart, clear counters operation, or power–up.
+ // since its last restart, clear counters operation, or power-up.
incrementCounter(QModbusServerPrivate::Counter::ServerNoResponse);
storeModbusCommEvent(event);
return;
@@ -227,7 +227,7 @@ public:
case QModbusExceptionResponse::ServerDeviceBusy:
// The quantity of messages addressed to the remote device for which it
// returned a server device busy exception response, since its last restart,
- // clear counters operation, or power–up.
+ // clear counters operation, or power-up.
incrementCounter(QModbusServerPrivate::Counter::ServerBusy);
event |= QModbusCommEvent::SendFlag::ServerBusyExceptionSent;
break;
@@ -235,7 +235,7 @@ public:
case QModbusExceptionResponse::NegativeAcknowledge:
// The quantity of messages addressed to the remote device for which it
// returned a negative acknowledge (NAK) exception response, since its last
- // restart, clear counters operation, or power–up.
+ // restart, clear counters operation, or power-up.
incrementCounter(QModbusServerPrivate::Counter::ServerNAK);
event |= QModbusCommEvent::SendFlag::ServerProgramNAKExceptionSent;
break;
@@ -244,7 +244,7 @@ public:
break;
}
// The quantity of Modbus exception responses returned by the remote device since
- // its last restart, clear counters operation, or power–up.
+ // its last restart, clear counters operation, or power-up.
incrementCounter(QModbusServerPrivate::Counter::BusExceptionError);
} else {
switch (quint16(req.functionCode())) {