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 Lua script ('bot_modifier.lua'
) in which we access and modify the data going through through the port.
$ yarpserver
$ yarp write /write
$ cd $YARP_ROOT/example/portmonitor/simple_modification $ yarp read /read
$ yarp connect /write /read tcp+recv.portmonitor+type.lua+file.bot_modifier
Now if you write something in the 'sender' terminal, you will see the text "modified from Lua" will be added to the original message. For example:
[sender terminal] Hello
[receiver terminal] Hello "modified from Lua"
As it is constrained in this PortMonitor.accept() method, If you type "ignore", the word will never be delivered to the input port.