Documentation ¶
Index ¶
- Constants
- func IsRS485(model string) bool
- func NewDevice(model string, subdevice int) (device meters.Device, err error)
- func ParseOperation(dev meters.Device, measurement string, op *Operation) (err error)
- func ParsePoint(selector string) (model, block int, point string, err error)
- func RS485FindDeviceOp(device *rs485.RS485, measurement meters.Measurement) (op rs485.Operation, err error)
- func RTUFloat64ToFloat64(b []byte) float64
- func RegisterOperation(r Register) (rs485.Operation, error)
- type Connection
- func (mb *Connection) ConnectDelay(delay time.Duration)
- func (mb *Connection) Delay(delay time.Duration)
- func (mb *Connection) Logger(logger meters.Logger)
- func (mb *Connection) MaskWriteRegister(address, andMask, orMask uint16) (results []byte, err error)
- func (mb *Connection) MaskWriteRegisterWithSlave(slaveID uint8, address, andMask, orMask uint16) (results []byte, err error)
- func (mb *Connection) ReadCoils(address, quantity uint16) ([]byte, error)
- func (mb *Connection) ReadCoilsWithSlave(slaveID uint8, address, quantity uint16) ([]byte, error)
- func (mb *Connection) ReadDiscreteInputs(address, quantity uint16) (results []byte, err error)
- func (mb *Connection) ReadDiscreteInputsWithSlave(slaveID uint8, address, quantity uint16) (results []byte, err error)
- func (mb *Connection) ReadFIFOQueue(address uint16) (results []byte, err error)
- func (mb *Connection) ReadFIFOQueueWithSlave(slaveID uint8, address uint16) (results []byte, err error)
- func (mb *Connection) ReadHoldingRegisters(address, quantity uint16) ([]byte, error)
- func (mb *Connection) ReadHoldingRegistersWithSlave(slaveID uint8, address, quantity uint16) ([]byte, error)
- func (mb *Connection) ReadInputRegisters(address, quantity uint16) ([]byte, error)
- func (mb *Connection) ReadInputRegistersWithSlave(slaveID uint8, address, quantity uint16) ([]byte, error)
- func (mb *Connection) ReadWriteMultipleRegisters(readAddress, readQuantity, writeAddress, writeQuantity uint16, value []byte) (results []byte, err error)
- func (mb *Connection) ReadWriteMultipleRegistersWithSlave(slaveID uint8, readAddress, readQuantity, writeAddress, writeQuantity uint16, ...) (results []byte, err error)
- func (mb *Connection) Timeout(timeout time.Duration)
- func (mb *Connection) WriteMultipleCoils(address, quantity uint16, value []byte) (results []byte, err error)
- func (mb *Connection) WriteMultipleCoilsWithSlave(slaveID uint8, address, quantity uint16, value []byte) (results []byte, err error)
- func (mb *Connection) WriteMultipleRegisters(address, quantity uint16, value []byte) ([]byte, error)
- func (mb *Connection) WriteMultipleRegistersWithSlave(slaveID uint8, address, quantity uint16, value []byte) ([]byte, error)
- func (mb *Connection) WriteSingleCoil(address, quantity uint16) ([]byte, error)
- func (mb *Connection) WriteSingleCoilWithSlave(slaveID uint8, address, value uint16) ([]byte, error)
- func (mb *Connection) WriteSingleRegister(address, value uint16) ([]byte, error)
- func (mb *Connection) WriteSingleRegisterWithSlave(slaveID uint8, address, value uint16) ([]byte, error)
- type Operation
- type Protocol
- type Register
- type Settings
- type SunSpecOperation
- type TcpSettings
Constants ¶
const ( Tcp Protocol = iota Rtu Ascii CoilOn uint16 = 0xFF00 )
Variables ¶
This section is empty.
Functions ¶
func ParseOperation ¶
ParseOperation parses an MBMD measurement or SunsSpec point definition into a modbus operation
func ParsePoint ¶
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 RTUFloat64ToFloat64 ¶
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, proto Protocol, slaveID uint8) (*Connection, error)
NewConnection creates physical modbus device from config
func (*Connection) ConnectDelay ¶
func (mb *Connection) ConnectDelay(delay time.Duration)
ConnectDelay sets the initial delay after connecting before starting communication
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)
func (*Connection) MaskWriteRegisterWithSlave ¶
func (mb *Connection) MaskWriteRegisterWithSlave(slaveID uint8, 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)
func (*Connection) ReadCoilsWithSlave ¶
func (mb *Connection) ReadCoilsWithSlave(slaveID uint8, address, quantity uint16) ([]byte, error)
ReadCoils wraps the underlying implementation
func (*Connection) ReadDiscreteInputs ¶
func (mb *Connection) ReadDiscreteInputs(address, quantity uint16) (results []byte, err error)
func (*Connection) ReadDiscreteInputsWithSlave ¶
func (mb *Connection) ReadDiscreteInputsWithSlave(slaveID uint8, 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)
func (*Connection) ReadFIFOQueueWithSlave ¶
func (mb *Connection) ReadFIFOQueueWithSlave(slaveID uint8, address uint16) (results []byte, err error)
ReadFIFOQueue wraps the underlying implementation
func (*Connection) ReadHoldingRegisters ¶
func (mb *Connection) ReadHoldingRegisters(address, quantity uint16) ([]byte, error)
func (*Connection) ReadHoldingRegistersWithSlave ¶
func (mb *Connection) ReadHoldingRegistersWithSlave(slaveID uint8, address, quantity uint16) ([]byte, error)
ReadHoldingRegisters wraps the underlying implementation
func (*Connection) ReadInputRegisters ¶
func (mb *Connection) ReadInputRegisters(address, quantity uint16) ([]byte, error)
func (*Connection) ReadInputRegistersWithSlave ¶
func (mb *Connection) ReadInputRegistersWithSlave(slaveID uint8, 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)
func (*Connection) ReadWriteMultipleRegistersWithSlave ¶
func (mb *Connection) ReadWriteMultipleRegistersWithSlave(slaveID uint8, 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)
func (*Connection) WriteMultipleCoilsWithSlave ¶
func (mb *Connection) WriteMultipleCoilsWithSlave(slaveID uint8, 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)
func (*Connection) WriteMultipleRegistersWithSlave ¶
func (mb *Connection) WriteMultipleRegistersWithSlave(slaveID uint8, address, quantity uint16, value []byte) ([]byte, error)
WriteMultipleRegisters wraps the underlying implementation
func (*Connection) WriteSingleCoil ¶
func (mb *Connection) WriteSingleCoil(address, quantity uint16) ([]byte, error)
func (*Connection) WriteSingleCoilWithSlave ¶
func (mb *Connection) WriteSingleCoilWithSlave(slaveID uint8, address, value uint16) ([]byte, error)
WriteSingleCoil wraps the underlying implementation
func (*Connection) WriteSingleRegister ¶
func (mb *Connection) WriteSingleRegister(address, value uint16) ([]byte, error)
func (*Connection) WriteSingleRegisterWithSlave ¶
func (mb *Connection) WriteSingleRegisterWithSlave(slaveID uint8, 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 Protocol ¶
type Protocol int
func ProtocolFromRTU ¶
ProtocolFromRTU identifies the wire format from the RTU setting
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 ¶
SunSpecOperation is a sunspec modbus operation
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/danielimada/evcc/issues/3360)