Module: Roby::Interface::V1

Extended by:
Logger::Hierarchy
Included in:
Roby::Interface
Defined in:
lib/roby/interface/v1.rb,
lib/roby/interface/v1/tcp.rb,
lib/roby/interface/v1/async.rb,
lib/roby/interface/v1/client.rb,
lib/roby/interface/v1/server.rb,
lib/roby/interface/v1/async/log.rb,
lib/roby/interface/v1/shell_client.rb,
lib/roby/interface/v1/droby_channel.rb,
lib/roby/interface/v1/async/interface.rb,
lib/roby/interface/v1/shell_subcommand.rb,
lib/roby/interface/v1/async/job_monitor.rb,
lib/roby/interface/v1/subcommand_client.rb,
lib/roby/interface/v1/async/ui_connector.rb,
lib/roby/interface/v1/async/action_monitor.rb,
lib/roby/interface/v1/async/new_job_listener.rb

Overview

V1 of the remote Roby control protocol

Defined Under Namespace

Modules: Async Classes: Client, DRobyChannel, Server, ShellClient, ShellSubcommand, SubcommandClient, TCPServer

Class Method Summary collapse

Class Method Details

.connect_with_tcp_to(host, port = DEFAULT_PORT, marshaller: DRoby::Marshal.new(auto_create_plans: true), handshake: %i[actions commands])) ⇒ Client

Connect to a Roby controller interface at this host and port

Parameters:

Returns:



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/roby/interface/v1/tcp.rb', line 175

def self.connect_with_tcp_to(host, port = DEFAULT_PORT,
        marshaller: DRoby::Marshal.new(auto_create_plans: true),
        handshake: %i[actions commands])
    require "socket"
    socket = TCPSocket.new(host, port)
    addr = socket.addr(true)
    channel = DRobyChannel.new(socket, true, marshaller: marshaller)
    Client.new(channel, "#{addr[2]}:#{addr[1]}", handshake: handshake)
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, Errno::ETIMEDOUT,
       Errno::EHOSTUNREACH, Errno::ENETUNREACH => e
    raise ConnectionError,
          "failed to connect to #{host}:#{port}: #{e.message}",
          e.backtrace
rescue SocketError => e
    raise e, "cannot connect to host '#{host}' port '#{port}': #{e.message}",
          e.backtrace
rescue ::Exception # rubocop:disable Lint/RescueException
    socket.close if socket && !socket.closed?
    raise
end