From d02e6b593676b1ff41bfb98e38bc103eb4f958c2 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 7 Mar 2019 00:22:43 +0100 Subject: [PATCH] Update cwftoflux to handle index information from CWF files. --- lib/fluxmap.cc | 6 ++++++ lib/fluxmap.h | 1 + tools/cwftoflux.cc | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/fluxmap.cc b/lib/fluxmap.cc index eaf549e2..2b3e9c0f 100644 --- a/lib/fluxmap.cc +++ b/lib/fluxmap.cc @@ -53,6 +53,12 @@ Fluxmap& Fluxmap::appendInterval(uint32_t ticks) return *this; } +Fluxmap& Fluxmap::appendIndex() +{ + appendByte(0x81); + return *this; +} + void Fluxmap::precompensate(int threshold_ticks, int amount_ticks) { uint8_t junk = 0xff; diff --git a/lib/fluxmap.h b/lib/fluxmap.h index eb5de779..584d7d9c 100644 --- a/lib/fluxmap.h +++ b/lib/fluxmap.h @@ -20,6 +20,7 @@ public: } Fluxmap& appendInterval(uint32_t ticks); + Fluxmap& appendIndex(); Fluxmap& appendBytes(const Bytes& bytes); Fluxmap& appendBytes(const uint8_t* ptr, size_t len); diff --git a/tools/cwftoflux.cc b/tools/cwftoflux.cc index 3b074a67..8d60d068 100644 --- a/tools/cwftoflux.cc +++ b/tools/cwftoflux.cc @@ -88,9 +88,12 @@ static void read_track() Fluxmap fluxmap; uint32_t pending = 0; + bool oldindex = true; for (unsigned cursor = 0; cursor < length; cursor++) { - uint32_t b = inputdata[cursor] & 0x7f; + uint32_t b = inputdata[cursor]; + bool index = !!(b & 0x80); + b &= 0x7f; if (b == 0x7f) { pending += 0x7f; @@ -101,6 +104,10 @@ static void read_track() double interval_us = b * (1e6/clockRate); fluxmap.appendInterval(interval_us / US_PER_TICK); + + if (index && !oldindex) + fluxmap.appendIndex(); + oldindex = index; } std::cout << fmt::format(" {} ms in {} output bytes\n",