Documentation
¶
Overview ¶
Package simpleproto implements the "simple serial" line protocol shared by every reader that streams newline-delimited SCAN lines, whatever the transport underneath (serial port, Bluetooth LE, ...).
Index ¶
Constants ¶
const ( // DefaultMaxLineLength bounds one line of input. Anything longer is // discarded up to the next newline so a misbehaving device cannot grow // memory without bound. DefaultMaxLineLength = 4096 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Line ¶
Line is one parsed protocol line. Removable is set only when the line carried a removable= argument, so the caller can keep its previous value otherwise.
type LineSplitter ¶
type LineSplitter struct {
// contains filtered or unexported fields
}
LineSplitter turns an arbitrary byte stream into complete lines. It keeps a partial line between calls and drops any line longer than the limit.
func NewLineSplitter ¶
func NewLineSplitter(maxLine int) *LineSplitter
NewLineSplitter returns a splitter with the given line limit; a limit of zero or less uses DefaultMaxLineLength.
func (*LineSplitter) Feed ¶
func (s *LineSplitter) Feed(data []byte) []string
Feed appends data to the stream and returns every line completed by it, without their trailing newline. Carriage returns are left for ParseLine.