Skip to content

Commit

Permalink
show connection info on rosnode info
Browse files Browse the repository at this point in the history
  • Loading branch information
maximest-pierre committed Aug 28, 2018
1 parent da486b3 commit db2f425
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions clients/rospy/src/rospy/impl/tcpros_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ def get_transport_info(self):
Similar to getTransportInfo() in 'libros/transport/transport_tcp.cpp'
e.g. TCPROS connection on port 41374 to [127.0.0.1:40623 on socket 6]
"""
# Pattern matching this output in tools/rosnode/src/rosnode/__init__.py CONNECTION_PATTERN
return "%s connection on port %s to [%s:%s on socket %s]" % (self.transport_type, self.local_endpoint[1], self.remote_endpoint[0], self.remote_endpoint[1], self._fileno)

def fileno(self):
Expand Down
14 changes: 11 additions & 3 deletions tools/rosnode/src/rosnode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import sys
import socket
import time
import re
try:
from xmlrpc.client import ServerProxy
except ImportError:
Expand All @@ -62,6 +63,8 @@

NAME='rosnode'
ID = '/rosnode'
# The string is defined in clients/rospy/src/rospy/impl/tcpros_base.py TCPROSTransport.get_transport_info
CONNECTION_PATTERN = re.compile(r'\w+ connection on port (\d+) to \[(.*) on socket (\d+)\]')

class ROSNodeException(Exception):
"""
Expand Down Expand Up @@ -543,11 +546,16 @@ def get_node_connection_info_description(node_api, master):
# older ros publisher implementations don't report a URI
buff += " * to: %s\n"%lookup_uri(master, system_state, topic, dest_id)
if direction == 'i':
buff += " * direction: inbound\n"
buff += " * direction: inbound"
elif direction == 'o':
buff += " * direction: outbound\n"
buff += " * direction: outbound"
else:
buff += " * direction: unknown\n"
buff += " * direction: unknown"
if len(info) > 6:
match = CONNECTION_PATTERN.match(info[6])
if match is not None:
buff += " (%s - %s) [%s]" % match.groups()
buff += "\n"
buff += " * transport: %s\n"%transport
except socket.error:
raise ROSNodeIOException("Communication with node[%s] failed!"%(node_api))
Expand Down

0 comments on commit db2f425

Please sign in to comment.