Documentation ¶
Index ¶
- Constants
- func Lock()
- func Unlock()
- type Connection
- func (c *Connection) Addr() string
- func (c *Connection) Clone(slaveID uint8) *Connection
- func (c *Connection) ConnectDelay(delay time.Duration)
- func (c *Connection) Delay(delay time.Duration)
- func (c *Connection) Logger(logger meters.Logger)
- func (c *Connection) MaskWriteRegister(address, andMask, orMask uint16) (results []byte, err error)
- func (l Connection) Printf(format string, v ...interface{})
- func (c *Connection) ReadCoils(address, quantity uint16) ([]byte, error)
- func (c *Connection) ReadDiscreteInputs(address, quantity uint16) (results []byte, err error)
- func (c *Connection) ReadFIFOQueue(address uint16) (results []byte, err error)
- func (c *Connection) ReadHoldingRegisters(address, quantity uint16) ([]byte, error)
- func (c *Connection) ReadInputRegisters(address, quantity uint16) ([]byte, error)
- func (c *Connection) ReadWriteMultipleRegisters(readAddress, readQuantity, writeAddress, writeQuantity uint16, value []byte) (results []byte, err error)
- func (c *Connection) Timeout(timeout time.Duration)
- func (l Connection) WithLogger(logger modbus.Logger, fun func() ([]byte, error)) ([]byte, error)
- func (c *Connection) WriteMultipleCoils(address, quantity uint16, value []byte) (results []byte, err error)
- func (c *Connection) WriteMultipleRegisters(address, quantity uint16, value []byte) ([]byte, error)
- func (c *Connection) WriteSingleCoil(address, value uint16) ([]byte, error)
- func (c *Connection) WriteSingleRegister(address, value uint16) ([]byte, error)
- type Protocol
- type Register
- func (r Register) DecodeFunc() (func([]byte) float64, error)
- func (r Register) EncodeFunc() (func(float64) ([]byte, error), error)
- func (r Register) Error() error
- func (r Register) FuncCode() (uint8, error)
- func (r Register) Length() (uint16, error)
- func (r Register) Operation() (RegisterOperation, error)
- type RegisterOperation
- type Settings
- type SunSpecOperation
- type TcpSettings
Constants ¶
const ( Tcp Protocol = iota Rtu Ascii Udp CoilOn uint16 = 0xFF00 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Connection ¶
type Connection struct { meters.Connection // contains filtered or unexported fields }
Connection is a logical modbus connection per slave ID sharing a physical connection
func NewConnection ¶
func NewConnection(uri, device, comset string, baudrate int, proto Protocol, slaveID uint8) (*Connection, error)
NewConnection creates physical modbus device from config
func (*Connection) Addr ¶
func (c *Connection) Addr() string
func (*Connection) Clone ¶
func (c *Connection) Clone(slaveID uint8) *Connection
func (*Connection) ConnectDelay ¶
func (c *Connection) ConnectDelay(delay time.Duration)
TODO resolve conflicts
func (*Connection) Delay ¶
func (c *Connection) Delay(delay time.Duration)
func (*Connection) Logger ¶
func (c *Connection) Logger(logger meters.Logger)
func (*Connection) MaskWriteRegister ¶
func (c *Connection) MaskWriteRegister(address, andMask, orMask uint16) (results []byte, err error)
func (Connection) Printf ¶
func (l Connection) Printf(format string, v ...interface{})
Printf implements modbus.Logger interface. Must always be called while being wrapped in WithLogger, hence the lock is held.
func (*Connection) ReadCoils ¶
func (c *Connection) ReadCoils(address, quantity uint16) ([]byte, error)
func (*Connection) ReadDiscreteInputs ¶
func (c *Connection) ReadDiscreteInputs(address, quantity uint16) (results []byte, err error)
func (*Connection) ReadFIFOQueue ¶
func (c *Connection) ReadFIFOQueue(address uint16) (results []byte, err error)
func (*Connection) ReadHoldingRegisters ¶
func (c *Connection) ReadHoldingRegisters(address, quantity uint16) ([]byte, error)
func (*Connection) ReadInputRegisters ¶
func (c *Connection) ReadInputRegisters(address, quantity uint16) ([]byte, error)
func (*Connection) ReadWriteMultipleRegisters ¶
func (c *Connection) ReadWriteMultipleRegisters(readAddress, readQuantity, writeAddress, writeQuantity uint16, value []byte) (results []byte, err error)
func (*Connection) Timeout ¶
func (c *Connection) Timeout(timeout time.Duration)
TODO resolve conflicts
func (Connection) WithLogger ¶
func (*Connection) WriteMultipleCoils ¶
func (c *Connection) WriteMultipleCoils(address, quantity uint16, value []byte) (results []byte, err error)
func (*Connection) WriteMultipleRegisters ¶
func (c *Connection) WriteMultipleRegisters(address, quantity uint16, value []byte) ([]byte, error)
func (*Connection) WriteSingleCoil ¶
func (c *Connection) WriteSingleCoil(address, value uint16) ([]byte, error)
func (*Connection) WriteSingleRegister ¶
func (c *Connection) WriteSingleRegister(address, value uint16) ([]byte, error)
type Register ¶
type Register struct { Address uint16 // Length uint16 Type string Decode string // TODO deprecated, use Encoding Encoding string BitMask string }
Register contains the ModBus register configuration
func (Register) Operation ¶
func (r Register) Operation() (RegisterOperation, error)
Operation creates a modbus operation from a register definition
type RegisterOperation ¶
type Settings ¶
type Settings struct { ID uint8 SubDevice int URI, Device, Comset string Baudrate int UDP bool RTU *bool // indicates RTU over TCP if true }
Settings contains the ModBus settings
type SunSpecOperation ¶
SunSpecOperation is a sunspec modbus operation
func ParsePoint ¶
func ParsePoint(selector string) (SunSpecOperation, error)
ParsePoint parses sunspec point from string
type TcpSettings ¶
Settings contains the ModBus TCP settings RTU field is included for compatibility with modbus.tpl which renders rtu: false for TCP TODO remove RTU field (https://github.com/evcc-io/evcc/issues/3360)