driver

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModbusClient

type ModbusClient struct {
	Client  modbus.Client
	Handler interface{}
	Config  interface{}
	// contains filtered or unexported fields
}

ModbusClient is the structure for modbus client.

func NewClient

func NewClient(config interface{}) (*ModbusClient, error)

NewClient allocate and return a modbus client. Client type includes TCP and RTU.

func (*ModbusClient) Get

func (c *ModbusClient) Get(registerType string, addr uint16, quantity uint16) (results []byte, err error)

Get get register.

func (*ModbusClient) GetStatus

func (c *ModbusClient) GetStatus() string

GetStatus get device status. Now we could only get the connection status.

func (*ModbusClient) Set

func (c *ModbusClient) Set(registerType string, addr uint16, value uint16) (results []byte, err error)

Set set register.

type ModbusRTU

type ModbusRTU struct {
	SlaveID      byte
	SerialName   string
	BaudRate     int
	DataBits     int
	StopBits     int
	Parity       string
	RS485Enabled bool
	Timeout      time.Duration
}

ModbusRTU is the configurations of modbus RTU.

type ModbusTCP

type ModbusTCP struct {
	SlaveID  byte
	DeviceIP string
	TCPPort  string
	Timeout  time.Duration
}

ModbusTCP is the configurations of modbus TCP.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL