Documentation
¶
Index ¶
- Constants
- type Port
- type SerialPort
- func (sp *SerialPort) Available() int
- func (sp *SerialPort) Close() error
- func (sp *SerialPort) EOL(c byte)
- func (sp *SerialPort) Open(name string, baud int, timeout ...time.Duration) error
- func (sp *SerialPort) Print(str string) error
- func (sp *SerialPort) Printf(format string, args ...interface{}) error
- func (sp *SerialPort) Println(str string) error
- func (sp *SerialPort) Read() (byte, error)
- func (sp *SerialPort) ReadLine() (string, error)
- func (sp *SerialPort) SendFile(filepath string) error
- func (sp *SerialPort) WaitForRegexTimeout(exp string, timeout time.Duration) (string, error)
- func (sp *SerialPort) Write(data []byte) (n int, err error)
Constants ¶
const EOL_DEFAULT byte = '\n'
End of line character (AKA EOL), newline character (ASCII 10, CR, '\n'). is used by default.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Port ¶
type Port struct {
// contains filtered or unexported fields
}
type SerialPort ¶
type SerialPort struct { Verbose bool // contains filtered or unexported fields }
func New ¶
func New() *SerialPort
func (*SerialPort) Available ¶
func (sp *SerialPort) Available() int
Available return the total number of available unread bytes on the serial buffer.
func (*SerialPort) Close ¶
func (sp *SerialPort) Close() error
This method close the current Serial Port.
func (*SerialPort) EOL ¶
func (sp *SerialPort) EOL(c byte)
Change end of line character (AKA EOL), newline character (ASCII 10, LF, '\n') is used by default.
func (*SerialPort) Print ¶
func (sp *SerialPort) Print(str string) error
This method prints data trough the serial port.
func (*SerialPort) Printf ¶
func (sp *SerialPort) Printf(format string, args ...interface{}) error
Printf formats according to a format specifier and print data trough the serial port.
func (*SerialPort) Println ¶
func (sp *SerialPort) Println(str string) error
Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, CR, '\r') and a newline character (ASCII 10, LF, '\n').
func (*SerialPort) Read ¶
func (sp *SerialPort) Read() (byte, error)
Read the first byte of the serial buffer.
func (*SerialPort) ReadLine ¶
func (sp *SerialPort) ReadLine() (string, error)
Read first available line from serial port buffer.
Line is delimited by the EOL character, newline character (ASCII 10, LF, '\n') is used by default.
The text returned from ReadLine does not include the line end ("\r\n" or '\n').
func (*SerialPort) SendFile ¶
func (sp *SerialPort) SendFile(filepath string) error
This method send a binary file trough the serial port. If EnableLog is active then this method will log file related data.
func (*SerialPort) WaitForRegexTimeout ¶
Wait for a defined regular expression for a defined amount of time.