simpleproto

package
v2.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: GPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

type Line struct {
	Token     *tokens.Token
	Removable *bool
}

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.

func ParseLine

func ParseLine(line, readerID string) (Line, bool)

ParseLine parses one line of the protocol. It reports false for blank lines and for lines that do not carry a token, which are not errors: the stream may contain chatter the reader does not understand.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL