serial

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = slog.Default()

Logger is the default logger for the serial package

Functions

func FindPorts

func FindPorts() []string

FindPorts will find the available serial ports on the system

Types

type Dummy

type Dummy struct {
	Outputters []outputters.Outputter
}

Dummy is a dummy serial port This just logs the output to the logger

func (*Dummy) Configured

func (s *Dummy) Configured() bool

Configured will return true if the serial port is configured

func (*Dummy) SendPositions

func (s *Dummy) SendPositions(c <-chan xplane.Position) error

SendPositions will send the positions from the channel to the serial port

func (*Dummy) SetBaud

func (s *Dummy) SetBaud(baud int)

SetBaud will set the baud rate

func (*Dummy) SetPort

func (s *Dummy) SetPort(port string)

SetPort will set the serial port

type Sender

type Sender interface {
	// SendPositions will send the positions from the channel wherever the Sender sends them, and send feedback to the feedback channel
	SendPositions(c <-chan xplane.Position, feedback chan<- string) error
	// Configured will return true if the serial port is configured
	Configured() bool
	// SetPort will set the serial port
	SetPort(string)
	// SetBaud will set the baud rate
	SetBaud(int)
}

Sender is the interface for sending positions to a serial port

type Serial

type Serial struct {
	Outputters []outputters.Outputter
	// contains filtered or unexported fields
}

Serial is an object that will send positions to a serial port

func NewSerial

func NewSerial(outputters []outputters.Outputter) *Serial

NewSerial returns a new Serial

func (*Serial) Configured

func (s *Serial) Configured() bool

Configured will return true if the serial port is configured

func (*Serial) Mode

func (s *Serial) Mode() serial.Mode

Mode will return the current mode

func (*Serial) SendPositions

func (s *Serial) SendPositions(c <-chan xplane.Position, feedback chan<- string) error

SendPositions will send the positions from the channel to the serial port

func (*Serial) SetBaud

func (s *Serial) SetBaud(baud int)

SetBaud will set the baud rate

func (*Serial) SetDataBits

func (s *Serial) SetDataBits(dataBits int)

SetDataBits will set the data bits

func (*Serial) SetParity

func (s *Serial) SetParity(parity serial.Parity)

SetParity will set the parity

func (*Serial) SetPort

func (s *Serial) SetPort(port string)

SetPort will set the serial port

func (*Serial) SetStopBits

func (s *Serial) SetStopBits(stopBits serial.StopBits)

SetStopBits will set the stop bits

Jump to

Keyboard shortcuts

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