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 }