serial

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: BSD-3-Clause Imports: 4 Imported by: 13

README

This is pure Go package for handling serial ports. Currently supports only Linux.

Package documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Serial

type Serial struct {
	// contains filtered or unexported fields
}

func Open

func Open(name string) (*Serial, error)

Defaults:

9600 8N1, soft/hard flow controll off, raw mode, vmin=1, vtime=0

func (*Serial) Close

func (s *Serial) Close() error

func (*Serial) File

func (s *Serial) File() *os.File

func (*Serial) Name

func (s *Serial) Name() string

func (*Serial) Read

func (s *Serial) Read(b []byte) (int, error)

func (*Serial) ReadByte

func (s *Serial) ReadByte() (byte, error)

func (*Serial) SetCanon

func (s *Serial) SetCanon(canon bool) error

Sets canonical/raw mode

func (*Serial) SetFlowCtrl

func (s *Serial) SetFlowCtrl(hw, soft bool) error

func (*Serial) SetParity

func (s *Serial) SetParity(parity, odd bool) error

func (*Serial) SetRawRead

func (s *Serial) SetRawRead(vmin, vtime int) error

Sets Read behavior for noncanonical mode.

vmin  - minimum number of characters for Read
vtime - timeout in deciseconds
vmin == 0 && vtime == 0 : non-blocking Read,
vmin == 0 && vtime > 0  : Read returns buffered characters or waits vtime for new charcters,
vmin > 0  && vtime > 0  : Read returns n >= vmin characters or 0 < n < vmin if vtime expires after n-th char
vmin > 0  && vtime == 0 : Read returns at least vmin characters

func (*Serial) SetSpeed

func (s *Serial) SetSpeed(boud int) error

func (*Serial) SetStopBits2

func (s *Serial) SetStopBits2(two bool) error

two == true means two stop bits, two == false means one stop bit

func (*Serial) Write

func (s *Serial) Write(b []byte) (int, error)

func (*Serial) WriteByte

func (s *Serial) WriteByte(c byte) error

func (*Serial) WriteString

func (s *Serial) WriteString(str string) (int, error)

Jump to

Keyboard shortcuts

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