Documentation
¶
Index ¶
- Constants
- Variables
- func Sign(data []byte) byte
- type Client
- func (c *Client) FlipGroup(i ...byte) error
- func (c *Client) FlipGroupNil(i ...byte) error
- func (c *Client) FlipOne(i byte) error
- func (c *Client) FlipOneNil(i byte) error
- func (c *Client) OffAll() error
- func (c *Client) OffGroup(i ...byte) error
- func (c *Client) OffGroupNil(i ...byte) error
- func (c *Client) OffOne(i byte) error
- func (c *Client) OffOneNil(i byte) error
- func (c *Client) OffPoint(i byte, t int) error
- func (c *Client) OffPointNil(i byte, t int) error
- func (c *Client) OnAll() error
- func (c *Client) OnGroup(i ...byte) error
- func (c *Client) OnGroupNil(i ...byte) error
- func (c *Client) OnOne(i byte) error
- func (c *Client) OnOneNil(i byte) error
- func (c *Client) OnPoint(i byte, t int) error
- func (c *Client) OnPointNil(i byte, t int) error
- func (c *Client) Status() ([]byte, error)
- func (c *Client) StatusOne(i byte) (byte, error)
- type ClientHandler
- func (mb *ClientHandler) Decode(adu []byte) (pdu *ProtocolDataUnit, err error)
- func (mb *ClientHandler) Encode(pdu *ProtocolDataUnit) (adu []byte, err error)
- func (mb *ClientHandler) Send(aduRequest []byte) (aduResponse []byte, err error)
- func (mb *ClientHandler) Verify(aduRequest []byte, aduResponse []byte) (err error)
- type Packager
- type ProtocolDataUnit
- type Transporter
Constants ¶
View Source
const ( DefaultBranchesLength = 0x8 MaxBranchesLength = 32 DataLength = 0x8 RequestHeader = 0x55 //发送帧数据头 ResponseHeader = 0x22 //接受帧数据头 //功能码 RequestReadStatus = 0x10 //读取状态 RequestOffOne = 0x11 //断开某路 RequestOnOne = 0x12 //吸合某路 RequestFlipOne = 0x20 //翻转某路 RequestRunCMD = 0x13 //命令执行 RequestOffGroup = 0x14 //组断开 RequestOnGroup = 0x15 //组吸合 RequestFlipGroup = 0x16 //组翻转 RequestOnPoint = 0x21 //点动闭合 RequestOffPoint = 0x22 //点动断开 RequestFlipOneNil = 0x30 //翻转某路 下位机不返回数据,指0令可以连续发送 RequestOffOneNil = 0x31 //断开某路 RequestOnOneNil = 0x32 //吸合某路 RequestRunCMDNil = 0x33 //命令执行 RequestOffGroupNil = 0x34 //组断开 RequestOnGroupNil = 0x35 //组吸合 RequestFlipGroupNil = 0x36 //组翻转 RequestOnPointNil = 0x37 //点动闭合 RequestOffPointNil = 0x38 //点动断开 RequestReadAddress = 0x40 //读地址 RequestWriteAddress = 0x41 //写地址 RequestReadVariable = 0x70 //读变量 RequestWriteVariable = 0x71 //写变量 ResponseReadStatus = 0x10 //读取状态 ResponseCloseOne = 0x11 //关闭某一路 ResponseOpenOne = 0x12 //打开某一路 ResponseRunCMD = 0x13 //命令执行 ResponseCloseGroup = 0x14 //组断开 ResponseOpenGroup = 0x15 //组吸合 ResponseFlipGroup = 0x16 //组翻转 ResponseModelAddress = 0x40 //返回模块地址 ResponseReadInnerVariable = 0x70 //读内部变量 ResponseWriteInnerVariable = 0x71 //写内部变量 )
Variables ¶
Functions ¶
Types ¶
type Client ¶
Client is the interface that groups the Packager and Transporter methods.
func NewClient ¶
func NewClient(handler *ClientHandler, length byte) *Client
NewClient creates a new modbus client with given backend handler.
func NewDefaultClient ¶
func NewDefaultClient(handler *ClientHandler) *Client
type ClientHandler ¶
type ClientHandler struct {
// contains filtered or unexported fields
}
ClientHandler implements Packager and Transporter interface.
func NewDefaultHandler ¶
func NewDefaultHandler(address string, slave byte) *ClientHandler
NewDefaultHandler allocates and initializes a ClientHandler.
func NewHandler ¶
func NewHandler(address string) *ClientHandler
NewHandler allocates and initializes a RELAYClientHandler.
func (*ClientHandler) Decode ¶
func (mb *ClientHandler) Decode(adu []byte) (pdu *ProtocolDataUnit, err error)
Decode extracts PDU from RELAY frame and verify CRC.
func (*ClientHandler) Encode ¶
func (mb *ClientHandler) Encode(pdu *ProtocolDataUnit) (adu []byte, err error)
Encode encodes PDU in a RELAY frame:
Data Header : 1 byte Slave Address : 1 byte Function : 1 byte Data : 4 bytes CRC : 1 byte
type Packager ¶
type Packager interface {
Encode(pdu *ProtocolDataUnit) (adu []byte, err error)
Decode(adu []byte) (pdu *ProtocolDataUnit, err error)
Verify(aduRequest []byte, aduResponse []byte) (err error)
}
Packager specifies the communication layer.
type ProtocolDataUnit ¶
ProtocolDataUnit (PDU) is independent of underlying communication layers.
type Transporter ¶
Transporter specifies the transport layer.
Click to show internal directories.
Click to hide internal directories.