Documentation ¶
Index ¶
- Constants
- func BytesToCoils(bytes []byte) ([]bool, error)
- func BytesToRegisters(bytes []byte) ([]uint16, error)
- func CoilsToBytes(values []bool) []byte
- func CoilsToRegisters(coils []bool) []uint16
- func InjectModbusHeader(header *ModbusHeader, bytes []byte) []byte
- func RegistersToBytes(values []uint16) []byte
- func RegistersToCoils(registers []uint16) []bool
- type ModbusClient
- type ModbusHeader
Constants ¶
View Source
const ( MODBUS_HEADER_LENGTH = 7 // MODBUS_Maximum_Number_Of_Registers is maximum number of registers that can be read in one request, a modbus message is limit to 256 bytes // TODO: this should be checked when register groups are created MODBUS_MAXIMUM_NUMBER_OF_REGISTERS = 125 MODBUS_MAXIMUM_NUMBER_OF_COILS = 2000 )
View Source
const ( // 01 (0x01) Read Coils READ_COILS = 0x01 // 02 (0x02) Read Discrete Inputs READ_DISCRETE_INPUTS = 0x02 // 03 (0x03) Read Holding Registers READ_HOLDING_REGISTERS = 0x03 // 04 (0x04) Read Input Registers READ_INPUT_REGISTERS = 0x04 // 05 (0x05) Write Single Coil WRITE_SINGLE_COIL = 0x05 // 06 (0x06) Write Single Register WRITE_SINGLE_REGISTER = 0x06 // 08 (0x08) Diagnostics (Serial Line only) DIAGNOSTICS = 0x08 // 11 (0x0B) Get Comm Event Counter (Serial Line only) GET_COMM_EVENT_COUNTER = 0x0B // 15 (0x0F) Write Multiple Coils WRITE_MULTIPLE_COILS = 0x0F // 16 (0x10) Write Multiple Registers WRITE_MULTIPLE_REGISTERS = 0x10 // 17 (0x11) Report Server ID (Serial Line only) REPORT_SERVER_ID = 0x11 // 22 (0x16) Mask Write Register MASK_WRITE_REGISTERS = 0x16 // 23 (0x17) Read/Write Multiple Registers READ_WRITE_MULTIPLE_REGISTERS = 0x17 // 43 / 14 (0x2B / 0x0E) Read Device Identification READ_DEVICE_IDENTIFICATION_A = 0x0E READ_DEVICE_IDENTIFICATION_B = 0x43 )
Variables ¶
This section is empty.
Functions ¶
func BytesToCoils ¶
func BytesToRegisters ¶
func CoilsToBytes ¶
func CoilsToRegisters ¶
func InjectModbusHeader ¶
func InjectModbusHeader(header *ModbusHeader, bytes []byte) []byte
func RegistersToBytes ¶
func RegistersToCoils ¶
Types ¶
type ModbusClient ¶
type ModbusClient struct {
// contains filtered or unexported fields
}
func NewModbusClient ¶
func NewModbusClient(realClient *modbus.ModbusClient, header *ModbusHeader) *ModbusClient
type ModbusHeader ¶
type ModbusHeader struct { Slave uint8 `mapstructure:"slave"` FunctionCode uint16 `mapstructure:"functionCode"` Address uint16 `mapstructure:"address"` NumberOfCoilsOrRegisters uint16 `mapstructure:"numberOfCoilsOrRegisters"` }
func ExtractModbusHeader ¶
func ExtractModbusHeader(bytes []byte) (*ModbusHeader, []byte, error)
Click to show internal directories.
Click to hide internal directories.