Documentation ¶
Overview ¶
Package serial provides support for serial connections.
Index ¶
- func Open(name string) (io.ReadWriteCloser, error)
- func OpenWithOptions(name string, baudRate int) (io.ReadWriteCloser, error)
- func RunCommands(ctx context.Context, socket io.ReadWriteCloser, cmds []Command) error
- func RunDiagnostics(ctx context.Context, socket io.ReadWriteCloser) error
- type Command
- type SerialSocket
- type Server
- type ServerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
func Open(name string) (io.ReadWriteCloser, error)
Open opens a new serial port using defaults.
func OpenWithOptions ¶
func OpenWithOptions(name string, baudRate int) (io.ReadWriteCloser, error)
OpenWithOptions opens a new serial port with the given name and baud rate.
func RunCommands ¶
RunCommands writes the provided commands to the serial socket.
func RunDiagnostics ¶
func RunDiagnostics(ctx context.Context, socket io.ReadWriteCloser) error
RunDiagnostics runs a series of diagnostic commands over serial.
Types ¶
type Command ¶
Command contains the command to run over serial and the expected duration to wait for the command to complete.
type SerialSocket ¶
func NewSocket ¶
func NewSocket(ctx context.Context, socketPath string) (*SerialSocket, error)
NewSocket opens a connection on the provided `socketPath`.
func NewSocketWithIOTimeout ¶
func NewSocketWithIOTimeout(ctx context.Context, socketPath string, ioTimeout time.Duration) (*SerialSocket, error)
NewSocketWithIOTimeout opens a connection on the provided `socketPath` with the provided socket IO timeout for reads and writes.
func (*SerialSocket) SetIOTimeout ¶
func (s *SerialSocket) SetIOTimeout(timeout time.Duration)
SetIOTimeout sets the timeout for a single Read() or Write().
type Server ¶
type Server struct { ServerOptions // contains filtered or unexported fields }
Server proxies all i/o to/from a serial port via another io.ReadWriter. Start and Stop may be pairwise called any number of times.
func NewServer ¶
func NewServer(serial io.ReadWriteCloser, opts ServerOptions) *Server
NewServer returns a new server that lives atop the given 'serial' port.
type ServerOptions ¶
type ServerOptions struct { // AuxiliaryOutput is an optional path to a serial output sink. AuxiliaryOutput string // StartAtEnd instructs each connection to begin streaming at the end // of the aux file. StartAtEnd bool }
ServerOptions provide options that parametrize the server's behavior.