package modbus type Endianness int32 const ( BigEndian Endianness = 0 LittleEndian Endianness = 1 ) // 在modbus协议中,主机正常是客户端 type MasterClient interface { // 启动 Start() error // 停止 Stop() error // 关闭,销毁 Close() error // 是否连接 IsConnected() bool // 设置从机id SetUnitId(id uint8) error // 设置字节序 SetEndianness(endianness Endianness) error // 读线圈,位操作,功能码为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) // 读多个保持寄存器,字节数组 ReadHoldingRegisterBytes(addr uint16, quantity uint16) ([]byte, error) // 读一个保持寄存器 ReadHoldingRegisterUint16(addr uint16) (uint16, error) // 读输入寄存器,字节操作,功能码为0x04 ReadInputRegister(addr uint16, quantity uint16) ([]uint16, error) // 读多个输入寄存器,字节数组 ReadInputRegisterBytes(addr uint16, quantity uint16) ([]byte, 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 // 写多个保持寄存器,字节数组 WriteRegisterBytes(addr uint16, values []byte) error }