summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2016-07-25 20:42:17 +0200
committerAndré Hartmann <aha_1980@gmx.de>2016-08-30 12:39:12 +0000
commit45bcf9e8f0249a984a90e021e69e93b96733ddd4 (patch)
treedaacfdc3b90cd51afa6368181025d6a9785d9618
parent5291efbac552b55d1343040f61908fbf71c29243 (diff)
CAN: Unify interface names
Mostly, the interfaces now simply start with can0 and the number increases for every next interface. Some vendors distinguish between e.g. PCI and USB interfaces. In this case, the interfaces are named usb0 and pci0, with increasing numbers, respectively. Multiple channels per device are accessed by adding the channel number after a dot: can0.0 for the first channel in the first device (TinyCAN). SocketCAN is still a bit different, as it allows arbitrary interface names to be mapped to the hardware or virtual CAN busses. [ChangeLog][QtSerialBus][Unify interface names] The interface names of the different backends were unified to follow a common rule: The prefixes were unified, the numbering now always starts with zero. Change-Id: Ia2ca76a9be01b9123aed1ede90debf69871bb82c Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--examples/serialbus/can/connectdialog.cpp6
-rw-r--r--src/plugins/canbus/peakcan/peakcanbackend.cpp32
-rw-r--r--src/plugins/canbus/tinycan/tinycanbackend.cpp4
-rw-r--r--src/plugins/canbus/vectorcan/vectorcanbackend.cpp4
-rw-r--r--src/serialbus/doc/src/peakcan.qdoc8
-rw-r--r--src/serialbus/doc/src/tinycan.qdoc5
-rw-r--r--src/serialbus/doc/src/vectorcan.qdoc13
7 files changed, 37 insertions, 35 deletions
diff --git a/examples/serialbus/can/connectdialog.cpp b/examples/serialbus/can/connectdialog.cpp
index ba6d060..43ded1d 100644
--- a/examples/serialbus/can/connectdialog.cpp
+++ b/examples/serialbus/can/connectdialog.cpp
@@ -108,13 +108,13 @@ 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"));
+ m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("usb0"));
else if (backend == QStringLiteral("socketcan"))
m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("can0"));
else if (backend == QStringLiteral("tinycan"))
- m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("channela"));
+ m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("can0.0"));
else if (backend == QStringLiteral("vectorcan"))
- m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("channel0"));
+ m_ui->interfaceNameEdit->setPlaceholderText(QStringLiteral("can0"));
}
void ConnectDialog::ok()
diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp
index 06a2d4b..eb2d4b9 100644
--- a/src/plugins/canbus/peakcan/peakcanbackend.cpp
+++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp
@@ -288,37 +288,37 @@ bool PeakCanBackendPrivate::setConfigurationParameter(int key, const QVariant &v
static int channelIndexFromName(const QString &interfaceName)
{
- if (interfaceName == QStringLiteral("usbbus1"))
+ if (interfaceName == QStringLiteral("usb0"))
return PCAN_USBBUS1;
- else if (interfaceName == QStringLiteral("usbbus2"))
+ else if (interfaceName == QStringLiteral("usb1"))
return PCAN_USBBUS2;
- else if (interfaceName == QStringLiteral("usbbus3"))
+ else if (interfaceName == QStringLiteral("usb2"))
return PCAN_USBBUS3;
- else if (interfaceName == QStringLiteral("usbbus4"))
+ else if (interfaceName == QStringLiteral("usb3"))
return PCAN_USBBUS4;
- else if (interfaceName == QStringLiteral("usbbus5"))
+ else if (interfaceName == QStringLiteral("usb4"))
return PCAN_USBBUS5;
- else if (interfaceName == QStringLiteral("usbbus6"))
+ else if (interfaceName == QStringLiteral("usb5"))
return PCAN_USBBUS6;
- else if (interfaceName == QStringLiteral("usbbus7"))
+ else if (interfaceName == QStringLiteral("usb6"))
return PCAN_USBBUS7;
- else if (interfaceName == QStringLiteral("usbbus8"))
+ else if (interfaceName == QStringLiteral("usb7"))
return PCAN_USBBUS8;
- else if (interfaceName == QStringLiteral("pcibus1"))
+ else if (interfaceName == QStringLiteral("pci0"))
return PCAN_PCIBUS1;
- else if (interfaceName == QStringLiteral("pcibus2"))
+ else if (interfaceName == QStringLiteral("pci1"))
return PCAN_PCIBUS2;
- else if (interfaceName == QStringLiteral("pcibus3"))
+ else if (interfaceName == QStringLiteral("pci2"))
return PCAN_PCIBUS3;
- else if (interfaceName == QStringLiteral("pcibus4"))
+ else if (interfaceName == QStringLiteral("pci3"))
return PCAN_PCIBUS4;
- else if (interfaceName == QStringLiteral("pcibus5"))
+ else if (interfaceName == QStringLiteral("pci4"))
return PCAN_PCIBUS5;
- else if (interfaceName == QStringLiteral("pcibus6"))
+ else if (interfaceName == QStringLiteral("pci5"))
return PCAN_PCIBUS6;
- else if (interfaceName == QStringLiteral("pcibus7"))
+ else if (interfaceName == QStringLiteral("pci6"))
return PCAN_PCIBUS7;
- else if (interfaceName == QStringLiteral("pcibus8"))
+ else if (interfaceName == QStringLiteral("pci7"))
return PCAN_PCIBUS8;
else // TODO: Add other indexes here
return PCAN_NONEBUS;
diff --git a/src/plugins/canbus/tinycan/tinycanbackend.cpp b/src/plugins/canbus/tinycan/tinycanbackend.cpp
index 2f9c191..ee2b347 100644
--- a/src/plugins/canbus/tinycan/tinycanbackend.cpp
+++ b/src/plugins/canbus/tinycan/tinycanbackend.cpp
@@ -305,9 +305,9 @@ QString TinyCanBackendPrivate::systemErrorString(int errorCode)
static int channelIndexFromName(const QString &interfaceName)
{
- if (interfaceName == QStringLiteral("channela"))
+ if (interfaceName == QStringLiteral("can0.0"))
return INDEX_CAN_KANAL_A;
- else if (interfaceName == QStringLiteral("channelb"))
+ else if (interfaceName == QStringLiteral("can0.1"))
return INDEX_CAN_KANAL_B;
else
return INDEX_INVALID;
diff --git a/src/plugins/canbus/vectorcan/vectorcanbackend.cpp b/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
index 78cf22f..d00d16a 100644
--- a/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
+++ b/src/plugins/canbus/vectorcan/vectorcanbackend.cpp
@@ -224,8 +224,8 @@ bool VectorCanBackendPrivate::setConfigurationParameter(int key, const QVariant
void VectorCanBackendPrivate::setupChannel(const QString &interfaceName)
{
- if (interfaceName.startsWith(QStringLiteral("channel"))) {
- const QStringRef ref = interfaceName.midRef(7);
+ if (interfaceName.startsWith(QStringLiteral("can"))) {
+ const QStringRef ref = interfaceName.midRef(3);
bool ok = false;
const int channelIndex = ref.toInt(&ok);
if (ok && (channelIndex >= 0 && channelIndex < XL_CONFIG_MAX_CHANNELS)) {
diff --git a/src/serialbus/doc/src/peakcan.qdoc b/src/serialbus/doc/src/peakcan.qdoc
index 8a973cb..ce612fb 100644
--- a/src/serialbus/doc/src/peakcan.qdoc
+++ b/src/serialbus/doc/src/peakcan.qdoc
@@ -49,13 +49,13 @@
\code
QCanBusDevice *device = QCanBus::instance()->createDevice(
- QStringLiteral("peakcan"), QStringLiteral("usbbus1"));
+ QStringLiteral("peakcan"), QStringLiteral("usb0"));
device->connectDevice();
\endcode
- Where \e usbbus1 is the active CAN interface name. The PeakCAN backend supports
- eight USB interfaces from \e usbbus1 to \e usbbus8 and eight PCI interfaces from
- \e pcibus1 to \e pcibus8.
+ Where \e usb0 is the active CAN interface name. The PeakCAN backend supports
+ eight USB interfaces from \e usb0 to \e usb7 and eight PCI interfaces from
+ \e pci0 to \e pci7.
\note Only the USB and PCI adapters are currently supported by this backend.
diff --git a/src/serialbus/doc/src/tinycan.qdoc b/src/serialbus/doc/src/tinycan.qdoc
index 4ca4e53..6637c0d 100644
--- a/src/serialbus/doc/src/tinycan.qdoc
+++ b/src/serialbus/doc/src/tinycan.qdoc
@@ -53,8 +53,9 @@
device->connectDevice();
\endcode
- Where \e channela is the active CAN interface name. The TinyCAN backend
- provides two interfaces, \e channela and \e channelb.
+ Where \e can0.0 is the active CAN interface name. TinyCAN provides the
+ interfaces \e can0.0 and \e can0.1, which maps to INDEX_CAN_KANAL_A resp.
+ INDEX_CAN_KANAL_B in the TinyCAN backend.
\note Only the USB adapters are currently supported by this backend.
diff --git a/src/serialbus/doc/src/vectorcan.qdoc b/src/serialbus/doc/src/vectorcan.qdoc
index 8125c5a..f34d0f2 100644
--- a/src/serialbus/doc/src/vectorcan.qdoc
+++ b/src/serialbus/doc/src/vectorcan.qdoc
@@ -49,15 +49,16 @@
\code
QCanBusDevice *device = QCanBus::instance()->createDevice(
- QStringLiteral("vectorcan"), QStringLiteral("channel0"));
+ QStringLiteral("vectorcan"), QStringLiteral("can0"));
device->connectDevice();
\endcode
- Where \e channel0 is the active CAN channel name. The VectorCAN backend provides
- 64 channels from \e channel0 to \e channel63. Some of these channels can be virtual,
- and therefore can be used without actual CAN hardware. To find out the virtual
- channels, the program "Vector Hardware Config" (vcanconf.exe) can be used,
- which is included in Vector's driver package.
+ Where \e can0 is the active CAN channel name. The VectorCAN backend provides
+ 64 channels (defined by XL_CONFIG_MAX_CHANNELS in the Vector API) from \e can0
+ to \e can63. Some of these channels can be virtual, and therefore can be used
+ without actual CAN hardware. To find out the virtual channels, the program
+ "Vector Hardware Config" (vcanconf.exe) can be used, which is included in
+ Vector's driver package.
The device is now open for writing and reading CAN frames: