Network APIs for ROS-based systems, including IP address and ROS TCP header libraries. Because ROS-based runtimes must respect the ROS_IP and ROS_HOSTNAME environment variables, ROS-specific APIs are necessary for correctly retrieving local IP address information.
Exception |
|
Exception to represent errors decoding handshake |
Function | create |
Determine the XMLRPC URI for local servers. This handles the search logic of checking ROS environment variables, the known hostname, and local interface IP addresses to determine the best possible URI. |
Function | decode |
Decode serialized ROS handshake header into a Python dictionary |
Function | encode |
Encode ROS handshake header as a byte string. Each header field is a string key value pair. The encoded header is prefixed by a length field, as is each field key/value pair. key/value pairs a separated by a '=' equals sign. |
Function | get |
No summary |
Function | get |
No summary |
Function | get |
if ROS_IP/ROS_HOSTNAME is set, use that address |
Function | get |
No summary |
Function | get |
No summary |
Function | is |
No summary |
Function | parse |
Convenience routine to handle parsing and validation of HTTP URL port due to the fact that Python only provides easy accessors in Python 2.5 and later. Validation checks that the protocol and host are set. |
Function | read |
Read in tcpros header off the socket \x07 sock using buffer \x07 b. |
Function | use |
Undocumented |
Function | write |
Write ROS handshake header header to socket sock |
Variable | logger |
Undocumented |
Variable | python3 |
Undocumented |
Variable | SIOCGIFADDR |
Undocumented |
Variable | SIOCGIFCONF |
Undocumented |
Function | _is |
@rtype: bool |
Variable | _local |
Undocumented |
Determine the XMLRPC URI for local servers. This handles the search logic of checking ROS environment variables, the known hostname, and local interface IP addresses to determine the best possible URI.
Parameters | |
port | port that server is running on, int |
Returns | |
XMLRPC URI, str |
Decode serialized ROS handshake header into a Python dictionary
header is a list of string key=value pairs, each prefixed by a 4-byte length field. It is preceded by a 4-byte length field for the entire header.
Parameters | |
header | encoded header string. May contain extra data at the end, str |
Returns | |
key value pairs encoded in \x07 header_str, {str: str} |
Encode ROS handshake header as a byte string. Each header field is a string key value pair. The encoded header is prefixed by a length field, as is each field key/value pair. key/value pairs a separated by a '=' equals sign.
FORMAT: (4-byte length + [4-byte field length + field=value ]*)
Parameters | |
header | header field keys/values, dict |
Returns | |
header encoded as byte string, bytes |
Returns | |
ROS_IP/ROS_HOSTNAME override or None, str | |
Raises | |
Unknown exception | ValueError If ROS_IP/ROS_HOSTNAME/__ip/__hostname are invalidly specified |
Parameters | |
address | (optional) address to compare against, str |
Returns | |
address TCP/IP sockets should use for binding. This is generally 0.0.0.0, but if \x07 address or ROS_IP/ROS_HOSTNAME is set to localhost it will return 127.0.0.1, str |
- Determine host-name for use in host-name-based addressing (e.g. XML-RPC URIs):
- if ROS_IP/ROS_HOSTNAME is set, use that address
- if the hostname returns a non-localhost value, use that
- use whatever L{get_local_address()} returns
Returns | |
default local IP address (e.g. eth0). May be overridden by ROS_IP/ROS_HOSTNAME/__ip/__hostname, str |
Parameters | |
hostname | host name/address, str |
Returns | |
if hostname maps to a local address, False otherwise. False conditions include invalid hostnames. |
Convenience routine to handle parsing and validation of HTTP URL port due to the fact that Python only provides easy accessors in Python 2.5 and later. Validation checks that the protocol and host are set.
Parameters | |
url | URL to parse, str |
Returns | |
hostname and port number in URL or 80 (default), (str, int) | |
Raises | |
Unknown exception | ValueError If the url does not validate |
Read in tcpros header off the socket \x07 sock using buffer \x07 b.
Parameters | |
sock | socket must be in blocking mode, socket |
b | buffer to use, StringIO for Python2, BytesIO for Python 3 |
buff | incoming buffer size to use, int |
Returns | |
key value pairs encoded in handshake, {str: str} | |
Raises | |
Unknown exception | ROSHandshakeException If header format does not match expected |
Write ROS handshake header header to socket sock
Parameters | |
sock | socket to write to (must be in blocking mode), socket.socket |
header | header field keys/values, {str : str} |
Returns | |
Number of bytes sent (for statistics), int |