MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / decodeCatweaselData

Function decodeCatweaselData

lib/external/catweasel.cc:6–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "lib/external/catweasel.h"
5
6std::unique_ptr<Fluxmap> decodeCatweaselData(
7 const Bytes& bytes, nanoseconds_t clock)
8{
9 std::unique_ptr<Fluxmap> fluxmap(new Fluxmap);
10 uint32_t pending = 0;
11 bool oldindex = true;
12 const uint8_t* ptr = bytes.begin();
13 while (ptr != bytes.end())
14 {
15 uint32_t b = *ptr++;
16 bool index = !!(b & 0x80);
17 b &= 0x7f;
18 if (b == 0x7f)
19 {
20 pending += 0x7f;
21 continue;
22 }
23 b += pending;
24 pending = 0;
25
26 double interval_ns = b * clock;
27 fluxmap->appendInterval(interval_ns / NS_PER_TICK);
28 fluxmap->appendPulse();
29
30 if (index && !oldindex)
31 fluxmap->appendIndex();
32 oldindex = index;
33 }
34
35 return fluxmap;
36}

Callers 2

readSingleFluxMethod · 0.85
nextMethod · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected