Documentation
¶
Overview ¶
Package serial provides a portable interface to access serial ports.
Index ¶
- Variables
- func ListPortNames() ([]string, error)
- type Config
- type FlowControl
- type Parity
- type Port
- func (p *Port) BaudRate() (int, error)
- func (p *Port) Close() error
- func (p *Port) DataBits() (int, error)
- func (p *Port) FlowControl() FlowControl
- func (p *Port) Flush() error
- func (p *Port) Parity() (Parity, error)
- func (p *Port) Read(buf []byte) (int, error)
- func (p *Port) SetBaudRate(baudrate int) error
- func (p *Port) SetDataBits(databits int) error
- func (p *Port) SetFlowControl(flowcontrol FlowControl) error
- func (p *Port) SetParity(parity Parity) error
- func (p *Port) SetStopBits(stopbits StopBits) error
- func (p *Port) SetTimeout(timeout_ms_firstbyte, timeout_ms_interbyte int) error
- func (p *Port) StopBits() (StopBits, error)
- func (p *Port) Write(buf []byte) (int, error)
- type StopBits
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTimeout = errors.New("I/O operation timeout") ErrInvalid = errors.New("invalid") ErrInvalidName = errors.New("invalid name") ErrInvalidParam = errors.New("invalid parameter") ErrNotSupported = errors.New("not supported by OS or implementation") ErrUnexpected = errors.New("unexpected response") )
Functions ¶
func ListPortNames ¶
Types ¶
type Config ¶
type Config struct { BaudRate int // Baud rate. (Default: 9600) DataBits int // Number of data bits. Range: 5-8. (Default: 8) Parity Parity // Parity checking. StopBits StopBits // Number of stop bits. FlowControl FlowControl // Flow control mechanism. }
type FlowControl ¶
type FlowControl int
const ( FlowControlNone FlowControl = 0 // No flow control. (Default) FlowControlXonXoff FlowControl = 1 << iota // Software (XON/XOFF) flow control. FlowControlRtsCts // Hardware (RTS/CTS) flow control. FlowControlDtrDsr // Hardware (DTR/DSR) flow control. )
Flow control used during transfering.
If no flow control is used, buffers on both sides of the connection are assumed to be large enough.
Software (XON/XOFF) flow control uses XON and XOFF character to perform flow control.
Hardware (RTS/CTS) flow control uses RTS output and CTS input signal to perform flow control.
Hardware (DTR/DSR) flow control uses DTR output and DSR input signal to perform flow control.
type Port ¶
func (*Port) FlowControl ¶
func (p *Port) FlowControl() FlowControl
func (*Port) Flush ¶
Flush discards data written to the port but not transmitted, or data received but not read.
func (*Port) SetBaudRate ¶
func (*Port) SetDataBits ¶
func (*Port) SetFlowControl ¶
func (p *Port) SetFlowControl(flowcontrol FlowControl) error
func (*Port) SetStopBits ¶
func (*Port) SetTimeout ¶
Click to show internal directories.
Click to hide internal directories.