Versions in this module Expand all Collapse all v1 v1.7.2 Jul 31, 2024 v1.7.1 Jul 30, 2024 Changes in this version + const BIG_ENDIAN + const HIGH_WORD_FIRST + const HOLDING_REGISTER + const INPUT_REGISTER + const LITTLE_ENDIAN + const LOW_WORD_FIRST + const PARITY_EVEN + const PARITY_NONE + const PARITY_ODD + func LoadCertPool(filePath string) (cp *x509.CertPool, err error) + type ClientConfiguration struct + DataBits uint + Logger *log.Logger + Parity uint + Speed uint + StopBits uint + TLSClientCert *tls.Certificate + TLSRootCAs *x509.CertPool + Timeout time.Duration + URL string + type CoilsRequest struct + Addr uint16 + Args []bool + ClientAddr string + ClientRole string + IsWrite bool + Quantity uint16 + UnitId uint8 + type DiscreteInputsRequest struct + Addr uint16 + ClientAddr string + ClientRole string + Quantity uint16 + UnitId uint8 + type Endianness uint + type Error string + const ErrAcknowledge + const ErrBadCRC + const ErrBadTransactionId + const ErrBadUnitId + const ErrConfigurationError + const ErrGWPathUnavailable + const ErrGWTargetFailedToRespond + const ErrIllegalDataAddress + const ErrIllegalDataValue + const ErrIllegalFunction + const ErrMemoryParityError + const ErrProtocolError + const ErrRequestTimedOut + const ErrServerDeviceBusy + const ErrServerDeviceFailure + const ErrShortFrame + const ErrUnexpectedParameters + const ErrUnknownProtocolId + func (me Error) Error() (s string) + type HoldingRegistersRequest struct + Addr uint16 + Args []uint16 + ClientAddr string + ClientRole string + IsWrite bool + Quantity uint16 + UnitId uint8 + type InputRegistersRequest struct + Addr uint16 + ClientAddr string + ClientRole string + Quantity uint16 + UnitId uint8 + type ModbusClient struct + func NewClient(conf *ClientConfiguration) (mc *ModbusClient, err error) + func (mc *ModbusClient) Close() (err error) + func (mc *ModbusClient) Open() (err error) + func (mc *ModbusClient) ReadBytes(addr uint16, quantity uint16, regType RegType) (values []byte, err error) + func (mc *ModbusClient) ReadCoil(addr uint16) (value bool, err error) + func (mc *ModbusClient) ReadCoils(addr uint16, quantity uint16) (values []bool, err error) + func (mc *ModbusClient) ReadDiscreteInput(addr uint16) (value bool, err error) + func (mc *ModbusClient) ReadDiscreteInputs(addr uint16, quantity uint16) (values []bool, err error) + func (mc *ModbusClient) ReadFloat32(addr uint16, regType RegType) (value float32, err error) + func (mc *ModbusClient) ReadFloat32s(addr uint16, quantity uint16, regType RegType) (values []float32, err error) + func (mc *ModbusClient) ReadFloat64(addr uint16, regType RegType) (value float64, err error) + func (mc *ModbusClient) ReadFloat64s(addr uint16, quantity uint16, regType RegType) (values []float64, err error) + func (mc *ModbusClient) ReadRawBytes(addr uint16, quantity uint16, regType RegType) (values []byte, err error) + func (mc *ModbusClient) ReadRegister(addr uint16, regType RegType) (value uint16, err error) + func (mc *ModbusClient) ReadRegisters(addr uint16, quantity uint16, regType RegType) (values []uint16, err error) + func (mc *ModbusClient) ReadUint32(addr uint16, regType RegType) (value uint32, err error) + func (mc *ModbusClient) ReadUint32s(addr uint16, quantity uint16, regType RegType) (values []uint32, err error) + func (mc *ModbusClient) ReadUint64(addr uint16, regType RegType) (value uint64, err error) + func (mc *ModbusClient) ReadUint64s(addr uint16, quantity uint16, regType RegType) (values []uint64, err error) + func (mc *ModbusClient) SetEncoding(endianness Endianness, wordOrder WordOrder) (err error) + func (mc *ModbusClient) SetUnitId(id uint8) (err error) + func (mc *ModbusClient) WriteBytes(addr uint16, values []byte) (err error) + func (mc *ModbusClient) WriteCoil(addr uint16, value bool) (err error) + func (mc *ModbusClient) WriteCoils(addr uint16, values []bool) (err error) + func (mc *ModbusClient) WriteFloat32(addr uint16, value float32) (err error) + func (mc *ModbusClient) WriteFloat32s(addr uint16, values []float32) (err error) + func (mc *ModbusClient) WriteFloat64(addr uint16, value float64) (err error) + func (mc *ModbusClient) WriteFloat64s(addr uint16, values []float64) (err error) + func (mc *ModbusClient) WriteRawBytes(addr uint16, values []byte) (err error) + func (mc *ModbusClient) WriteRegister(addr uint16, value uint16) (err error) + func (mc *ModbusClient) WriteRegisters(addr uint16, values []uint16) (err error) + func (mc *ModbusClient) WriteUint32(addr uint16, value uint32) (err error) + func (mc *ModbusClient) WriteUint32s(addr uint16, values []uint32) (err error) + func (mc *ModbusClient) WriteUint64(addr uint16, value uint64) (err error) + func (mc *ModbusClient) WriteUint64s(addr uint16, values []uint64) (err error) + type ModbusServer struct + func NewServer(conf *ServerConfiguration, reqHandler RequestHandler) (ms *ModbusServer, err error) + func (ms *ModbusServer) Start() (err error) + func (ms *ModbusServer) Stop() (err error) + type RegType uint + type RequestHandler interface + HandleCoils func(req *CoilsRequest) (res []bool, err error) + HandleDiscreteInputs func(req *DiscreteInputsRequest) (res []bool, err error) + HandleHoldingRegisters func(req *HoldingRegistersRequest) (res []uint16, err error) + HandleInputRegisters func(req *InputRegistersRequest) (res []uint16, err error) + type ServerConfiguration struct + Logger *log.Logger + MaxClients uint + TLSClientCAs *x509.CertPool + TLSServerCert *tls.Certificate + Timeout time.Duration + URL string + type WordOrder uint