Skip to content

Commit

Permalink
yarpserver: abort if rossrv or tcpros or xmlrpc are not found when
Browse files Browse the repository at this point in the history
launched with `--ros` option

It fixes #722
  • Loading branch information
Nicogene committed May 9, 2018
1 parent 400a67c commit 10c0738
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libYARP_serversql/src/yarpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <yarp/os/all.h>
#include <yarp/os/Os.h>
#include <yarp/os/RosNameSpace.h>
#include <yarp/os/Carriers.h>

#include <yarp/name/NameServerManager.h>
#include <yarp/name/BootstrapServer.h>
Expand Down Expand Up @@ -166,6 +167,17 @@ class NameServerContainer : public ComposedNameService
}

if (options.check("ros") || NetworkBase::getEnvironment("YARP_USE_ROS")!="") {
yarp::os::Bottle lst = yarp::os::Carriers::listCarriers();
std::string lstStr(lst.toString().c_str());
if (lstStr.find("rossrv") == std::string::npos ||
lstStr.find("tcpros") == std::string::npos ||
lstStr.find("xmlrpc") == std::string::npos) {
fprintf(stderr,"Missing one or more required carriers ");
fprintf(stderr,"for yarpserver --ros (rossrv, tcpros, xmlrpc).\n");
fprintf(stderr,"Run 'yarp connect --list-carriers' to see carriers on your machine\n");
fprintf(stderr,"Aborting.\n");
return false;
}
ConstString addr = NetworkBase::getEnvironment("ROS_MASTER_URI");
Contact c = Contact::fromString(addr.c_str());
if (c.isValid()) {
Expand Down

0 comments on commit 10c0738

Please sign in to comment.