Class: ModBus::RTUViaTCPServer

Inherits:
GServer
  • Object
show all
Includes:
Debug, RTU, Server
Defined in:
lib/rmodbus/rtu_via_tcp_server.rb

Overview

RTU over TCP server implementation

Examples:

srv = RTUViaTCPServer.new(10002)
slave = src.with_slave(1)
slave.coils = [1,0,1,1]
slave.discrete_inputs = [1,1,0,0]
slave.holding_registers = [1,2,3,4]
slave.input_registers = [1,2,3,4]
srv.logger = Logger.new($stdout)
srv.start

Constant Summary

Constants included from Server

Server::FUNCS

Instance Attribute Summary

Attributes included from Server

#promiscuous, #request_callback, #response_callback

Attributes included from Debug

#logger, #raise_exception_on_mismatch, #read_retries, #read_retry_timeout

Instance Method Summary collapse

Methods included from Server

#with_slave

Constructor Details

#initialize(port = 10_002, opts = {}) ⇒ RTUViaTCPServer

Init server

Parameters:

  • port (Integer) (defaults to: 10_002)

    listen port

  • uid (Integer)

    slave device

  • opts (Hash) (defaults to: {})

    options of server

Options Hash (opts):

  • :host (String)

    host of server default ‘127.0.0.1’

  • :max_connection (Float, Integer)

    max of TCP connection with server default 4



31
32
33
34
35
# File 'lib/rmodbus/rtu_via_tcp_server.rb', line 31

def initialize(port = 10_002, opts = {})
  opts[:host] = DEFAULT_HOST unless opts[:host]
  opts[:max_connection] = 4 unless opts[:max_connection]
  super(port, opts[:host], opts[:max_connection])
end