diff options
author | Andre Hartmann <aha_1980@gmx.de> | 2016-08-12 22:20:00 +0200 |
---|---|---|
committer | André Hartmann <aha_1980@gmx.de> | 2016-08-26 08:57:54 +0000 |
commit | c8305c87f805dbeb6cb5b09ac086a7651ef8c857 (patch) | |
tree | 7a5f0a3791191c7dae0b48ea8e9fa165d6afa1ce /src/plugins/canbus/peakcan | |
parent | c732ad3b469bfba8b714772c455aeb70706a1a8e (diff) |
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 <denis.shienkov@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/plugins/canbus/peakcan')
-rw-r--r-- | src/plugins/canbus/peakcan/peakcanbackend.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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<const char *>(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); |