modbus

package
v0.0.0-...-e6e1b3f Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const WriteSingleRegister = 6 // modbus.FuncCodeWriteSingleRegister

WriteSingleRegister 16-bit wise write access

Variables

This section is empty.

Functions

func IsRS485

func IsRS485(model string) bool

IsRS485 determines if model is a known MBMD rs485 device model

func NewDevice

func NewDevice(model string, subdevice int, isRS485 bool) (device meters.Device, err error)

NewDevice creates physical modbus device from config

func ParseOperation

func ParseOperation(dev meters.Device, measurement string, op *Operation) (err error)

ParseOperation parses an MBMD measurement or SunsSpec point definition into a modbus operation

func ParsePoint

func ParsePoint(selector string) (model int, block int, point string, err error)

ParsePoint parses sunspec point from string

func RS485FindDeviceOp

func RS485FindDeviceOp(device *rs485.RS485, measurement meters.Measurement) (op rs485.Operation, err error)

RS485FindDeviceOp checks is RS485 device supports operation

func ReadingName

func ReadingName(val string) string

ReadingName formats MBMD reading names

func RegisterOperation

func RegisterOperation(r Register) (rs485.Operation, error)

RegisterOperation creates a read operation from a register definition

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection decorates a meters.Connection with transparent slave id and error handling

func NewConnection

func NewConnection(uri, device, comset string, baudrate int, rtu bool, slaveID uint8) (*Connection, error)

NewConnection creates physical modbus device from config

func (*Connection) Delay

func (mb *Connection) Delay(delay time.Duration)

Delay sets delay so use between subsequent modbus operations

func (*Connection) Logger

func (mb *Connection) Logger(logger meters.Logger)

Logger sets logger implementation

func (*Connection) MaskWriteRegister

func (mb *Connection) MaskWriteRegister(address, andMask, orMask uint16) (results []byte, err error)

MaskWriteRegister wraps the underlying implementation

func (*Connection) ReadCoils

func (mb *Connection) ReadCoils(address, quantity uint16) ([]byte, error)

ReadCoils wraps the underlying implementation

func (*Connection) ReadDiscreteInputs

func (mb *Connection) ReadDiscreteInputs(address, quantity uint16) (results []byte, err error)

ReadDiscreteInputs wraps the underlying implementation

func (*Connection) ReadFIFOQueue

func (mb *Connection) ReadFIFOQueue(address uint16) (results []byte, err error)

ReadFIFOQueue wraps the underlying implementation

func (*Connection) ReadHoldingRegisters

func (mb *Connection) ReadHoldingRegisters(address, quantity uint16) ([]byte, error)

ReadHoldingRegisters wraps the underlying implementation

func (*Connection) ReadInputRegisters

func (mb *Connection) ReadInputRegisters(address, quantity uint16) ([]byte, error)

ReadInputRegisters wraps the underlying implementation

func (*Connection) ReadWriteMultipleRegisters

func (mb *Connection) ReadWriteMultipleRegisters(readAddress, readQuantity, writeAddress, writeQuantity uint16, value []byte) (results []byte, err error)

ReadWriteMultipleRegisters wraps the underlying implementation

func (*Connection) Timeout

func (mb *Connection) Timeout(timeout time.Duration)

Timeout sets the connection timeout (not idle timeout)

func (*Connection) WriteMultipleCoils

func (mb *Connection) WriteMultipleCoils(address, quantity uint16, value []byte) (results []byte, err error)

WriteMultipleCoils wraps the underlying implementation

func (*Connection) WriteMultipleRegisters

func (mb *Connection) WriteMultipleRegisters(address, quantity uint16, value []byte) ([]byte, error)

WriteMultipleRegisters wraps the underlying implementation

func (*Connection) WriteSingleCoil

func (mb *Connection) WriteSingleCoil(address, quantity uint16) ([]byte, error)

WriteSingleCoil wraps the underlying implementation

func (*Connection) WriteSingleRegister

func (mb *Connection) WriteSingleRegister(address, value uint16) ([]byte, error)

WriteSingleRegister wraps the underlying implementation

type Operation

type Operation struct {
	MBMD    rs485.Operation
	SunSpec SunSpecOperation
}

Operation is a register-based or sunspec modbus operation

type Register

type Register struct {
	Address uint16 // Length  uint16
	Type    string
	Decode  string
}

Register contains the ModBus register configuration

type Settings

type Settings struct {
	ID                  uint8
	SubDevice           int
	URI, Device, Comset string
	Baudrate            int
	RTU                 *bool // indicates RTU over TCP if true
}

Settings contains the ModBus settings

type SunSpecOperation

type SunSpecOperation struct {
	Model, Block int
	Point        string
}

SunSpecOperation is a sunspec modbus operation

Jump to

Keyboard shortcuts

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