Skip to content

Commit

Permalink
added some useful error messages to yarprun
Browse files Browse the repository at this point in the history
  • Loading branch information
randaz81 committed Jun 1, 2017
1 parent e479747 commit 77d72b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libYARP_OS/src/Run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <yarp/os/Network.h>
#include <yarp/os/Os.h>
#include <yarp/os/LogStream.h>
#include <yarp/os/RpcClient.h>
#include <yarp/os/SystemInfo.h>
#include <yarp/os/SystemInfoSerializer.h>
Expand Down Expand Up @@ -494,8 +495,10 @@ int yarp::os::Run::server()

if (!port.open(mPortName.c_str()))
{
yError() << "Yarprun failed to open port: " << mPortName.c_str();
return YARPRUN_ERROR;
}
yInfo() << "Yarprun succesfully started on port: " << mPortName.c_str();

pServerPort=&port;

Expand Down Expand Up @@ -870,10 +873,12 @@ int yarp::os::Run::server()

if (!port.open(mPortName.c_str()))
{
if (mPortName[0]!='/') fprintf(stderr, "Invalid port name '%s', it should start with '/'\n", mPortName.c_str());
yError() << "Yarprun failed to open port: " << mPortName.c_str();

if (mPortName[0]!='/') yError("Invalid port name '%s', it should start with '/'\n", mPortName.c_str());
return YARPRUN_ERROR;
}
yInfo() << "Yarprun succesfully started on port: " << mPortName.c_str();

pServerPort=&port;

Expand Down
8 changes: 8 additions & 0 deletions src/yarprun/yarprun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@

#include <yarp/os/Run.h>
#include <yarp/os/Network.h>
#include <yarp/os/LogStream.h>
#include <cstdio>


int main(int argc, char *argv[])
{
yarp::os::Network yarp;

if (!yarp.checkNetwork())
{
yError("Sorry YARP network does not seem to be available, is the yarp server available?\n");
return 1;
}

int ret=yarp::os::Run::main(argc,argv);
return (ret!=0?1:0);
}

0 comments on commit 77d72b3

Please sign in to comment.