34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
|
package modbus
|
|||
|
|
|||
|
// 在modbus协议中,主机正常是客户端
|
|||
|
type MasterClient interface {
|
|||
|
// 启动
|
|||
|
Start() error
|
|||
|
// 停止
|
|||
|
Stop() error
|
|||
|
// 关闭,销毁
|
|||
|
Close() error
|
|||
|
// 是否连接
|
|||
|
IsConnected() bool
|
|||
|
// 读线圈,位操作,功能码为0x01
|
|||
|
ReadCoil(addr uint16, quantity uint16) ([]bool, error)
|
|||
|
// 读一个线圈
|
|||
|
ReadCoilBit(addr uint16) (bool, error)
|
|||
|
// 读离散输入,位操作,功能码为0x02
|
|||
|
ReadDiscreteInput(addr uint16, quantity uint16) ([]bool, error)
|
|||
|
// 读保持寄存器,字节操作,功能码为0x03
|
|||
|
ReadHoldingRegister(addr uint16, quantity uint16) ([]uint16, error)
|
|||
|
// 读一个保持寄存器
|
|||
|
ReadHoldingRegisterUint16(addr uint16) (uint16, error)
|
|||
|
// 读输入寄存器,字节操作,功能码为0x04
|
|||
|
ReadInputRegister(addr uint16, quantity uint16) ([]uint16, error)
|
|||
|
// 写单个线圈,功能码为0x05
|
|||
|
WriteCoil(addr uint16, value bool) error
|
|||
|
// 写多个线圈,功能码为0x0F
|
|||
|
WriteCoils(addr uint16, values []bool) error
|
|||
|
// 写单个保持寄存器,功能码为0x06
|
|||
|
WriteRegister(addr uint16, value uint16) error
|
|||
|
// 写多个保持寄存器,功能码为0x10
|
|||
|
WriteRegisters(addr uint16, values []uint16) error
|
|||
|
}
|