diff options
author | Andre Hartmann <aha_1980@gmx.de> | 2021-11-15 18:40:49 +0100 |
---|---|---|
committer | Andre Hartmann <aha_1980@gmx.de> | 2022-11-18 20:56:19 +0100 |
commit | b0eede2dc58df1805a0745ff72e9dee51a08e9e5 (patch) | |
tree | f106b9e25312ba70e16ae7dfe9b2f8ac8e563f8e | |
parent | 72b799474468920f8f598c424b6c69a1a5c4fd01 (diff) |
PeakCAN: Make compatible to latest MacCAN library
From the changelog [1] and private mail requests I got aware,
that the MacCAN library changed all "Long" data types back to
32 bit to be compatible to the PeakCAN library, as the 64 bit
data types were used by accident.
This partly reverts 187999b06ee355d482374a3ea4b417d6d8185983
[1] https://www.uv-software.de/files/downloads/MacCAN/PCANUSB/Library/
OS_X_Library_for_PCANUSB_v0.10.readme
[ChangeLog][PeakCAN] The PeakCAN plugin is now compatible to
the MacCAN library 0.9 or higher. On the other hand, older
MacCAN libraries are no longer supported.
Change-Id: Ibcd4a015ee2b0172c52ae68e4f6dc3a468ed86d0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/plugins/canbus/peakcan/peakcan_symbols_p.h | 22 | ||||
-rw-r--r-- | src/plugins/canbus/peakcan/peakcanbackend.cpp | 6 | ||||
-rw-r--r-- | src/serialbus/doc/src/peakcan.qdoc | 2 |
3 files changed, 11 insertions, 19 deletions
diff --git a/src/plugins/canbus/peakcan/peakcan_symbols_p.h b/src/plugins/canbus/peakcan/peakcan_symbols_p.h index d48a02e..bf786a3 100644 --- a/src/plugins/canbus/peakcan/peakcan_symbols_p.h +++ b/src/plugins/canbus/peakcan/peakcan_symbols_p.h @@ -241,14 +241,8 @@ #define PCAN_TYPE_DNG_SJA_EPP 0x06U // PCAN-Dongle EPP SJA1000 // Type definitions -#ifdef Q_OS_MACOS -#define TPCANLong quint64 -#else -#define TPCANLong quint32 -#endif -#define TPCANLongToFrameID(a) static_cast<QCanBusFrame::FrameId>(a) #define TPCANHandle quint16 // Represents a PCAN hardware channel handle -#define TPCANStatus TPCANLong // Represents a PCAN status/error code +#define TPCANStatus quint32 // Represents a PCAN status/error code #define TPCANParameter quint8 // Represents a PCAN parameter to be read or set #define TPCANDevice quint8 // Represents a PCAN device #define TPCANMessageType quint8 // Represents the type of a PCAN message @@ -261,7 +255,7 @@ // Represents a PCAN message typedef struct tagTPCANMsg { - TPCANLong ID; // 11/29-bit message identifier + quint32 ID; // 11/29-bit message identifier TPCANMessageType MSGTYPE; // Type of the message quint8 LEN; // Data Length Code of the message (0..8) quint8 DATA[8]; // Data of the message (DATA[0]..DATA[7]) @@ -271,7 +265,7 @@ typedef struct tagTPCANMsg // Total Microseconds = micros + 1000 * millis + 0xFFFFFFFF * 1000 * millis_overflow typedef struct tagTPCANTimestamp { - TPCANLong millis; // Base-value: milliseconds: 0.. 2^32-1 + quint32 millis; // Base-value: milliseconds: 0.. 2^32-1 quint16 millis_overflow; // Roll-arounds of millis quint16 micros; // Microseconds: 0..999 } TPCANTimestamp; @@ -279,7 +273,7 @@ typedef struct tagTPCANTimestamp // Represents a PCAN message from a FD capable hardware typedef struct tagTPCANMsgFD { - TPCANLong ID; // 11/29-bit message identifier + quint32 ID; // 11/29-bit message identifier TPCANMessageType MSGTYPE; // Type of the message quint8 DLC; // Data Length Code of the message (0..15) quint8 DATA[64]; // Data of the message (DATA[0]..DATA[63]) @@ -306,7 +300,7 @@ typedef struct tagTPCANChannelInformation if (!symbolName) \ return false; -GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_Initialize, TPCANHandle, TPCANBaudrate, TPCANType, TPCANLong, quint16) +GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_Initialize, TPCANHandle, TPCANBaudrate, TPCANType, quint32, quint16) GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_InitializeFD, TPCANHandle, TPCANBitrateFD) GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_Uninitialize, TPCANHandle) GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_Reset, TPCANHandle) @@ -315,9 +309,9 @@ GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_Read, TPCANHandle, TPCANMsg *, TPCANTi GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_ReadFD, TPCANHandle, TPCANMsgFD *, TPCANTimestampFD *) GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_Write, TPCANHandle, TPCANMsg *) GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_WriteFD, TPCANHandle, TPCANMsgFD *) -GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_FilterMessages, TPCANHandle, TPCANLong, TPCANLong, TPCANMode) -GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_GetValue, TPCANHandle, TPCANParameter, void *, TPCANLong) -GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_SetValue, TPCANHandle, TPCANParameter, void *, TPCANLong) +GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_FilterMessages, TPCANHandle, quint32, quint32, TPCANMode) +GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_GetValue, TPCANHandle, TPCANParameter, void *, quint32) +GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_SetValue, TPCANHandle, TPCANParameter, void *, quint32) GENERATE_SYMBOL_VARIABLE(TPCANStatus, CAN_GetErrorText, TPCANStatus, quint16, char *) inline bool resolvePeakCanSymbols(QLibrary *pcanLibrary) diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp index 0761ebd..6d8ce94 100644 --- a/src/plugins/canbus/peakcan/peakcanbackend.cpp +++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp @@ -705,8 +705,7 @@ void PeakCanBackendPrivate::startRead() continue; const int size = dlcToSize(static_cast<CanFrameDlc>(message.DLC)); - QCanBusFrame frame(TPCANLongToFrameID(message.ID), - QByteArray(reinterpret_cast<const char *>(message.DATA), size)); + QCanBusFrame frame(message.ID, QByteArray(reinterpret_cast<const char *>(message.DATA), size)); frame.setTimeStamp(QCanBusFrame::TimeStamp::fromMicroSeconds(static_cast<qint64>(timestamp))); frame.setExtendedFrameFormat(message.MSGTYPE & PCAN_MESSAGE_EXTENDED); frame.setFrameType((message.MSGTYPE & PCAN_MESSAGE_RTR) @@ -733,8 +732,7 @@ void PeakCanBackendPrivate::startRead() continue; const int size = static_cast<int>(message.LEN); - QCanBusFrame frame(TPCANLongToFrameID(message.ID), - QByteArray(reinterpret_cast<const char *>(message.DATA), size)); + QCanBusFrame frame(message.ID, QByteArray(reinterpret_cast<const char *>(message.DATA), size)); const quint64 millis = timestamp.millis + Q_UINT64_C(0x100000000) * timestamp.millis_overflow; const quint64 micros = Q_UINT64_C(1000) * millis + timestamp.micros; frame.setTimeStamp(QCanBusFrame::TimeStamp::fromMicroSeconds(static_cast<qint64>(micros))); diff --git a/src/serialbus/doc/src/peakcan.qdoc b/src/serialbus/doc/src/peakcan.qdoc index 43204d4..7aa9561 100644 --- a/src/serialbus/doc/src/peakcan.qdoc +++ b/src/serialbus/doc/src/peakcan.qdoc @@ -12,7 +12,7 @@ This plugin requires the PCAN device drivers and the PCAN-Basic library version 4.4.0 or higher on Windows (pcanbasic.dll) resp. 4.0.0 on Linux (libpcanbasic.so). On macOS the plugin requires the PCBUSB library from - \l{http://www.mac-can.com}{UV Software}. + \l{http://www.mac-can.com}{UV Software}, version is 0.9 or higher. \note QCanBusDeviceInfo::alias() is only supported on Windows and with PCAN-Basic 4.4.0 or higher. |