Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Comms
  5. pw_cobs
  6. pw::cobs::Streamer Class Reference
Loading...
Searching...
No Matches
pw::cobs::Streamer Class Reference

Overview

Incrementally COBS-encodes a frame of arbitrary length through a small output buffer (StreamerBuffer<> or a caller-provided ByteSpan).

Feed payload chunks into Write(). Whenever Write() returns a non-empty unconsumed remainder, transmit Flush() before calling Write() again. Once all payload chunks have been written, transmit Finish() to complete the frame:

for (pw::ConstByteSpan seg : segments) {
while (!seg.empty()) {
seg = streamer.Write(seg);
if (!seg.empty()) {
WriteToUart(streamer.Flush());
}
}
}
WriteToUart(streamer.Finish());
Definition: cobs.h:322
ConstByteSpan Write(ConstByteSpan data)
Inheritance diagram for pw::cobs::Streamer:
pw::cobs::StreamerBuffer< kSizeBytes >

Public Member Functions

constexpr Streamer (ByteSpan buffer, bool emit_leading_delimiter=false)
 
constexpr void Reset (bool emit_leading_delimiter=false)
 
ConstByteSpan Write (ConstByteSpan data)
 
ByteSpan Flush ()
 
ByteSpan Finish ()
 
constexpr ConstByteSpan AbortSequence () const
 

Static Public Attributes

static constexpr size_t kMinBufferSize = MaxEncodedSize(kMaxRunLength) + 1
 
static constexpr std::array< std::byte, 2 > kAbortSequence
 

Friends

Result< ByteSpan > Encode (ConstByteSpan input, ByteSpan output)
 

The documentation for this class was generated from the following file: