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

Function fluxEngineToApplesauceWriteData

lib/usb/applesauceusb.cc:48–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48static Bytes fluxEngineToApplesauceWriteData(const Bytes& fldata)
49{
50 Fluxmap fluxmap(fldata);
51 FluxmapReader fmr(fluxmap);
52 Bytes asdata;
53 ByteWriter bw(asdata);
54
55 while (!fmr.eof())
56 {
57 unsigned ticks;
58 if (!fmr.findEvent(F_BIT_PULSE, ticks))
59 break;
60
61 uint32_t applesauceTicks = (double)ticks * NS_PER_TICK;
62 while (applesauceTicks >= 0xffff)
63 {
64 bw.write_le16(0xffff);
65 applesauceTicks -= 0xffff;
66 }
67 if (applesauceTicks == 0)
68 error("bad data!");
69 bw.write_le16(applesauceTicks);
70 }
71
72 bw.write_le16(0);
73 return asdata;
74}
75
76class ApplesauceException : public ErrorException
77{

Callers 1

writeMethod · 0.85

Calls 3

errorFunction · 0.85
findEventMethod · 0.80
eofMethod · 0.45

Tested by

no test coverage detected