UAVCAN servers: proper handling of startup failure, more verbose error reporting

This commit is contained in:
Pavel Kirienko 2015-08-15 09:42:16 +03:00
parent e9ce0789c3
commit aa412aaced
1 changed files with 14 additions and 2 deletions

View File

@ -142,8 +142,9 @@ int UavcanServers::start(unsigned num_ifaces, uavcan::INode &main_node)
int rv = _instance->init(num_ifaces);
if (rv < 0) {
warnx("Node init failed %i", rv);
warnx("Node init failed: %d", rv);
delete _instance;
_instance = nullptr;
return rv;
}
@ -163,9 +164,10 @@ int UavcanServers::start(unsigned num_ifaces, uavcan::INode &main_node)
rv = pthread_create(&_instance->_subnode_thread, &tattr, static_cast<pthread_startroutine_t>(run_trampoline), NULL);
if (rv < 0) {
warnx("start failed: %d", errno);
warnx("pthread_create() failed: %d", errno);
rv = -errno;
delete _instance;
_instance = nullptr;
}
return rv;
@ -173,6 +175,8 @@ int UavcanServers::start(unsigned num_ifaces, uavcan::INode &main_node)
int UavcanServers::init(unsigned num_ifaces)
{
errno = 0;
/*
* Initialize the mutex.
* giving it its path
@ -181,6 +185,7 @@ int UavcanServers::init(unsigned num_ifaces)
int ret = Lock::init(_subnode_mutex);
if (ret < 0) {
warnx("Lock init: %d", errno);
return ret;
}
@ -197,6 +202,7 @@ int UavcanServers::init(unsigned num_ifaces)
ret = _fw_version_checker.createFwPaths(UAVCAN_FIRMWARE_PATH);
if (ret < 0) {
warnx("FirmwareVersionChecker init: %d, errno: %d", ret, errno);
return ret;
}
@ -205,6 +211,7 @@ int UavcanServers::init(unsigned num_ifaces)
ret = _fw_server.start();
if (ret < 0) {
warnx("BasicFileServer init: %d, errno: %d", ret, errno);
return ret;
}
@ -213,6 +220,7 @@ int UavcanServers::init(unsigned num_ifaces)
ret = _storage_backend.init(UAVCAN_NODE_DB_PATH);
if (ret < 0) {
warnx("FileStorageBackend init: %d, errno: %d", ret, errno);
return ret;
}
@ -221,6 +229,7 @@ int UavcanServers::init(unsigned num_ifaces)
ret = _tracer.init(UAVCAN_LOG_FILE);
if (ret < 0) {
warnx("FileEventTracer init: %d, errno: %d", ret, errno);
return ret;
}
@ -232,6 +241,7 @@ int UavcanServers::init(unsigned num_ifaces)
ret = _server_instance.init(hwver.unique_id);
if (ret < 0) {
warnx("CentralizedServer init: %d", ret);
return ret;
}
@ -240,6 +250,7 @@ int UavcanServers::init(unsigned num_ifaces)
ret = _node_info_retriever.start();
if (ret < 0) {
warnx("NodeInfoRetriever init: %d", ret);
return ret;
}
@ -248,6 +259,7 @@ int UavcanServers::init(unsigned num_ifaces)
ret = _fw_upgrade_trigger.start(_node_info_retriever, _fw_version_checker.getFirmwarePath());
if (ret < 0) {
warnx("FirmwareUpdateTrigger init: %d", ret);
return ret;
}