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.
nnet/connection/rtu.go

40 lines
731 B
Go

package connection
import (
"github.com/goburrow/serial"
"net"
"time"
)
// RTUConn rtu connection wrapper
type RTUConn struct {
serial.Port
config *serial.Config
}
// NewRTUConn 新建 RTUConn
func NewRTUConn(port serial.Port, cfg *serial.Config) net.Conn {
return &RTUConn{Port: port, config: cfg}
}
func (c *RTUConn) LocalAddr() net.Addr {
cfg := c.config
return NewRTUAddr(cfg.Address, cfg.BaudRate, cfg.DataBits, cfg.StopBits, cfg.Parity)
}
func (c *RTUConn) RemoteAddr() net.Addr {
return c.LocalAddr()
}
func (c *RTUConn) SetDeadline(_ time.Time) error {
return nil
}
func (c *RTUConn) SetReadDeadline(_ time.Time) error {
return nil
}
func (c *RTUConn) SetWriteDeadline(_ time.Time) error {
return nil
}