Documentation ¶
Index ¶
- type OpenOptions
- type ParityMode
- type Port
- func (p *Port) Close() error
- func (p *Port) DTR() (bool, error)
- func (p *Port) InWaiting() (int, error)
- func (p *Port) RTS() (bool, error)
- func (p *Port) Read(b []byte) (int, error)
- func (p *Port) ResetInputBuffer() error
- func (p *Port) ResetOutputBuffer() error
- func (p *Port) SetDTR(state bool) error
- func (p *Port) SetDeadline(t time.Time) error
- func (p *Port) SetRTS(state bool) error
- func (p *Port) Write(b []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenOptions ¶
type OpenOptions struct { // The name of the port, e.g. "/dev/tty.usbserial-A8008HlV". PortName string // The baud rate for the port. BaudRate uint // The number of data bits per frame. Legal values are 5, 6, 7, and 8. DataBits uint // The number of stop bits per frame. Legal values are 1 and 2. StopBits uint // The type of parity bits to use for the connection. Currently parity errors // are simply ignored; that is, bytes are delivered to the user no matter // whether they were received with a parity error or not. ParityMode ParityMode // Canonical mode determines whether the port will use line endings to determine // end of messages, or (in the case of non-canonical) just treat the data as a // binary stream, without considering line endings or processing data at all. CanonicalMode bool InterCharacterTimeout uint MinimumReadSize uint }
OpenOptions is the struct containing all of the options necessary for opening a serial port.
type ParityMode ¶
type ParityMode int
ParityMode provides a type for three different parity modes of a serial port
const ( Parity_None ParityMode = 0 Parity_Odd ParityMode = 1 Parity_Even ParityMode = 2 )
type Port ¶
type Port struct { DeviceName string // contains filtered or unexported fields }
Port represents a File opened with serial port options
func NewPort ¶
func NewPort(f *os.File, fd uintptr, options OpenOptions) *Port
NewPort creates and returns a new Port struct using the given os.File pointer
func Open ¶
func Open(options OpenOptions) (*Port, error)
Open creates an io.ReadWriteCloser based on the supplied options struct.
func (*Port) DTR ¶
DTR returns the status of the Data Terminal Ready (DTR) line of the port. See: https://en.wikipedia.org/wiki/Data_Terminal_Ready
func (*Port) InWaiting ¶
InWaiting returns the number of waiting bytes in the Port's internal buffer.
func (*Port) Read ¶
Read reads up to len(b) bytes from the Port's file. It will return the number of bytes read and an error, if any
func (*Port) ResetInputBuffer ¶
func (*Port) ResetOutputBuffer ¶
func (*Port) SetDTR ¶
SetDTR sets the status of the DTR line of a port to the given state, allowing manual control of the Data Terminal Ready modem line.
func (*Port) SetDeadline ¶
SetDeadline sets the read and write deadlines for the Port's file. Deadlines are absolute timeouts after which any read or write calls will fail with a timeout error.