29 void reset(std::size_t frameBytes);
32 void write(std::span<const uint8_t> frame);
35 std::span<const uint8_t>
read();
38 static constexpr uint8_t kFresh = 0x04;
39 static constexpr uint8_t kIndexMask = 0x03;
41 std::array<std::vector<uint8_t>, 3> buffers_;
42 uint8_t writeIndex_ = 0;
43 uint8_t readIndex_ = 1;
44 std::atomic<uint8_t> middle_{2};
52 void reset(std::size_t frameBytes, std::size_t capacity);
55 bool push(std::span<const uint8_t> frame);
59 bool pop(std::span<uint8_t> frame);
65 std::size_t
size()
const;
68 std::vector<uint8_t> storage_;
69 std::size_t frameBytes_ = 0;
70 std::size_t capacity_ = 0;
71 std::atomic<std::size_t> head_{0};
72 std::atomic<std::size_t> tail_{0};
87 void reset(std::size_t frameBytes);
90 std::vector<uint8_t>
add(std::span<const uint8_t> reply);
96 std::size_t frameBytes_ = 0;
97 std::vector<uint8_t> partial_;
98 uint64_t framingLosses_ = 0;
Definition spoe_process_data.h:85
std::vector< uint8_t > add(std::span< const uint8_t > reply)
Adds the input bytes of one reply. Returns the whole frames they complete, joined.
Definition spoe_process_data.cc:89
void reset(std::size_t frameBytes)
Definition spoe_process_data.cc:83
uint64_t framingLosses() const
How many times stale bytes were dropped to restore the framing.
Definition spoe_process_data.h:93
Definition spoe_process_data.h:26
void reset(std::size_t frameBytes)
Sizes every buffer and clears them. Not safe while the writer or the reader runs.
Definition spoe_process_data.cc:8
void write(std::span< const uint8_t > frame)
Writer side. frame must hold the size given to reset.
Definition spoe_process_data.cc:17
std::span< const uint8_t > read()
Reader side. Returns the newest frame, or the previous one again when nothing newer arrived.
Definition spoe_process_data.cc:25
Definition spoe_connection.cc:15
constexpr std::size_t kInputPopLimit
pop_from_pdo_fifo_buffer in the firmware returns at most this many bytes of inputs at once.
Definition spoe_process_data.h:21