Documentation ¶
Overview ¶
Package serial is Embedded focused serial port package that allows you to read, write and configure the serial port.
This project draws inspiration from the github.com/tarm/serial package, github.com/johnlauer/goserial package and go.bug.st/serial package
Initially this project aims to provide API and compatibility for Linux. As time progresses other architectures would be added.
This library is Context based and performs read write asynchronously.
By default this package uses 8 bits (byte) data format for exchange.
Note: Baud rates are defined as OS specifics
Currently Following Features are supported:
- All types of BAUD rates
- Flow Control - Hardware, Software (XON/XOFF)
- RTS , DTR control
- CTS , DSR, RING read back
- Parity Control - Odd, Even, Mark, Space
- Stop Bit Control - 1 bit and 2 bits
- Hardware to Software Signal Inversion for all Signals RTS, CTS, DTR, DSR
- Sending Break from TX line X. ... More on the way ...
Index ¶
Constants ¶
const ( // StopBits1 defines a single Stop bit sent after every data unit block StopBits1 byte = iota // StopBits15 defines a 1 and 1/2 Stop bits sent after every data unit block StopBits15 byte = iota // 1.5 Stop Bits // StopBits2 defines a 2 Stop bits sent after every data unit block StopBits2 byte = iota )
Specific Stop bits type
const ( ParityNone byte = iota ParityOdd byte = iota ParityEven byte = iota ParityMark byte = iota ParitySpace byte = iota )
Parity Constants
const ( // FlowNone for no flow control to be used for Serial port FlowNone byte = iota // FlowHardware for CTS / RTS base Hardware flow control to be used for Serial port FlowHardware byte = iota // FlowSoft for Software flow control to be used for Serial port FlowSoft byte = iota // XON / XOFF based - Not Supported )
const DataSize byte = 8
DataSize defines the unit data size in bits used for Serial communication
Variables ¶
var ( // ErrNotImplemented - ErrNotImplemented = fmt.Errorf("not implemented yet") // ErrPortNotInitialized - ErrPortNotInitialized = fmt.Errorf("port not initialized or closed") // ErrNotOpen - ErrNotOpen = fmt.Errorf("port not open") // ErrAlreadyOpen - ErrAlreadyOpen = fmt.Errorf("port is already open") // ErrAccessDenied - ErrAccessDenied = fmt.Errorf("access denied") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Name string Baud int ReadTimeout time.Duration // Blocks the Read operation for a specified time Parity byte StopBits byte Flow byte SignalInvert bool // Option to invert the RTS/CTS/DTR/DSR Read outs }
Config stores the complete configuration of a Serial Port
type Port ¶
type Port interface { io.ReadWriteCloser Rts(en bool) (err error) Cts() (en bool, err error) Dtr(en bool) (err error) Dsr() (en bool, err error) Ring() (en bool, err error) SetBaud(baud int) (err error) SignalInvert(en bool) (err error) SendBreak(en bool) (err error) }
Port Type for Multi platform implementation of Serial port functionality