wiki:Tutorials/Beginner/Inter-Process Port Connections

Inter-Process Port Connections

In order to create distributed applications, Finroc components from different processes ("parts" or "runtime environments") - possibly running on different systems - can be connected. This can be done using any network transport mechanism available as Finroc plugin. The default, is Finroc's slim TCP plugin. This is used in this tutorial.

Shared Ports

Only ports marked as shared are visible and accessible from other processes. They are so to say the public interface of a process. The reason for this is that it would create considerable overhead if Finroc processes exchanged information on possibly tens of thousands of internal ports. Merely the tools (fingui and finstruct) have access to all ports.

The easiest way to make ports shared is by setting a constructor parameter of a module or group base class to true. For instance, in the tSenseControlModule the parameter is called share_so_and_ci_ports:

 * \param parent Parent
 * \param name Name of module
 * \param share_so_and_ci_ports Share sensor output and controller input ports so that they can be accessed from other runtime environments?
tSenseControlModule(core::tFrameworkElement *parent, const std::string &name, bool share_so_and_ci_ports = false);

To make only single ports shared, the flag tFlag::SHARED can be passed to a port's constructor.

Connecting Processes

If processes are started on the same system with the same server port, they automatically connect. Otherwise, the --connect command line option must be specified when starting one of the processes. The processes should (both) show on the command line that they are connected to the other process.

Connecting Ports

Now the ports need to be conneted. This can either be done from source code or graphically - using finstruct.

Connecting Ports in Source Code

In order to connect a port to a shared port from another process, we need to find out the shared port's Uid (which is - more or less - the port's qualified name).

A convenient way to obtain a port's Uid, is via right-click menu in the tree view of fingui or finstruct. Right-click on the port and select "Copy UID"

This will copy the uid to the clipboard.

Now in the part, you can connect the port by-name:

port.ConnectTo("shared port uid string from clipboard");

Connecting Ports using Finstruct

Simply connnect ports from different processes. You will get an error message if this fails for some reason (e.g. none of the two ports is shared).

Last modified 8 years ago Last modified on 11.04.2014 23:17:01

Attachments (1)

Download all attachments as: .zip