YARP  2.3.70.2
Yet Another Robot Platform
carrier/carrier_stub.cpp

Example showing how to add a new carrier to YARP.

/*
* Copyright: (C) 2010 RobotCub Consortium
* Author: Paul Fitzpatrick
* CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
*/
#include <stdio.h>
#include <yarp/os/all.h>
class TestCarrier : public yarp::os::impl::TextCarrier {
public:
return "test";
}
return "TESTTEST";
}
virtual Carrier *create() {
return new TestCarrier();
}
};
int main(int argc, char *argv[]) {
out.open("/test/out");
in.open("/test/in");
yarp::os::Network::connect("/test/out","/test/in","test");
out.prepare().fromString("1 2 3");
out.write();
yarp::os::Bottle * bot = in.read();
if (bot!=NULL) {
printf("Got message %s\n", bot->toString().c_str());
}
out.close();
in.close();
return 0;
}