Documentation
¶
Index ¶
- Constants
- Variables
- func SetChecksum(b []byte)
- type BadRxErr
- type Cmd
- type CmdReq
- type Controller
- type IController
- type ModbusErr
- type OpenErr
- type Parity
- type PortOpener
- type ReadCoilsCmd
- func (c *ReadCoilsCmd) Addr() uint16
- func (c *ReadCoilsCmd) Bytes() []byte
- func (c *ReadCoilsCmd) Coil(i int) bool
- func (c *ReadCoilsCmd) Count() int
- func (c *ReadCoilsCmd) DevAddr() byte
- func (c *ReadCoilsCmd) Err() error
- func (c *ReadCoilsCmd) IsValidRx() bool
- func (c *ReadCoilsCmd) Rx() string
- func (c *ReadCoilsCmd) RxBytes() *[]byte
- func (c *ReadCoilsCmd) SetAddr(x uint16)
- func (c *ReadCoilsCmd) SetDevAddr(x byte)
- func (c *ReadCoilsCmd) String() string
- func (c *ReadCoilsCmd) Tx() string
- func (c *ReadCoilsCmd) TxBytes() []byte
- type ReadDInputsCmd
- func (c *ReadDInputsCmd) Addr() uint16
- func (c *ReadDInputsCmd) Bytes() []byte
- func (c *ReadDInputsCmd) Count() int
- func (c *ReadDInputsCmd) DevAddr() byte
- func (c *ReadDInputsCmd) Err() error
- func (c *ReadDInputsCmd) Input(i int) bool
- func (c *ReadDInputsCmd) IsValidRx() bool
- func (c *ReadDInputsCmd) Rx() string
- func (c *ReadDInputsCmd) RxBytes() *[]byte
- func (c *ReadDInputsCmd) SetAddr(x uint16)
- func (c *ReadDInputsCmd) SetDevAddr(x byte)
- func (c *ReadDInputsCmd) String() string
- func (c *ReadDInputsCmd) Tx() string
- func (c *ReadDInputsCmd) TxBytes() []byte
- type ReadHRegsCmd
- func (c *ReadHRegsCmd) Addr() uint16
- func (c *ReadHRegsCmd) Bytes() []byte
- func (c *ReadHRegsCmd) Count() int
- func (c *ReadHRegsCmd) DevAddr() byte
- func (c *ReadHRegsCmd) Err() error
- func (c *ReadHRegsCmd) IsValidRx() bool
- func (c *ReadHRegsCmd) Reg(i int) uint16
- func (c *ReadHRegsCmd) Rx() string
- func (c *ReadHRegsCmd) RxBytes() *[]byte
- func (c *ReadHRegsCmd) SetAddr(x uint16)
- func (c *ReadHRegsCmd) SetDevAddr(x byte)
- func (c *ReadHRegsCmd) String() string
- func (c *ReadHRegsCmd) Tx() string
- func (c *ReadHRegsCmd) TxBytes() []byte
- type ReadIRegsCmd
- func (c *ReadIRegsCmd) Addr() uint16
- func (c *ReadIRegsCmd) Bytes() []byte
- func (c *ReadIRegsCmd) Count() int
- func (c *ReadIRegsCmd) DevAddr() byte
- func (c *ReadIRegsCmd) Err() error
- func (c *ReadIRegsCmd) IsValidRx() bool
- func (c *ReadIRegsCmd) Reg(i int) uint16
- func (c *ReadIRegsCmd) Rx() string
- func (c *ReadIRegsCmd) RxBytes() *[]byte
- func (c *ReadIRegsCmd) SetAddr(x uint16)
- func (c *ReadIRegsCmd) SetDevAddr(x byte)
- func (c *ReadIRegsCmd) String() string
- func (c *ReadIRegsCmd) Tx() string
- func (c *ReadIRegsCmd) TxBytes() []byte
- type Scanner
- type SerialPort
- type SubScanner
- type WriteCoilCmd
- func (c *WriteCoilCmd) Addr() uint16
- func (c *WriteCoilCmd) Coil() bool
- func (c *WriteCoilCmd) DevAddr() byte
- func (c *WriteCoilCmd) Err() error
- func (c *WriteCoilCmd) IsValidRx() bool
- func (c *WriteCoilCmd) Rx() string
- func (c *WriteCoilCmd) RxBytes() *[]byte
- func (c *WriteCoilCmd) SetAddr(x uint16)
- func (c *WriteCoilCmd) SetCoil(v bool)
- func (c *WriteCoilCmd) SetDevAddr(x byte)
- func (c *WriteCoilCmd) String() string
- func (c *WriteCoilCmd) Tx() string
- func (c *WriteCoilCmd) TxBytes() []byte
- type WriteCoilsCmd
- func (c *WriteCoilsCmd) Addr() uint16
- func (c *WriteCoilsCmd) Byte(i int) byte
- func (c *WriteCoilsCmd) ByteCount() int
- func (c *WriteCoilsCmd) Bytes() []byte
- func (c *WriteCoilsCmd) Coil(i int) bool
- func (c *WriteCoilsCmd) Count() int
- func (c *WriteCoilsCmd) DevAddr() byte
- func (c *WriteCoilsCmd) Err() error
- func (c *WriteCoilsCmd) IsValidRx() bool
- func (c *WriteCoilsCmd) ModifyBytes(f func(b []byte))
- func (c *WriteCoilsCmd) Rx() string
- func (c *WriteCoilsCmd) RxBytes() *[]byte
- func (c *WriteCoilsCmd) SetAddr(x uint16)
- func (c *WriteCoilsCmd) SetByte(i int, b byte)
- func (c *WriteCoilsCmd) SetCoil(i int, v bool)
- func (c *WriteCoilsCmd) SetCoils(coils []bool)
- func (c *WriteCoilsCmd) SetDevAddr(x byte)
- func (c *WriteCoilsCmd) String() string
- func (c *WriteCoilsCmd) Tx() string
- func (c *WriteCoilsCmd) TxBytes() []byte
- type WriteRegCmd
- func (c *WriteRegCmd) Addr() uint16
- func (c *WriteRegCmd) DevAddr() byte
- func (c *WriteRegCmd) Err() error
- func (c *WriteRegCmd) IsValidRx() bool
- func (c *WriteRegCmd) Reg() uint16
- func (c *WriteRegCmd) Rx() string
- func (c *WriteRegCmd) RxBytes() *[]byte
- func (c *WriteRegCmd) SetAddr(x uint16)
- func (c *WriteRegCmd) SetDevAddr(x byte)
- func (c *WriteRegCmd) SetReg(v uint16)
- func (c *WriteRegCmd) String() string
- func (c *WriteRegCmd) Tx() string
- func (c *WriteRegCmd) TxBytes() []byte
- type WriteRegsCmd
- func (c *WriteRegsCmd) Addr() uint16
- func (c *WriteRegsCmd) Byte(i int) byte
- func (c *WriteRegsCmd) ByteCount() int
- func (c *WriteRegsCmd) Bytes() []byte
- func (c *WriteRegsCmd) Count() int
- func (c *WriteRegsCmd) DevAddr() byte
- func (c *WriteRegsCmd) Err() error
- func (c *WriteRegsCmd) IsValidRx() bool
- func (c *WriteRegsCmd) ModifyBytes(f func(b []byte))
- func (c *WriteRegsCmd) Reg(i int) uint16
- func (c *WriteRegsCmd) Rx() string
- func (c *WriteRegsCmd) RxBytes() *[]byte
- func (c *WriteRegsCmd) SetAddr(x uint16)
- func (c *WriteRegsCmd) SetByte(i int, b byte)
- func (c *WriteRegsCmd) SetDevAddr(x byte)
- func (c *WriteRegsCmd) SetReg(i int, v uint16)
- func (c *WriteRegsCmd) String() string
- func (c *WriteRegsCmd) Tx() string
- func (c *WriteRegsCmd) TxBytes() []byte
Constants ¶
View Source
const ( NoParity = Parity(serial.NoParity) OddParity = Parity(serial.OddParity) EvenParity = Parity(serial.EvenParity) )
View Source
const ( SERIAL_TIMEOUT = 30 * time.Millisecond SERIAL_WAIT = 30 * time.Millisecond BAUDRATE = 9600 )
View Source
const (
TIMEOUT = time.Second
)
Variables ¶
View Source
var ( ErrorLogFunc func(string, ...interface{}) InfoLogFunc func(string, ...interface{}) DebugLogFunc func(string, ...interface{}) )
View Source
var ErrTimeout = errors.New("timeout")
Functions ¶
func SetChecksum ¶
func SetChecksum(b []byte)
Types ¶
type Controller ¶
type Controller struct {
Port PortOpener
Timeout time.Duration
// contains filtered or unexported fields
}
func (*Controller) Close ¶
func (c *Controller) Close()
func (*Controller) Send ¶
func (c *Controller) Send(cmd Cmd) error
type IController ¶
type PortOpener ¶
type ReadCoilsCmd ¶
type ReadCoilsCmd struct {
// contains filtered or unexported fields
}
func NewReadCoilsCmd ¶
func NewReadCoilsCmd(devAddr byte, addr uint16, count uint16) *ReadCoilsCmd
func (*ReadCoilsCmd) Bytes ¶
func (c *ReadCoilsCmd) Bytes() []byte
func (*ReadCoilsCmd) Coil ¶
func (c *ReadCoilsCmd) Coil(i int) bool
func (*ReadCoilsCmd) Count ¶
func (c *ReadCoilsCmd) Count() int
func (*ReadCoilsCmd) IsValidRx ¶
func (c *ReadCoilsCmd) IsValidRx() bool
func (*ReadCoilsCmd) Rx ¶
func (c *ReadCoilsCmd) Rx() string
func (*ReadCoilsCmd) SetDevAddr ¶
func (c *ReadCoilsCmd) SetDevAddr(x byte)
func (*ReadCoilsCmd) String ¶
func (c *ReadCoilsCmd) String() string
func (*ReadCoilsCmd) Tx ¶
func (c *ReadCoilsCmd) Tx() string
type ReadDInputsCmd ¶
type ReadDInputsCmd struct {
// contains filtered or unexported fields
}
func NewReadDInputsCmd ¶
func NewReadDInputsCmd( devAddr byte, addr uint16, count uint16, ) *ReadDInputsCmd
func (*ReadDInputsCmd) Bytes ¶
func (c *ReadDInputsCmd) Bytes() []byte
func (*ReadDInputsCmd) Count ¶
func (c *ReadDInputsCmd) Count() int
func (*ReadDInputsCmd) Input ¶
func (c *ReadDInputsCmd) Input(i int) bool
func (*ReadDInputsCmd) IsValidRx ¶
func (c *ReadDInputsCmd) IsValidRx() bool
func (*ReadDInputsCmd) Rx ¶
func (c *ReadDInputsCmd) Rx() string
func (*ReadDInputsCmd) SetDevAddr ¶
func (c *ReadDInputsCmd) SetDevAddr(x byte)
func (*ReadDInputsCmd) String ¶
func (c *ReadDInputsCmd) String() string
func (*ReadDInputsCmd) Tx ¶
func (c *ReadDInputsCmd) Tx() string
type ReadHRegsCmd ¶
type ReadHRegsCmd struct {
// contains filtered or unexported fields
}
func NewReadHRegsCmd ¶
func NewReadHRegsCmd(devAddr byte, addr uint16, count uint16) *ReadHRegsCmd
func (*ReadHRegsCmd) Bytes ¶
func (c *ReadHRegsCmd) Bytes() []byte
func (*ReadHRegsCmd) Count ¶
func (c *ReadHRegsCmd) Count() int
func (*ReadHRegsCmd) IsValidRx ¶
func (c *ReadHRegsCmd) IsValidRx() bool
func (*ReadHRegsCmd) Reg ¶
func (c *ReadHRegsCmd) Reg(i int) uint16
func (*ReadHRegsCmd) Rx ¶
func (c *ReadHRegsCmd) Rx() string
func (*ReadHRegsCmd) SetDevAddr ¶
func (c *ReadHRegsCmd) SetDevAddr(x byte)
func (*ReadHRegsCmd) String ¶
func (c *ReadHRegsCmd) String() string
func (*ReadHRegsCmd) Tx ¶
func (c *ReadHRegsCmd) Tx() string
type ReadIRegsCmd ¶
type ReadIRegsCmd struct {
// contains filtered or unexported fields
}
func NewReadIRegsCmd ¶
func NewReadIRegsCmd(devAddr byte, addr uint16, count uint16) *ReadIRegsCmd
func (*ReadIRegsCmd) Bytes ¶
func (c *ReadIRegsCmd) Bytes() []byte
func (*ReadIRegsCmd) Count ¶
func (c *ReadIRegsCmd) Count() int
func (*ReadIRegsCmd) IsValidRx ¶
func (c *ReadIRegsCmd) IsValidRx() bool
func (*ReadIRegsCmd) Reg ¶
func (c *ReadIRegsCmd) Reg(i int) uint16
func (*ReadIRegsCmd) Rx ¶
func (c *ReadIRegsCmd) Rx() string
func (*ReadIRegsCmd) SetDevAddr ¶
func (c *ReadIRegsCmd) SetDevAddr(x byte)
func (*ReadIRegsCmd) String ¶
func (c *ReadIRegsCmd) String() string
func (*ReadIRegsCmd) Tx ¶
func (c *ReadIRegsCmd) Tx() string
type Scanner ¶
type Scanner struct {
Controller IController
Subs []SubScanner
// contains filtered or unexported fields
}
type SerialPort ¶
type SerialPort struct {
Dev string
Timeout time.Duration
Wait time.Duration
Baudrate int
Parity Parity
}
func (*SerialPort) Open ¶
func (p *SerialPort) Open( repeat bool, ) (io.ReadWriteCloser, time.Duration, error)
type SubScanner ¶
type SubScanner interface {
Run(stop <-chan struct{}) <-chan CmdReq
}
type WriteCoilCmd ¶
type WriteCoilCmd struct {
// contains filtered or unexported fields
}
func NewWriteCoilCmd ¶
func NewWriteCoilCmd(devAddr byte, addr uint16, val bool) *WriteCoilCmd
func (*WriteCoilCmd) Coil ¶
func (c *WriteCoilCmd) Coil() bool
func (*WriteCoilCmd) IsValidRx ¶
func (c *WriteCoilCmd) IsValidRx() bool
func (*WriteCoilCmd) Rx ¶
func (c *WriteCoilCmd) Rx() string
func (*WriteCoilCmd) SetCoil ¶
func (c *WriteCoilCmd) SetCoil(v bool)
func (*WriteCoilCmd) SetDevAddr ¶
func (c *WriteCoilCmd) SetDevAddr(x byte)
func (*WriteCoilCmd) String ¶
func (c *WriteCoilCmd) String() string
func (*WriteCoilCmd) Tx ¶
func (c *WriteCoilCmd) Tx() string
type WriteCoilsCmd ¶
type WriteCoilsCmd struct {
// contains filtered or unexported fields
}
func NewWriteCoilsCmd ¶
func NewWriteCoilsCmd(devAddr byte, addr uint16, values []bool) *WriteCoilsCmd
func (*WriteCoilsCmd) Byte ¶
func (c *WriteCoilsCmd) Byte(i int) byte
func (*WriteCoilsCmd) ByteCount ¶
func (c *WriteCoilsCmd) ByteCount() int
func (*WriteCoilsCmd) Bytes ¶
func (c *WriteCoilsCmd) Bytes() []byte
func (*WriteCoilsCmd) Coil ¶
func (c *WriteCoilsCmd) Coil(i int) bool
func (*WriteCoilsCmd) Count ¶
func (c *WriteCoilsCmd) Count() int
func (*WriteCoilsCmd) IsValidRx ¶
func (c *WriteCoilsCmd) IsValidRx() bool
func (*WriteCoilsCmd) ModifyBytes ¶
func (c *WriteCoilsCmd) ModifyBytes(f func(b []byte))
Warning: care must be taken to not set bit outside valid range.
func (*WriteCoilsCmd) Rx ¶
func (c *WriteCoilsCmd) Rx() string
func (*WriteCoilsCmd) SetByte ¶
func (c *WriteCoilsCmd) SetByte(i int, b byte)
Warning: care must be taken to not set bit outside valid range.
func (*WriteCoilsCmd) SetCoil ¶
func (c *WriteCoilsCmd) SetCoil(i int, v bool)
func (*WriteCoilsCmd) SetCoils ¶
func (c *WriteCoilsCmd) SetCoils(coils []bool)
func (*WriteCoilsCmd) SetDevAddr ¶
func (c *WriteCoilsCmd) SetDevAddr(x byte)
func (*WriteCoilsCmd) String ¶
func (c *WriteCoilsCmd) String() string
func (*WriteCoilsCmd) Tx ¶
func (c *WriteCoilsCmd) Tx() string
type WriteRegCmd ¶
type WriteRegCmd struct {
// contains filtered or unexported fields
}
func NewWriteRegCmd ¶
func NewWriteRegCmd(devAddr byte, addr uint16, val uint16) *WriteRegCmd
func (*WriteRegCmd) IsValidRx ¶
func (c *WriteRegCmd) IsValidRx() bool
func (*WriteRegCmd) Reg ¶
func (c *WriteRegCmd) Reg() uint16
func (*WriteRegCmd) Rx ¶
func (c *WriteRegCmd) Rx() string
func (*WriteRegCmd) SetDevAddr ¶
func (c *WriteRegCmd) SetDevAddr(x byte)
func (*WriteRegCmd) SetReg ¶
func (c *WriteRegCmd) SetReg(v uint16)
func (*WriteRegCmd) String ¶
func (c *WriteRegCmd) String() string
func (*WriteRegCmd) Tx ¶
func (c *WriteRegCmd) Tx() string
type WriteRegsCmd ¶
type WriteRegsCmd struct {
// contains filtered or unexported fields
}
func NewWriteRegsCmd ¶
func NewWriteRegsCmd(devAddr byte, addr uint16, values []uint16) *WriteRegsCmd
func (*WriteRegsCmd) Byte ¶
func (c *WriteRegsCmd) Byte(i int) byte
func (*WriteRegsCmd) ByteCount ¶
func (c *WriteRegsCmd) ByteCount() int
func (*WriteRegsCmd) Bytes ¶
func (c *WriteRegsCmd) Bytes() []byte
func (*WriteRegsCmd) Count ¶
func (c *WriteRegsCmd) Count() int
func (*WriteRegsCmd) IsValidRx ¶
func (c *WriteRegsCmd) IsValidRx() bool
func (*WriteRegsCmd) ModifyBytes ¶
func (c *WriteRegsCmd) ModifyBytes(f func(b []byte))
func (*WriteRegsCmd) Reg ¶
func (c *WriteRegsCmd) Reg(i int) uint16
func (*WriteRegsCmd) Rx ¶
func (c *WriteRegsCmd) Rx() string
func (*WriteRegsCmd) SetByte ¶
func (c *WriteRegsCmd) SetByte(i int, b byte)
func (*WriteRegsCmd) SetDevAddr ¶
func (c *WriteRegsCmd) SetDevAddr(x byte)
func (*WriteRegsCmd) SetReg ¶
func (c *WriteRegsCmd) SetReg(i int, v uint16)
func (*WriteRegsCmd) String ¶
func (c *WriteRegsCmd) String() string
func (*WriteRegsCmd) Tx ¶
func (c *WriteRegsCmd) Tx() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.