orb_exists support for muorb

Also added builtin command wait_for_topic

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2016-06-21 10:39:30 -07:00
committed by Lorenz Meier
parent dc787830b5
commit 62a3e07423
15 changed files with 462 additions and 67 deletions

View File

@@ -131,11 +131,15 @@ int uORB::Manager::orb_exists(const struct orb_metadata *meta, int instance)
return ERROR;
}
#ifdef __PX4_NUTTX
#if __PX4_NUTTX
struct stat buffer;
return stat(path, &buffer);
#else
return px4_access(path, F_OK);
ret = px4_access(path, F_OK);
if (ret == -1 && meta != nullptr && _remote_topics.size() > 0) {
ret = (_remote_topics.find(meta->o_name) != _remote_topics.end());
}
return ret;
#endif
}
@@ -197,6 +201,9 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
return nullptr;
}
//For remote systems call over and inform them
uORB::DeviceNode::topic_advertised(meta, priority);
/* the advertiser must perform an initial publish to initialise the object */
result = orb_publish(meta, advertiser, data);
@@ -433,6 +440,23 @@ uORBCommunicator::IChannel *uORB::Manager::get_uorb_communicator(void)
return _comm_channel;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int16_t uORB::Manager::process_remote_topic(const char *topic_name, bool isAdvertisement)
{
warnx("[posix-uORB::Manager::process_remote_topic(%d)] name: %s, isAdver: %d",
__LINE__, topic_name, isAdvertisement);
int16_t rc = 0;
if (isAdvertisement) {
_remote_topics.insert(topic_name);
} else {
_remote_topics.erase(topic_name);
}
return rc;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int16_t uORB::Manager::process_add_subscription(const char *messageName,