Skip to content
Permalink
Browse files

fix peak timestamp problems

  • Loading branch information...
HubertD committed May 17, 2016
1 parent 804b7e1 commit c69941ac50c02776c55927c0aa69850a0859a304
Showing with 20 additions and 3 deletions.
  1. +17 −2 src/driver/PeakCanDriver/PeakCanInterface.cpp
  2. +3 −1 src/driver/PeakCanDriver/PeakCanInterface.h
@@ -9,9 +9,15 @@

PeakCanInterface::PeakCanInterface(PeakCanDriver *driver, uint32_t handle)
: CanInterface(driver),
_handle(handle)
_handle(handle),
_hostTimestampStart(0),
_peakTimestampStart(0)
{
_timestampOffset = QDateTime::currentMSecsSinceEpoch() - GetTickCount();

LARGE_INTEGER tps;
QueryPerformanceFrequency(&tps);
_perfTicksPerSecond = tps.QuadPart;

_autoResetEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

_config.autoRestart = true;
@@ -215,6 +221,15 @@ bool PeakCanInterface::readMessage(CanMessage &msg, unsigned int timeout_ms)
ts += 0x100000000 * (uint64_t)timestamp.millis_overflow;
ts *= 1000;
ts += timestamp.micros;

if (_peakTimestampStart==0) {
_hostTimestampStart = 1000 * QDateTime::currentMSecsSinceEpoch();
_peakTimestampStart = ts;
}

ts -=_peakTimestampStart;
ts += _hostTimestampStart;

msg.setTimestamp(ts/1000000, ts % 1000000);

return true;
@@ -38,7 +38,9 @@ class PeakCanInterface : public CanInterface

private:
uint32_t _handle;
int64_t _timestampOffset;
uint64_t _perfTicksPerSecond;
uint64_t _hostTimestampStart;
uint64_t _peakTimestampStart;
void *_autoResetEvent;

struct {

0 comments on commit c69941a

Please sign in to comment.
You can’t perform that action at this time.