Yet Another Robot Platform
This example demonstrates how to simply use the port monitor carrier to modify data going through a connection. The port '/write' from 'yarp write' module is connected to the '/read' port of 'yarp read' using a portmonitor plugged into the receiver side. The portmoniotr loads a dll (
'libsimple_monitor.so') in which we access and modify the data going through the port.
$ mkdir $YARP_ROOT/example/portmonitor/simple_dll/build $ cd $YARP_ROOT/example/portmonitor/simple_dll/build $ cmake ../; make;
you should see the
'libsimple_monitor.so' after the compilation (the generated dll can have different names on windows or mac os).
$ yarp write /write
$ yarp read /read
$ yarp connect /write /read tcp+recv.portmonitor+type.dll+file.simple_monitor
Now if you write something in the 'sender' terminal, you will see the text "Modified in DLL" will be added to the original message. For example:
[sender terminal] Hello
[receiver terminal] Hello "Modified in DLL"
As it is constrained in `SimpleMonitorObject::accept()' method from `Simple.cpp', if you type "ignore", the message will be ignored by the portmonitor and it never be delivered to the input port.