summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorStefan Steinwasser <stefan-qt@kcxh6.de>2024-03-25 11:30:40 +0100
committerStefan Steinwasser <stefan-qt@kcxh6.de>2024-03-27 09:53:41 +0100
commit9d8501e9e996dd87020208e4b07673cb62bcf10e (patch)
tree36209449387245044b01b21203ff1fb59ddf3dd7 /src/plugins
parent7ae921cb5e1c0629427ed2f1843871558432da79 (diff)
VectorCAN: Set CAN-FD configuration only for uninitialized channels
The Vector plugin allows multi application access to single CAN channels, but only the first application gets init access and is allowed to set the configuration parameters. On hardware devices you get an invalid access error, but the virtual channels return an XL_ERROR and the connection fails. [ChangeLog][CAN][Vector] Fixed XL_ERROR when try to set CAN-FD configuration for a virtual channel which was already opened by another application. Fixes: QTBUG-123012 Pick-to: 6.7 Change-Id: Iafb770940025b5c71fd5db83e61edbb0f49254e2 Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/canbus/vectorcan/vectorcanbackend.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/plugins/canbus/vectorcan/vectorcanbackend.cpp b/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
index c728399..c7ec84c 100644
--- a/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
+++ b/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
@@ -226,22 +226,27 @@ bool VectorCanBackendPrivate::open()
portHandle = XL_INVALID_PORTHANDLE;
return false;
}
- }
- if (usesCanFd && arbBitRate != 0) {
- XLcanFdConf xlfdconf = xlCanFdConfInit(arbBitRate, dataBitRate);
-
- const XLstatus status = ::xlCanFdSetConfiguration(portHandle, channelMask, &xlfdconf);
- 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);
+ if (usesCanFd && arbBitRate != 0) {
+ if (permissionMask != 0) {
+ XLcanFdConf xlfdconf = xlCanFdConfInit(arbBitRate, dataBitRate);
+
+ const XLstatus statusFd = ::xlCanFdSetConfiguration(portHandle, channelMask, &xlfdconf);
+ if (Q_UNLIKELY(statusFd != XL_SUCCESS)) {
+ const QString errorString = systemErrorString(statusFd);
+ if (statusFd == 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;
+ }
+ }
} else {
- qCWarning(QT_CANBUS_PLUGINS_VECTORCAN, "Connection error: %ls.",
- qUtf16Printable(errorString));
- q->setError(errorString, QCanBusDevice::CanBusError::ConnectionError);
- return false;
+ qCWarning(QT_CANBUS_PLUGINS_VECTORCAN, "No init access for channel %d! "
+ "Using existing configuration!", channelIndex);
}
}
}