network

package
v0.0.0-...-0cd537b Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Send an instruction to all servos
	BroadcastIdent byte = 0xFE // 254
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Network

type Network struct {
	Serial io.ReadWriteCloser

	// The time to wait for a single read to complete before giving up.
	Timeout time.Duration

	// Optional Logger (which only implements Printf) to log network traffic. If
	// nil (the default), nothing is logged.
	Logger iface.Logger
}

func New

func New(serial io.ReadWriteCloser) *Network

func (*Network) Flush

func (nw *Network) Flush()

func (*Network) Logf

func (nw *Network) Logf(format string, v ...interface{})

Logf writes a message to the network logger, unless it's nil.

func (*Network) Read

func (nw *Network) Read(p []byte) (n int, err error)

read receives the next n bytes from the network, blocking if they're not immediately available. Returns a slice containing the bytes read. If the network timeout is reached, returns the bytes read so far (which might be none) and an error.

func (*Network) Write

func (nw *Network) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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