Documentation ¶
Index ¶
- Constants
- type Baud
- type Connection
- func (connection *Connection) Close() error
- func (connection *Connection) Flush() error
- func (connection *Connection) Open(timeout uint8) error
- func (connection *Connection) Query(request []byte, delimiter byte) ([]byte, error)
- func (connection *Connection) Read(delimiter byte) ([]byte, error)
- func (connection *Connection) ReadToBuffer(size int) ([]byte, error)
- func (connection *Connection) Save(path string) error
- func (connection *Connection) String() string
- func (connection *Connection) Write(b []byte) (int, error)
- type DataBit
- type Parity
- type StopBit
Constants ¶
const ( // Baud4800 defines a transmission rate of 4800 symbols per second. Baud4800 = 4800 // Baud9600 defines a transmission rate of 9600 symbols per second. Baud9600 = 9600 // Baud19200 defines a transmission rate of 19200 symbols per second. Baud19200 = 19200 // Baud38400 defines a transmission rate of 38400 symbols per second. Baud38400 = 38400 // Baud57600 defines a transmission rate of 57600 symbols per second. Baud57600 = 57600 // Baud115200 defines a transmission rate of 115200 symbols per second. Baud115200 = 115200 )
const ( // DataBit5 stands for a character length of five bits. DataBit5 = DataBit(iota + 5) // DataBit6 stands for a character length of six bits. DataBit6 // DataBit7 stands for a character length of seven bits. DataBit7 // DataBit8 stands for a character length of eight bits. DataBit8 )
const ( // StopBit1 represents a single bit being send as stopbit. StopBit1 = StopBit(iota + 1) // StopBit2 represents two bits being send as stopbit. StopBit2 )
const ( // ParityNone indicates that no error detection is being used. ParityNone = Parity(iota) // ParityEven indicates that a bit is added to even out the bit count. ParityEven // ParityOdd indicates that a bit is added to provide an odd bit count. ParityOdd )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Baud ¶
type Baud uint32
Baud is the unit for the symbol rate. It describes the number of symbols transmitted per second.
type Connection ¶
type Connection struct { Port string Baud Baud DataBit DataBit StopBit StopBit Parity Parity // contains filtered or unexported fields }
Connection represents a serial connection with all parameters.
func InitConnection ¶
func InitConnection(port string, baudrate Baud, databit DataBit, stopbit StopBit, parity Parity) (*Connection, error)
InitConnection provides a connection with the given parameters.
func LoadConnection ¶
func LoadConnection(path string) (*Connection, error)
LoadConnection provides a connection with the parameters being loaded from a json file.
func (*Connection) Flush ¶
func (connection *Connection) Flush() error
Flush the connection, which causes untransmitted or not read data to be discarded.
func (*Connection) Open ¶
func (connection *Connection) Open(timeout uint8) error
Open a connection with a read timeout.
func (*Connection) Query ¶
func (connection *Connection) Query(request []byte, delimiter byte) ([]byte, error)
Query combines Write(), Read() and Flush() to improve usability.
func (*Connection) Read ¶
func (connection *Connection) Read(delimiter byte) ([]byte, error)
Read from an open connection until the delimiter is reached.
func (*Connection) ReadToBuffer ¶
func (connection *Connection) ReadToBuffer(size int) ([]byte, error)
ReadToBuffer reads from an open connection into a []byte buffer with the given size.
func (*Connection) Save ¶
func (connection *Connection) Save(path string) error
Save a connection to a json file.
func (*Connection) String ¶
func (connection *Connection) String() string