Source

Target

Commits (13)
Showing with 34 additions and 20 deletions
......@@ -3,7 +3,7 @@
The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
You may use, distribute and copy the Qt Toolkit under the terms of
GNU General Public License version 2, which is displayed below.
-------------------------------------------------------------------------
......
......@@ -3,7 +3,7 @@
The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
You may use, distribute and copy the Qt Toolkit under the terms of
GNU Lesser General Public License version 3. That license references
the General Public License version 3, that is displayed below. Other
portions of the Qt Toolkit may be licensed directly under this license.
......
......@@ -3,7 +3,7 @@
The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
You may use, distribute and copy the Qt Toolkit under the terms of
GNU Lesser General Public License version 3, which is displayed below.
This license makes reference to the version 3 of the GNU General
Public License, which you can find in the LICENSE.GPLv3 file.
......
......@@ -71,7 +71,8 @@ ConnectDialog::ConnectDialog(QWidget *parent) :
connect(m_ui->speedBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &ConnectDialog::checkCustomSpeedPolicy);
connect(m_ui->backendListBox, &QComboBox::currentTextChanged,
this, &ConnectDialog::backendChanged);
m_ui->rawFilterEdit->hide();
m_ui->rawFilterLabel->hide();
......@@ -102,6 +103,18 @@ void ConnectDialog::checkCustomSpeedPolicy(int idx)
}
}
void ConnectDialog::backendChanged(const QString &backend)
{
if (backend == QStringLiteral("generic"))
m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("can0"));
else if (backend == QStringLiteral("peakcan"))
m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("usbbus1"));
else if (backend == QStringLiteral("socketcan"))
m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("can0"));
else if (backend == QStringLiteral("tinycan"))
m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("channela"));
}
void ConnectDialog::ok()
{
updateSettings();
......
......@@ -76,6 +76,7 @@ public:
private slots:
void checkCustomSpeedPolicy(int idx);
void backendChanged(const QString &backend);
void ok();
void cancel();
......
......@@ -116,7 +116,7 @@ void MainWindow::connectDevice()
m_canDevice = QCanBus::instance()->createDevice(p.backendName.toLocal8Bit(), p.deviceInterfaceName);
if (!m_canDevice) {
showStatusMessage(tr("Connection error"));
showStatusMessage(tr("Error creating device: %1").arg(p.backendName));
return;
}
......@@ -133,10 +133,10 @@ void MainWindow::connectDevice()
}
if (!m_canDevice->connectDevice()) {
showStatusMessage(tr("Connection error: %1").arg(m_canDevice->errorString()));
delete m_canDevice;
m_canDevice = nullptr;
showStatusMessage(tr("Connection error"));
} else {
m_ui->actionConnect->setEnabled(false);
m_ui->actionDisconnect->setEnabled(true);
......
......@@ -72,7 +72,9 @@ public:
{
QMenu menu(this);
menu.addAction(QStringLiteral("Clear"), this, &QPlainTextEdit::clear);
#ifndef QT_NO_CLIPBOARD
menu.addAction(QStringLiteral("Copy"), this, &QPlainTextEdit::copy, QKeySequence::Copy);
#endif
menu.addSeparator();
menu.addAction(QStringLiteral("Select All"), this, &QPlainTextEdit::selectAll,
QKeySequence::SelectAll);
......
......@@ -28,7 +28,7 @@
/*! \example can
\title CAN Bus example
\brief The example sends and received CAN bus frames.
\brief The example sends and receives CAN bus frames.
The example sends and receives CAN bus frames. Incoming frames
are ordered according to their type. A connect dialog is
......
......@@ -120,7 +120,7 @@ QList<QByteArray> QCanBus::plugins() const
method. \a interfaceName is the CAN bus interface name.
Ownership of the returned backend is transferred to the caller.
Returns \c null if no suitable device can be found.
Returns \c nullptr if no suitable device can be found.
*/
QCanBusDevice *QCanBus::createDevice(const QByteArray &plugin,
const QString &interfaceName) const
......
......@@ -51,8 +51,7 @@ protected:
virtual ~QCanBusFactory() {}
};
Q_DECLARE_INTERFACE(QCanBusFactory,
"org.qt-project.Qt.QCanBusFactory")
Q_DECLARE_INTERFACE(QCanBusFactory, "org.qt-project.Qt.QCanBusFactory")
QT_END_NAMESPACE
......
......@@ -320,7 +320,7 @@ QDataStream &operator>>(QDataStream &in, QCanBusFrame &frame)
frame.setFrameType(static_cast<QCanBusFrame::FrameType>(frameType));
frame.setExtendedFrameFormat(extendedFrameFormat);
frame.setPayload(payload);
frame.setPayload(payload);
frame.setTimeStamp(QCanBusFrame::TimeStamp(seconds, microSeconds));
......
......@@ -723,7 +723,7 @@ int QModbusResponse::calculateDataSize(const QModbusResponse &response)
if (response.dataSize() < minimum)
break; // can't calculate, let's return -1 to indicate error
quint8 meiType;
quint8 meiType = 0;
response.decodeData(&meiType);
// update size, header 6 bytes: mei type + read device id + conformity level + more follows
......
......@@ -140,13 +140,9 @@ bool CanBusUtil::parseDataField(qint32 &id, QString &payload)
return false;
}
id = data.left(hashMarkPos).toInt();
id = data.left(hashMarkPos).toInt(nullptr, 16);
payload = data.right(data.length() - hashMarkPos - 1);
if (payload.size() == 0) {
output << "Payload size zero!" << endl;
printDataUsage();
return false;
}
return true;
}
......@@ -156,7 +152,10 @@ bool CanBusUtil::parsePayloadField(QString payload, bool &rtrFrame,
fdFrame = false;
rtrFrame = false;
if (payload[0].toUpper() == 'R') {
if (payload.size() == 0)
return true;
if (payload[0].toUpper() == 'R') {
rtrFrame = true;
bool validPayloadLength = false;
if (payload.size() > 1) {
......