You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
673 B
Go
36 lines
673 B
Go
package conn
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
)
|
|
|
|
const SerialNetwork = "serial"
|
|
|
|
type SerialAddr struct {
|
|
Address string
|
|
BaudRate int
|
|
DataBits int
|
|
StopBits int
|
|
Parity string
|
|
}
|
|
|
|
func NewSerialAddr(addr string, rate int, dataBits int, stopBits int, parity string) net.Addr {
|
|
return &SerialAddr{
|
|
Address: addr,
|
|
BaudRate: rate,
|
|
DataBits: dataBits,
|
|
StopBits: stopBits,
|
|
Parity: parity,
|
|
}
|
|
}
|
|
|
|
func (r *SerialAddr) Network() string {
|
|
return SerialNetwork
|
|
}
|
|
|
|
// String form of address (for example, "/dev/ttyS0|19200|8|1|N", "com1|19200|8|1|N")
|
|
func (r *SerialAddr) String() string {
|
|
return fmt.Sprintf("%s|%d|%d|%d", r.Address, r.BaudRate, r.DataBits, r.StopBits)
|
|
}
|