From f22af5d595749041e353b9248208ca93355e901c Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Sun, 31 Jul 2016 09:40:57 +0200 Subject: CAN: Better error messages when loading dynamic libraries Make use of the detailed (and localized) error messages that QLibrary already provides. Example: Cannot load library pcanbasic: \ (pcanbasic: cannot open shared object file: No such file or directory) Change-Id: I3f4fd42d1872a00f2c4ecc6172ccc17995c7888e Reviewed-by: Denis Shienkov Reviewed-by: Alex Blasche --- src/plugins/canbus/peakcan/peakcanbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/canbus/peakcan/peakcanbackend.cpp') diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp index 7e954c2..3b06ede 100644 --- a/src/plugins/canbus/peakcan/peakcanbackend.cpp +++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp @@ -65,7 +65,7 @@ bool PeakCanBackend::canCreate(QString *errorReason) #else static bool symbolsResolved = resolveSymbols(pcanLibrary()); if (!symbolsResolved) { - *errorReason = tr("The PCAN runtime library is not found"); + *errorReason = pcanLibrary()->errorString(); return false; } return true; -- cgit v1.2.3 From c732ad3b469bfba8b714772c455aeb70706a1a8e Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Fri, 12 Aug 2016 21:20:18 +0200 Subject: PeakCAN: Do not set an error when receive buffer is empty The function PeakCanBackendPrivate::startRead() reads all incoming frames until the receive buffer becomes empty. When the receive buffer is empty, the function should exit silently. Otherwise, an error should be set up. The previous code simply used the wrong constant to allow this valid case. Change-Id: I325e25682d7749950d936bf715a160a2beff7d06 Reviewed-by: Denis Shienkov Reviewed-by: Alex Blasche --- src/plugins/canbus/peakcan/peakcanbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/canbus/peakcan/peakcanbackend.cpp') diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp index 3b06ede..c62fc1b 100644 --- a/src/plugins/canbus/peakcan/peakcanbackend.cpp +++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp @@ -434,7 +434,7 @@ void PeakCanBackendPrivate::canReadNotification() const TPCANStatus st = ::CAN_Read(channelIndex, &message, ×tamp); if (st != PCAN_ERROR_OK) { - if (st != PCAN_ERROR_XMTFULL) + if (st != PCAN_ERROR_QRCVEMPTY) q->setError(systemErrorString(st), QCanBusDevice::ReadError); break; } -- cgit v1.2.3 From c8305c87f805dbeb6cb5b09ac086a7651ef8c857 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Fri, 12 Aug 2016 22:20:00 +0200 Subject: PeakCAN: Fix timestamps The TimeStamp object gets seconds and microseconds, so the milliseconds that are smaller than one second have to be transformed to microseconds. Further, add the millis_overflow to extend the range of the timestamps. Change-Id: I0b0b531a7d1f2816d24a0683a2156cb19a3f655e Reviewed-by: Denis Shienkov Reviewed-by: Alex Blasche --- src/plugins/canbus/peakcan/peakcanbackend.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins/canbus/peakcan/peakcanbackend.cpp') diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp index c62fc1b..c245462 100644 --- a/src/plugins/canbus/peakcan/peakcanbackend.cpp +++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp @@ -440,7 +440,9 @@ void PeakCanBackendPrivate::canReadNotification() } QCanBusFrame frame(message.ID, QByteArray(reinterpret_cast(message.DATA), int(message.LEN))); - frame.setTimeStamp(QCanBusFrame::TimeStamp(timestamp.millis / 1000, timestamp.micros)); + const quint64 millis = timestamp.millis + 0xFFFFFFFFU * timestamp.millis_overflow; + const quint64 micros = 1000 * (millis % 1000) + timestamp.micros; + frame.setTimeStamp(QCanBusFrame::TimeStamp(millis / 1000, micros)); frame.setExtendedFrameFormat(message.MSGTYPE & PCAN_MESSAGE_EXTENDED); frame.setFrameType((message.MSGTYPE & PCAN_MESSAGE_RTR) ? QCanBusFrame::RemoteRequestFrame : QCanBusFrame::DataFrame); -- cgit v1.2.3 From bb75d3d4a4e4b7b1efb383d755e05e5f3623572c Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Fri, 16 Sep 2016 06:11:23 +0200 Subject: PeakCAN: Avoid overflows on timestamp calculation While the formula itself is correct, there is a chance of getting wrong values due to limited data types. Found after a hint from H.Mueller in the Peak Forum: http://www.peak-system.com/forum/viewtopic.php?f=41&t=1238 Change-Id: I0f3036c5d694bee7cc8d3fd54e206545b71344b7 Reviewed-by: Denis Shienkov Reviewed-by: Marc Mutz Reviewed-by: Alex Blasche --- src/plugins/canbus/peakcan/peakcanbackend.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/canbus/peakcan/peakcanbackend.cpp') diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp index c245462..9598003 100644 --- a/src/plugins/canbus/peakcan/peakcanbackend.cpp +++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp @@ -440,8 +440,8 @@ void PeakCanBackendPrivate::canReadNotification() } QCanBusFrame frame(message.ID, QByteArray(reinterpret_cast(message.DATA), int(message.LEN))); - const quint64 millis = timestamp.millis + 0xFFFFFFFFU * timestamp.millis_overflow; - const quint64 micros = 1000 * (millis % 1000) + timestamp.micros; + const quint64 millis = timestamp.millis + Q_UINT64_C(0xFFFFFFFF) * timestamp.millis_overflow; + const quint64 micros = Q_UINT64_C(1000) * (millis % 1000) + timestamp.micros; frame.setTimeStamp(QCanBusFrame::TimeStamp(millis / 1000, micros)); frame.setExtendedFrameFormat(message.MSGTYPE & PCAN_MESSAGE_EXTENDED); frame.setFrameType((message.MSGTYPE & PCAN_MESSAGE_RTR) ? QCanBusFrame::RemoteRequestFrame : QCanBusFrame::DataFrame); -- cgit v1.2.3