| 4 | #include "lib/external/catweasel.h" |
| 5 | |
| 6 | std::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 | } |
no test coverage detected