diff options
author | Andre Hartmann <aha_1980@gmx.de> | 2017-10-26 22:28:50 +0200 |
---|---|---|
committer | André Hartmann <aha_1980@gmx.de> | 2018-01-12 06:56:45 +0000 |
commit | 44a449ff8f0b7cdb71e67385e1bd9a098209045e (patch) | |
tree | 3860802a1afff79563970166f4739a6b187f265e /src/plugins/canbus/peakcan/peakcanbackend.cpp | |
parent | df9735fc1660dd40730693f08f6e046a5e01deb3 (diff) |
Add more info to QCanBusDeviceInfo
Added description, serial number and channel for SocketCAN, PeakCAN,
SystecCAN, and VectorCAN plugins. For now, not all plugins do support
all kind of information:
SocketCAN: description and channel
PeakCAN: description and channel (Windows PCANBasic >= 4.2.0)
SystecCAN: description, serial number, and channel
VectorCAN: description, serial number, and channel
[ChangeLog][QCanBusDeviceInfo] Added description, serial number
and channel to QCanBusDeviceInfo, as far as supported by the
various plugins.
Change-Id: Ib2292e06065eb91848f682ebf69a4cc968f4d4ba
Reviewed-by: Rolf Eike Beer <eb@emlix.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/plugins/canbus/peakcan/peakcanbackend.cpp')
-rw-r--r-- | src/plugins/canbus/peakcan/peakcanbackend.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp index 5460951..7e6fe43 100644 --- a/src/plugins/canbus/peakcan/peakcanbackend.cpp +++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp @@ -120,14 +120,30 @@ QList<QCanBusDeviceInfo> PeakCanBackend::interfaces() QList<QCanBusDeviceInfo> result; for (int i = 0; pcanChannels[i].index != PCAN_NONEBUS; ++i) { - int value; - const TPCANStatus stat = ::CAN_GetValue(pcanChannels[i].index, PCAN_CHANNEL_CONDITION, + int value = 0; + const TPCANHandle index = pcanChannels[i].index; + const TPCANStatus stat = ::CAN_GetValue(index, PCAN_CHANNEL_CONDITION, &value, sizeof(value)); if ((stat == PCAN_ERROR_OK) && (value & PCAN_CHANNEL_AVAILABLE)) { - const TPCANStatus fdStat = ::CAN_GetValue(pcanChannels[i].index, PCAN_CHANNEL_FEATURES, + const TPCANStatus fdStat = ::CAN_GetValue(index, PCAN_CHANNEL_FEATURES, &value, sizeof(value)); const bool isFd = (fdStat == PCAN_ERROR_OK) && (value & FEATURE_FD_CAPABLE); - result.append(createDeviceInfo(QLatin1String(pcanChannels[i].name), false, isFd)); + + char description[256] = {0}; + const TPCANStatus descStat = ::CAN_GetValue(index, PCAN_HARDWARE_NAME, + description, sizeof(description)); + if (descStat != PCAN_ERROR_OK) + description[0] = 0; + + int channel = 0; + const TPCANStatus chnStat = ::CAN_GetValue(index, PCAN_CONTROLLER_NUMBER, + &channel, sizeof(channel)); + if (chnStat != PCAN_ERROR_OK) + channel = 0; + + result.append(std::move(createDeviceInfo(QLatin1String(pcanChannels[i].name), + QString(), QLatin1String(description), + channel, false, isFd))); } } |