Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package qt6-serialbus for openSUSE:Factory checked in at 2024-04-08 17:39:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/qt6-serialbus (Old) and /work/SRC/openSUSE:Factory/.qt6-serialbus.new.1905 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "qt6-serialbus" Mon Apr 8 17:39:07 2024 rev:22 rq:1165802 version:6.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/qt6-serialbus/qt6-serialbus.changes 2024-03-28 14:22:58.340599225 +0100 +++ /work/SRC/openSUSE:Factory/.qt6-serialbus.new.1905/qt6-serialbus.changes 2024-04-08 17:51:31.684038052 +0200 @@ -1,0 +2,6 @@ +Tue Apr 2 13:39:56 UTC 2024 - Christophe Marin <christo...@krop.fr> + +- Update to 6.7.0: + * https://www.qt.io/blog/qt-6.7-released + +------------------------------------------------------------------- Old: ---- qtserialbus-everywhere-src-6.6.3.tar.xz New: ---- qtserialbus-everywhere-src-6.7.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ qt6-serialbus.spec ++++++ --- /var/tmp/diff_new_pack.XU2cCk/_old 2024-04-08 17:51:32.236058426 +0200 +++ /var/tmp/diff_new_pack.XU2cCk/_new 2024-04-08 17:51:32.236058426 +0200 @@ -16,8 +16,8 @@ # -%define real_version 6.6.3 -%define short_version 6.6 +%define real_version 6.7.0 +%define short_version 6.7 %define tar_name qtserialbus-everywhere-src %define tar_suffix %{nil} # @@ -27,7 +27,7 @@ %endif # Name: qt6-serialbus -Version: 6.6.3 +Version: 6.7.0 Release: 0 Summary: Qt 6 SerialBus library License: LGPL-3.0-only OR GPL-2.0-or-later @@ -62,7 +62,7 @@ %package devel Summary: Qt 6 SerialBus library - Development files -Requires: %{name} = %{version} +Requires: qt6-serialbus = %{version} Requires: libQt6SerialBus6 = %{version} Requires: cmake(Qt6Network) = %{real_version} Requires: cmake(Qt6SerialPort) = %{real_version} ++++++ qtserialbus-everywhere-src-6.6.3.tar.xz -> qtserialbus-everywhere-src-6.7.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/.cmake.conf new/qtserialbus-everywhere-src-6.7.0/.cmake.conf --- old/qtserialbus-everywhere-src-6.6.3/.cmake.conf 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/.cmake.conf 2024-03-22 13:35:54.000000000 +0100 @@ -1,3 +1,5 @@ -set(QT_REPO_MODULE_VERSION "6.6.3") +set(QT_REPO_MODULE_VERSION "6.7.0") set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1") set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1") +list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_FOREACH=1") +list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_CONTEXTLESS_CONNECT=1") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/.tag new/qtserialbus-everywhere-src-6.7.0/.tag --- old/qtserialbus-everywhere-src-6.6.3/.tag 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/.tag 2024-03-22 13:35:54.000000000 +0100 @@ -1 +1 @@ -1df01219add4b862a132b18fce2452143e44228f +2c1fec48f9a8c075d5bd920f02c58e87322a3952 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/coin/axivion/ci_config_linux.json new/qtserialbus-everywhere-src-6.7.0/coin/axivion/ci_config_linux.json --- old/qtserialbus-everywhere-src-6.6.3/coin/axivion/ci_config_linux.json 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/coin/axivion/ci_config_linux.json 2024-03-22 13:35:54.000000000 +0100 @@ -1,9 +1,5 @@ { "Project": { - "Git": { - "_active": true, - "sourceserver_gitdir": "/data/axivion/databases/$(env:TESTED_MODULE_COIN).git" - }, "BuildSystemIntegration": { "child_order": [ "GCCSetup", @@ -34,29 +30,14 @@ "plugin_files": [ "build/plugins/*/lib*.so*.ir" ] - }, - "Project-GlobalOptions": { - "directory": "../work/qt/$(env:TESTED_MODULE_COIN)", - "ir": "build/$(env:TESTED_MODULE_COIN).ir", - "name": "qt_$(env:TESTED_MODULE_COIN)_dev_$(env:TARGET_OS_COIN)" - } - }, - "Results": { - "Dashboard": { - "dashboard_url": "https://axivion-srv.ci.qt.io/axivion/" - }, - "Database": { - "ci_mode": { - "directory": "/data/axivion/databases" - } } }, "_Format": "1.0", - "_Version": "trunk-9e0ef9c5818", + "_Version": "7.6.2", "_VersionNum": [ 7, 6, - 9999, - 11489 + 2, + 12725 ] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/dependencies.yaml new/qtserialbus-everywhere-src-6.7.0/dependencies.yaml --- old/qtserialbus-everywhere-src-6.6.3/dependencies.yaml 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/dependencies.yaml 2024-03-22 13:35:54.000000000 +0100 @@ -1,7 +1,7 @@ dependencies: ../qtbase: - ref: afdec885058c92e24604f398a926297222da06f3 + ref: 98602c26fc97eb41e3dd7548194ca637420a31b9 required: true ../qtserialport: - ref: 477a3b977154284ecad6ea9b68b62bf54b04bc89 + ref: df94dfb4016063614b0daaddb744322280ae14c1 required: false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/can/connectdialog.cpp new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/can/connectdialog.cpp --- old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/can/connectdialog.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/can/connectdialog.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -37,7 +37,7 @@ this, &ConnectDialog::pluginChanged); connect(m_ui->interfaceListBox, &QComboBox::currentTextChanged, this, &ConnectDialog::interfaceChanged); - connect(m_ui->ringBufferBox, &QCheckBox::stateChanged, [this](int state){ + connect(m_ui->ringBufferBox, &QCheckBox::stateChanged, this, [this](int state){ m_ui->ringBufferLimitBox->setEnabled(state == Qt::CheckState::Checked); }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/can/mainwindow.cpp new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/can/mainwindow.cpp --- old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/can/mainwindow.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/can/mainwindow.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -61,7 +61,7 @@ m_ui->sendFrameBox->setEnabled(false); connect(m_ui->sendFrameBox, &SendFrameBox::sendFrame, this, &MainWindow::sendFrame); - connect(m_ui->actionConnect, &QAction::triggered, [this]() { + connect(m_ui->actionConnect, &QAction::triggered, this, [this]() { m_canDevice.release()->deleteLater(); m_connectDialog->show(); }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/can/sendframebox.cpp new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/can/sendframebox.cpp --- old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/can/sendframebox.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/can/sendframebox.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -203,11 +203,11 @@ ? QString() : tr("Cannot send because Payload hex string is invalid.")); } }; - connect(m_ui->frameIdEdit, &QLineEdit::textChanged, frameIdOrPayloadChanged); - connect(m_ui->payloadEdit, &QLineEdit::textChanged, frameIdOrPayloadChanged); + connect(m_ui->frameIdEdit, &QLineEdit::textChanged, this, frameIdOrPayloadChanged); + connect(m_ui->payloadEdit, &QLineEdit::textChanged, this, frameIdOrPayloadChanged); frameIdOrPayloadChanged(); - connect(m_ui->sendButton, &QPushButton::clicked, [this]() { + connect(m_ui->sendButton, &QPushButton::clicked, this, [this]() { //! [prepare_can_frame] const uint frameId = m_ui->frameIdEdit->text().toUInt(nullptr, 16); QString data = m_ui->payloadEdit->text(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/modbus/client/mainwindow.cpp new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/modbus/client/mainwindow.cpp --- old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/modbus/client/mainwindow.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/modbus/client/mainwindow.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -151,7 +151,7 @@ } //! [create_client_0] - connect(modbusDevice, &QModbusClient::errorOccurred, [this](QModbusDevice::Error) { + connect(modbusDevice, &QModbusClient::errorOccurred, this, [this](QModbusDevice::Error) { statusBar()->showMessage(modbusDevice->errorString(), 5000); }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/modbus/client/settingsdialog.cpp new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/modbus/client/settingsdialog.cpp --- old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/modbus/client/settingsdialog.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/modbus/client/settingsdialog.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -19,7 +19,7 @@ ui->timeoutSpinner->setValue(m_settings.responseTime); ui->retriesSpinner->setValue(m_settings.numberOfRetries); - connect(ui->applyButton, &QPushButton::clicked, [this]() { + connect(ui->applyButton, &QPushButton::clicked, this, [this]() { #if QT_CONFIG(modbus_serialport) m_settings.parity = ui->parityCombo->currentIndex(); if (m_settings.parity > 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/modbus/custom/mainwindow.cpp new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/modbus/custom/mainwindow.cpp --- old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/modbus/custom/mainwindow.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/modbus/custom/mainwindow.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -44,13 +44,13 @@ // client connect(&m_client, &QModbusServer::stateChanged, this, &MainWindow::onStateChanged); - connect(&m_client, &QModbusServer::errorOccurred, [this](QModbusDevice::Error) { + connect(&m_client, &QModbusServer::errorOccurred, this, [this](QModbusDevice::Error) { statusBar()->showMessage(m_client.errorString(), 5000); }); // server connect(&m_server, &QModbusServer::dataWritten, this, &MainWindow::updateWidgets); - connect(&m_server, &QModbusServer::errorOccurred, [this](QModbusDevice::Error) { + connect(&m_server, &QModbusServer::errorOccurred, this, [this](QModbusDevice::Error) { statusBar()->showMessage(m_server.errorString(), 5000); }); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/modbus/server/settingsdialog.cpp new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/modbus/server/settingsdialog.cpp --- old/qtserialbus-everywhere-src-6.6.3/examples/serialbus/modbus/server/settingsdialog.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/examples/serialbus/modbus/server/settingsdialog.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -17,7 +17,7 @@ ui->stopBitsCombo->setCurrentText(QString::number(m_settings.stopBits)); #endif - connect(ui->applyButton, &QPushButton::clicked, [this]() { + connect(ui->applyButton, &QPushButton::clicked, this, [this]() { #if QT_CONFIG(modbus_serialport) m_settings.parity = ui->parityCombo->currentIndex(); if (m_settings.parity > 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/plugins/canbus/vectorcan/vectorcan_symbols_p.h new/qtserialbus-everywhere-src-6.7.0/src/plugins/canbus/vectorcan/vectorcan_symbols_p.h --- old/qtserialbus-everywhere-src-6.6.3/src/plugins/canbus/vectorcan/vectorcan_symbols_p.h 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/plugins/canbus/vectorcan/vectorcan_symbols_p.h 2024-03-22 13:35:54.000000000 +0100 @@ -321,16 +321,16 @@ typedef struct { quint32 id; quint32 flags; - quint16 dlc; - quint16 reserved[7]; - quint16 data[XL_CAN_MAX_DATA_LEN]; + quint8 dlc; + quint8 reserved[7]; + quint8 data[XL_CAN_MAX_DATA_LEN]; } XL_CAN_TX_MSG; typedef struct { - quint32 tag; - quint32 transId; - quint32 channelIndex; - quint32 reserved[3]; + quint16 tag; + quint16 transId; + quint8 channelIndex; + quint8 reserved[3]; union { XL_CAN_TX_MSG canMsg; } tagData; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/plugins/canbus/vectorcan/vectorcanbackend.cpp new/qtserialbus-everywhere-src-6.7.0/src/plugins/canbus/vectorcan/vectorcanbackend.cpp --- old/qtserialbus-everywhere-src-6.6.3/src/plugins/canbus/vectorcan/vectorcanbackend.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/plugins/canbus/vectorcan/vectorcanbackend.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -53,6 +53,8 @@ for (uint i = 0; i < config.channelCount; ++i) { if (config.channel[i].hwType == XL_HWTYPE_NONE) continue; + if (!(config.channel[i].channelBusCapabilities & XL_BUS_ACTIVE_CAP_CAN)) + continue; const bool isVirtual = config.channel[i].hwType == XL_HWTYPE_VIRTUAL; const bool isFd = config.channel[i].channelCapabilities & XL_CHANNEL_FLAG_CANFD_SUPPORT; @@ -115,6 +117,79 @@ VectorCanBackendPrivate * const dptr; }; +XLcanFdConf xlCanFdConfInit(int arbitrationBitRate, int dataBitRate) +{ + XLcanFdConf conf = {}; + const int minArbitrationBitRate = 5000; + if (arbitrationBitRate < minArbitrationBitRate) { + qCWarning(QT_CANBUS_PLUGINS_VECTORCAN, + "Arbitration bit rate %d is to low (Minimum: %d)", + arbitrationBitRate, minArbitrationBitRate); + return conf; + } + if (dataBitRate < arbitrationBitRate) { + qCWarning(QT_CANBUS_PLUGINS_VECTORCAN, + "Data bit rate %d must not be lower than arbitration bit rate %d", + dataBitRate, arbitrationBitRate); + return conf; + } + + int prescalerArbitration = 1; + switch (arbitrationBitRate) { + case 5000: prescalerArbitration = 50; break; + case 10000: prescalerArbitration = 25; break; + case 20000: prescalerArbitration = 20; break; + case 33333: prescalerArbitration = 8; break; + case 50000: prescalerArbitration = 5; break; + case 83333: prescalerArbitration = 3; break; + case 100000: prescalerArbitration = 4; break; + case 125000: prescalerArbitration = 2; break; + } + conf.arbitrationBitRate = arbitrationBitRate; + const int clock = 80000000; + double samplePoint = 0.75; + const int btlCyclesAbr = clock / conf.arbitrationBitRate / prescalerArbitration; + conf.tseg1Abr = (btlCyclesAbr * samplePoint) - 1; + conf.tseg2Abr = btlCyclesAbr * (1 - samplePoint); + conf.sjwAbr = conf.tseg2Abr; + + int prescalerData = 1; + switch (dataBitRate) { + case 25000: prescalerData = 20; break; + case 50000: prescalerData = 10; break; + case 83333: prescalerData = 6; break; + case 100000: prescalerData = 5; break; + case 125000: prescalerData = 4; break; + case 250000: prescalerData = 2; break; + case 8000000: samplePoint = 0.70; break; + } + conf.dataBitRate = dataBitRate; + const int btlCyclesDbr = clock / conf.dataBitRate / prescalerData; + conf.tseg1Dbr = (btlCyclesDbr * samplePoint) - 1; + conf.tseg2Dbr = btlCyclesDbr * (1 - samplePoint); + conf.sjwDbr = conf.tseg2Dbr; + + return conf; +} + +static qsizetype getDlcFromPayloadSize(const qsizetype size) +{ + if (size <= 8) + return size; + if (size <= 12) + return 9; + if (size <= 16) + return 10; + if (size <= 20) + return 11; + if (size <= 24) + return 12; + if (size <= 32) + return 13; + if (size <= 48) + return 14; + return 15; +} VectorCanBackendPrivate::VectorCanBackendPrivate(VectorCanBackend *q) : q_ptr(q) @@ -153,14 +228,22 @@ } } if (usesCanFd && arbBitRate != 0) { - XLcanFdConf xlfdconf = {}; - xlfdconf.dataBitRate = (dataBitRate != 0) ? dataBitRate : arbBitRate; - xlfdconf.arbitrationBitRate = arbBitRate; + XLcanFdConf xlfdconf = xlCanFdConfInit(arbBitRate, dataBitRate); const XLstatus status = ::xlCanFdSetConfiguration(portHandle, channelMask, &xlfdconf); - if (Q_UNLIKELY(status != XL_SUCCESS)) - qCWarning(QT_CANBUS_PLUGINS_VECTORCAN, - "Unable to change the configuration for an open channel"); + if (Q_UNLIKELY(status != XL_SUCCESS)) { + const QString errorString = systemErrorString(status); + if (status == XL_ERR_INVALID_ACCESS) { + qCWarning(QT_CANBUS_PLUGINS_VECTORCAN, "Unable to change the configuration: %ls.", + qUtf16Printable(errorString)); + q->setError(errorString, QCanBusDevice::CanBusError::ConfigurationError); + } else { + qCWarning(QT_CANBUS_PLUGINS_VECTORCAN, "Connection error: %ls.", + qUtf16Printable(errorString)); + q->setError(errorString, QCanBusDevice::CanBusError::ConnectionError); + return false; + } + } } { @@ -319,9 +402,11 @@ if (frame.hasExtendedFrameFormat()) msg.id |= XL_CAN_EXT_MSG_ID; - msg.dlc = payloadSize; + msg.dlc = static_cast<quint8>(getDlcFromPayloadSize(payloadSize)); if (frame.hasFlexibleDataRateFormat()) msg.flags = XL_CAN_TXMSG_FLAG_EDL; + if (frame.hasBitrateSwitch()) + msg.flags |= XL_CAN_TXMSG_FLAG_BRS; if (frame.frameType() == QCanBusFrame::RemoteRequestFrame) msg.flags |= XL_CAN_TXMSG_FLAG_RTR; // we do not care about the payload else @@ -382,10 +467,22 @@ const XL_CAN_EV_RX_MSG &msg = event.tagData.canRxOkMsg; + int dataLength = msg.dlc; + switch (msg.dlc) { + case 9: dataLength = 12; break; + case 10: dataLength = 16; break; + case 11: dataLength = 20; break; + case 12: dataLength = 24; break; + case 13: dataLength = 32; break; + case 14: dataLength = 48; break; + case 15: dataLength = 64; break; + } + QCanBusFrame frame(msg.id & ~XL_CAN_EXT_MSG_ID, - QByteArray(reinterpret_cast<const char *>(msg.data), int(msg.dlc))); + QByteArray(reinterpret_cast<const char *>(msg.data), dataLength)); frame.setTimeStamp(QCanBusFrame::TimeStamp::fromMicroSeconds(event.timeStamp / 1000)); - frame.setExtendedFrameFormat(msg.id & XL_CAN_RXMSG_FLAG_EDL); + frame.setExtendedFrameFormat(msg.id & XL_CAN_EXT_MSG_ID); + frame.setBitrateSwitch(msg.flags & XL_CAN_RXMSG_FLAG_BRS); frame.setFrameType((msg.flags & XL_CAN_RXMSG_FLAG_RTR) ? QCanBusFrame::RemoteRequestFrame : (msg.flags & XL_CAN_RXMSG_FLAG_EF) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/plugins/canbus/virtualcan/virtualcanbackend.cpp new/qtserialbus-everywhere-src-6.7.0/src/plugins/canbus/virtualcan/virtualcanbackend.cpp --- old/qtserialbus-everywhere-src-6.6.3/src/plugins/canbus/virtualcan/virtualcanbackend.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/plugins/canbus/virtualcan/virtualcanbackend.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -12,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::Literals::StringLiterals; + Q_DECLARE_LOGGING_CATEGORY(QT_CANBUS_PLUGINS_VIRTUALCAN) enum { @@ -188,7 +190,7 @@ { qCDebug(QT_CANBUS_PLUGINS_VIRTUALCAN, "Client [%p] sends disconnect to server.", this); - m_clientSocket->write("disconnect:can" + QByteArray::number(m_channel) + '\n'); + m_clientSocket->write(QByteArray("disconnect:can"_ba + QByteArray::number(m_channel) + '\n')); } void VirtualCanBackend::setConfigurationParameter(ConfigurationKey key, const QVariant &value) @@ -294,7 +296,7 @@ void VirtualCanBackend::clientConnected() { qCInfo(QT_CANBUS_PLUGINS_VIRTUALCAN, "Client [%p] socket connected.", this); - m_clientSocket->write("connect:can" + QByteArray::number(m_channel) + '\n'); + m_clientSocket->write(QByteArray("connect:can"_ba + QByteArray::number(m_channel) + '\n')); setState(QCanBusDevice::ConnectedState); } @@ -313,7 +315,7 @@ qCDebug(QT_CANBUS_PLUGINS_VIRTUALCAN, "Client [%p] received: '%s'.", this, answer.constData()); - if (answer.startsWith("disconnect:can" + QByteArray::number(m_channel))) { + if (answer.startsWith(QByteArray("disconnect:can"_ba + QByteArray::number(m_channel)))) { m_clientSocket->disconnectFromHost(); continue; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qcandbcfileparser.cpp new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qcandbcfileparser.cpp --- old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qcandbcfileparser.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qcandbcfileparser.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -161,9 +161,11 @@ Call the \l warnings() method to get the list of warnings that were logged during the parsing. - \note This method expects the file contents to be encoded in UTF-8. + \note This method expects the file contents to be encoded in UTF-8. If the + file has a different encoding, decode it first, and use \l parseData() + to extract the DBC information. - \sa messageDescriptions(), error(), warnings() + \sa messageDescriptions(), error(), warnings(), parseData() */ bool QCanDbcFileParser::parse(const QString &fileName) { @@ -186,9 +188,11 @@ Call the \l warnings() method to get the list of warnings that were logged during the parsing. - \note This method expects the file contents to be encoded in UTF-8. + \note This method expects the file contents to be encoded in UTF-8. If the + file has a different encoding, decode it first, and use \l parseData() + to extract the DBC information. - \sa messageDescriptions(), error(), warnings() + \sa messageDescriptions(), error(), warnings(), parseData() */ bool QCanDbcFileParser::parse(const QStringList &fileNames) { @@ -201,6 +205,43 @@ } /*! + \since 6.7 + + Parses the input data \a data and returns \c true if the parsing completed + successfully or \c false otherwise. + + If the parsing completed successfully, call the \l messageDescriptions() + method to get the list of all extracted message descriptions. + + If the parsing failed, call the \l error() and \l errorString() methods + to get the information about the error. + + Call the \l warnings() method to get the list of warnings that were + logged during the parsing. + + The method expects that \a data is the content of a valid DBC file, + properly converted to QStringView. + + Use this method when the input file has an encoding different from UTF-8. + + \code + // Read the data from a DBC file with custom encoding + const QByteArray initialData = ...; + // Convert to UTF-16 using QStringDecoder or some other way + const QString decodedData = ...; + QCanDbcFileParser parser; + const bool result = parser.parseData(decodedData); + \endcode + + \sa messageDescriptions(), error(), warnings(), parse() +*/ +bool QCanDbcFileParser::parseData(QStringView data) +{ + d->reset(); + return d->parseData(data); +} + +/*! Returns the list of message descriptions that were extracted during the last \l parse() call. @@ -355,6 +396,47 @@ return true; } +struct ReadData +{ + qsizetype index; + QStringView result; +}; + +static ReadData readUntilNewline(QStringView in, qsizetype from) +{ + const qsizetype idx = in.indexOf('\n'_L1, from); + + return (idx == -1) ? ReadData{idx, in.sliced(from).trimmed()} + : ReadData{idx, in.sliced(from, idx - from).trimmed()}; +} + +/*! + \internal + The implementation basically copies parseFile(), including all + post-processing. The only difference is in extracting the data. +*/ +bool QCanDbcFileParserPrivate::parseData(QStringView data) +{ + if (data.isEmpty()) { + m_error = QCanDbcFileParser::Error::Parsing; + m_errorString = QObject::tr("Empty input data."); + return false; + } + m_seenExtraData = false; + qsizetype from = 0; + while (true) { + const auto [idx, sv] = readUntilNewline(data, from); + if (!processLine(sv)) + return false; + if (idx == -1) // reached the end of the string + break; + from = idx + 1; + } + addCurrentMessage(); + postProcessSignalMultiplexing(); + return true; +} + /*! \internal Returns \c false only in case of hard error. Returns \c true even if some @@ -364,12 +446,20 @@ { QStringView data = line; m_lineOffset = 0; + + auto handleParsingError = [this](QLatin1StringView section) { + m_error = QCanDbcFileParser::Error::Parsing; + m_errorString = !m_fileName.isEmpty() + ? QObject::tr("Failed to parse file %1. Unexpected position " + "of %2 section.").arg(m_fileName, section) + : QObject::tr("Failed to parse input data. Unexpected position " + "of %1 section.").arg(section); + }; + if (data.startsWith(kMessageDef)) { if (m_seenExtraData) { // Unexpected position of message description - m_error = QCanDbcFileParser::Error::Parsing; - m_errorString = QObject::tr("Failed to parse file %1. Unexpected position " - "of %2 section.").arg(m_fileName, kMessageDef); + handleParsingError(kMessageDef); return false; } addCurrentMessage(); @@ -382,9 +472,7 @@ while (data.startsWith(kSignalDef)) { if (!m_isProcessingMessage || m_seenExtraData) { // Unexpected position of signal description - m_error = QCanDbcFileParser::Error::Parsing; - m_errorString = QObject::tr("Failed to parse file %1. Unexpected position " - "of %2 section.").arg(m_fileName, kSignalDef); + handleParsingError(kSignalDef); return false; } if (!parseSignal(data)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qcandbcfileparser.h new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qcandbcfileparser.h --- old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qcandbcfileparser.h 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qcandbcfileparser.h 2024-03-22 13:35:54.000000000 +0100 @@ -38,6 +38,7 @@ Q_SERIALBUS_EXPORT bool parse(const QString &fileName); Q_SERIALBUS_EXPORT bool parse(const QStringList &fileNames); + Q_SERIALBUS_EXPORT bool parseData(QStringView data); Q_SERIALBUS_EXPORT QList<QCanMessageDescription> messageDescriptions() const; Q_SERIALBUS_EXPORT MessageValueDescriptions messageValueDescriptions() const; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qcandbcfileparser_p.h new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qcandbcfileparser_p.h --- old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qcandbcfileparser_p.h 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qcandbcfileparser_p.h 2024-03-22 13:35:54.000000000 +0100 @@ -29,6 +29,7 @@ public: void reset(); bool parseFile(const QString &fileName); + bool parseData(QStringView data); bool processLine(const QStringView line); bool parseMessage(const QStringView data); QCanMessageDescription extractMessage(const QRegularExpressionMatch &match); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qmodbusclient_p.h new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qmodbusclient_p.h --- old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qmodbusclient_p.h 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qmodbusclient_p.h 2024-03-22 13:35:54.000000000 +0100 @@ -9,6 +9,9 @@ #include <QtSerialBus/qmodbuspdu.h> #include <private/qmodbusdevice_p.h> + +#include <QtCore/qpointer.h> + #include <limits.h> // diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qmodbuspdu.h new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qmodbuspdu.h --- old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qmodbuspdu.h 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qmodbuspdu.h 2024-03-22 13:35:54.000000000 +0100 @@ -235,14 +235,6 @@ inline QDataStream &operator<<(QDataStream &stream, const QModbusResponse &pdu) { return stream << static_cast<const QModbusPdu &>(pdu); } -Q_DECLARE_TYPEINFO(QModbusPdu, Q_RELOCATABLE_TYPE); -Q_DECLARE_TYPEINFO(QModbusPdu::ExceptionCode, Q_PRIMITIVE_TYPE); -Q_DECLARE_TYPEINFO(QModbusPdu::FunctionCode, Q_PRIMITIVE_TYPE); - -Q_DECLARE_TYPEINFO(QModbusRequest, Q_RELOCATABLE_TYPE); -Q_DECLARE_TYPEINFO(QModbusResponse, Q_RELOCATABLE_TYPE); -Q_DECLARE_TYPEINFO(QModbusExceptionResponse, Q_RELOCATABLE_TYPE); - QT_END_NAMESPACE Q_DECLARE_METATYPE(QModbusPdu::ExceptionCode) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qmodbusrtuserialclient.h new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qmodbusrtuserialclient.h --- old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qmodbusrtuserialclient.h 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qmodbusrtuserialclient.h 2024-03-22 13:35:54.000000000 +0100 @@ -6,7 +6,7 @@ // The pragma is required to generate proper headers for source compatibility. #if 0 -#pragma qt_deprecates(QModbusRtuSerialMaster) +#pragma qt_deprecates(QModbusRtuSerialMaster, 7.0) #endif #include <QtSerialBus/qmodbusclient.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qmodbusrtuserialserver.h new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qmodbusrtuserialserver.h --- old/qtserialbus-everywhere-src-6.6.3/src/serialbus/qmodbusrtuserialserver.h 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/src/serialbus/qmodbusrtuserialserver.h 2024-03-22 13:35:54.000000000 +0100 @@ -6,7 +6,7 @@ // The pragma is required to generate proper headers for source compatibility. #if 0 -#pragma qt_deprecates(QModbusRtuSerialSlave) +#pragma qt_deprecates(QModbusRtuSerialSlave, 7.0) #endif #include <QtSerialBus/qmodbusserver.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/sync.profile new/qtserialbus-everywhere-src-6.7.0/sync.profile --- old/qtserialbus-everywhere-src-6.6.3/sync.profile 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/sync.profile 1970-01-01 01:00:00.000000000 +0100 @@ -1,14 +0,0 @@ -%modules = ( - "QtSerialBus" => "$basedir/src/serialbus", -); - -%classnames = ( - "QtSerialBus/qmodbusrtuserialserver.h" => "QModbusRtuSerialSlave", - "QtSerialBus/qmodbusrtuserialclient.h" => "QModbusRtuSerialMaster" -), - -%deprecatedheaders = ( - "QtSerialBus" => { - "qserialbusglobal.h" => "QtSerialBus/qtserialbusglobal.h" - }, -); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/tests/auto/plugins/testcanbus/testcanbackend.cpp new/qtserialbus-everywhere-src-6.7.0/tests/auto/plugins/testcanbus/testcanbackend.cpp --- old/qtserialbus-everywhere-src-6.6.3/tests/auto/plugins/testcanbus/testcanbackend.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/tests/auto/plugins/testcanbus/testcanbackend.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -12,7 +12,7 @@ TestCanBackend::TestCanBackend() : simulateReceivingTimer(new QTimer(this)) { - connect(simulateReceivingTimer, &QTimer::timeout, [this]() { + connect(simulateReceivingTimer, &QTimer::timeout, this, [this]() { const quint64 timeStamp = QDateTime::currentDateTime().toMSecsSinceEpoch(); QCanBusFrame dummyFrame(12, "def"); dummyFrame.setTimeStamp(QCanBusFrame::TimeStamp::fromMicroSeconds(timeStamp * 1000)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp new/qtserialbus-everywhere-src-6.7.0/tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp --- old/qtserialbus-everywhere-src-6.6.3/tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/tests/auto/qcanbusdevice/tst_qcanbusdevice.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -599,7 +599,7 @@ device->triggerNewFrame(); }); QTimer::singleShot(2000, [&]() { device->triggerNewFrame(); }); - QObject::connect(device.get(), &QCanBusDevice::framesReceived, [this, &handleCounter]() { + QObject::connect(device.get(), &QCanBusDevice::framesReceived, this, [this, &handleCounter]() { handleCounter++; // this should trigger a recursion which we want to catch QVERIFY(!device->waitForFramesReceived(5000)); @@ -686,7 +686,7 @@ device->writeFrame(frame); QTimer::singleShot(1000, [&]() { device->writeFrame(frame); }); QTimer::singleShot(2000, [&]() { device->writeFrame(frame); }); - QObject::connect(device.get(), &QCanBusDevice::framesWritten, [this, &handleCounter]() { + QObject::connect(device.get(), &QCanBusDevice::framesWritten, this, [this, &handleCounter]() { handleCounter++; // this should trigger a recursion which we want to catch QVERIFY(!device->waitForFramesWritten(5000)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtserialbus-everywhere-src-6.6.3/tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp new/qtserialbus-everywhere-src-6.7.0/tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp --- old/qtserialbus-everywhere-src-6.6.3/tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp 2024-03-18 18:49:49.000000000 +0100 +++ new/qtserialbus-everywhere-src-6.7.0/tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp 2024-03-22 13:35:54.000000000 +0100 @@ -19,6 +19,7 @@ { Q_OBJECT private slots: + void initTestCase_data(); void initTestCase(); void construct(); void uinqueId(); @@ -31,6 +32,13 @@ QString m_filesDir; }; +void tst_QCanDbcFileParser::initTestCase_data() +{ + QTest::addColumn<bool>("readFromFile"); + QTest::newRow("from_file") << true; + QTest::newRow("from_input_data") << false; +} + void tst_QCanDbcFileParser::initTestCase() { m_filesDir = QString::fromLatin1(QT_TEST_DATADIR) + QDir::separator(); @@ -911,19 +919,39 @@ QFETCH(QString, expectedErrorDescription); QFETCH(QStringList, expectedWarnings); QFETCH(QList<QCanMessageDescription>, expectedMessageDescriptions); + QFETCH_GLOBAL(bool, readFromFile); QVERIFY(!fileNames.isEmpty()); QCanDbcFileParser parser; - if (fileNames.size() > 1) { - QStringList files; - for (const auto &fn : fileNames) - files.push_back(m_filesDir + fn); - parser.parse(files); + if (readFromFile) { + if (fileNames.size() > 1) { + QStringList files; + for (const auto &fn : fileNames) + files.push_back(m_filesDir + fn); + parser.parse(files); + } else { + parser.parse(m_filesDir + fileNames.first()); + } } else { - parser.parse(m_filesDir + fileNames.first()); + // read the file outside of the parser + if (fileNames.size() > 1) + QSKIP("parseData() does not support multiple files"); + + QByteArray allData; + QFile f(m_filesDir + fileNames.first()); + if (f.open(QIODevice::ReadOnly)) + allData = f.readAll(); + f.close(); + if (allData.isEmpty()) + QSKIP("No valid input file provided"); + const QString inputData = QString::fromUtf8(allData); + parser.parseData(inputData); } + QCOMPARE_EQ(parser.error(), expectedError); + if (!readFromFile && expectedErrorDescription.contains("Failed to parse file")) + expectedErrorDescription.replace(QRegularExpression(u"file .+dbc"_s), u"input data"_s); QCOMPARE_EQ(parser.errorString(), expectedErrorDescription); if (expectedError != QCanDbcFileParser::Error::None) @@ -949,8 +977,24 @@ QVERIFY(equals(messageDescriptions, expectedMessageDescriptions)); } +static bool parseHelper(QCanDbcFileParser *parser, const QString &name, bool readFromFile) +{ + if (readFromFile) + return parser->parse(name); + + QString data; + QFile f(name); + if (f.open(QIODevice::ReadOnly)) { + data = QString::fromUtf8(f.readAll()); + f.close(); + } + return parser->parseData(data); +} + void tst_QCanDbcFileParser::valueDescriptions() { + QFETCH_GLOBAL(bool, readFromFile); + QCanDbcFileParser::ValueDescriptions s0_test_value_descriptions; s0_test_value_descriptions.insert(0, u"Description for the value '0x0'"_s); s0_test_value_descriptions.insert(1, u"Description for the value '0x1'"_s); @@ -994,21 +1038,23 @@ "VAL_ 2566844926 s2 4 \"Value4\" 3 \"Value3\" 2 \"Value2\" 1 \"Value1\" 0 ;"_s }; - const QString fileName = u"value_descriptions.dbc"_s; QCanDbcFileParser parser; - parser.parse(m_filesDir + fileName); - QCOMPARE(parser.error(), QCanDbcFileParser::Error::None); + const QString fileName = u"value_descriptions.dbc"_s; + QVERIFY(parseHelper(&parser, m_filesDir + fileName, readFromFile)); + QCOMPARE(parser.error(), QCanDbcFileParser::Error::None); QCOMPARE(parser.messageValueDescriptions(), expectedDescriptions); QCOMPARE(parser.warnings(), expectedWarnings); } void tst_QCanDbcFileParser::resetState() { + QFETCH_GLOBAL(bool, readFromFile); + // Test that the state is correctly reset between parsings const QString fileName = u"value_descriptions.dbc"_s; QCanDbcFileParser parser; - parser.parse(m_filesDir + fileName); + QVERIFY(parseHelper(&parser, m_filesDir + fileName, readFromFile)); QCOMPARE(parser.error(), QCanDbcFileParser::Error::None); QVERIFY(!parser.messageDescriptions().isEmpty()); @@ -1018,8 +1064,11 @@ // Now when we parse an invalid file, we should get an error, and all // other getters should return default values const QString invalidName = u"invalid_file"_s; - parser.parse(m_filesDir + invalidName); - QCOMPARE(parser.error(), QCanDbcFileParser::Error::FileReading); + QVERIFY(!parseHelper(&parser, m_filesDir + invalidName, readFromFile)); + + const auto expectedError = readFromFile ? QCanDbcFileParser::Error::FileReading + : QCanDbcFileParser::Error::Parsing; + QCOMPARE(parser.error(), expectedError); QVERIFY(parser.messageDescriptions().isEmpty()); QVERIFY(parser.warnings().isEmpty()); QVERIFY(parser.messageValueDescriptions().isEmpty());