Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a Modbus TCP Server implementation. A Server listens on a network and awaits a client's request. Servers are typically sensors or actuators in an industrial setting. Server's methods are not all safe for concurrent use.
func NewServer ¶
func NewServer(cfg ServerConfig) (*Server, error)
NewServer returns a Server ready for use. `localhost` in a server address is replaced with `127.0.0.1`
func (*Server) Accept ¶
Accept begins listening on the server's TCP address. If the server already has a connection this method returns an error. By design Servers can only maintain one connection. File an issue if this does not cover your use case.
func (*Server) Addr ¶
Addr returns the address of the last active connection. If the server has not yet initialized a connection it returns an empty *net.TCPAddr.
func (*Server) DataModel ¶
DataModel returns the active handle the the modbus data model. Changes to the data model are reflected in the server's behavior. There is no concurrent protection for the data model.
func (*Server) HandleNext ¶
HandleNext reads the next message on the network and handles it automatically. This call is blocking.
func (*Server) IsConnected ¶
IsConnected returns true if the server has an active connection. Is safe for concurrent use.
type ServerConfig ¶
type ServerConfig struct { // Formatted numeric IP with port. i.e: "192.168.1.35:502" Address string // ConnectTimeout is the maximum amount of time a call to Accept will wait for a connect to complete. ConnectTimeout time.Duration // DataModel defines the data bank used for data access operations // such as read/write operations with coils, discrete inputs, holding registers etc. // If nil a default data model will be chosen. DataModel peamodbus.DataModel }
ServerConfig provides configuration parameters to NewServer.