Browse Source

uORB delete unused Flavor

sbg
Daniel Agar 7 years ago
parent
commit
edea1b65cd
  1. 14
      src/modules/uORB/uORBCommon.hpp
  2. 47
      src/modules/uORB/uORBDevices.cpp
  3. 6
      src/modules/uORB/uORBDevices.hpp
  4. 2
      src/modules/uORB/uORBMain.cpp
  5. 108
      src/modules/uORB/uORBManager.cpp
  6. 43
      src/modules/uORB/uORBManager.hpp
  7. 18
      src/modules/uORB/uORBUtils.cpp
  8. 10
      src/modules/uORB/uORBUtils.hpp
  9. 7
      src/modules/uORB/uORB_tests/uORBTest_UnitTest.cpp

14
src/modules/uORB/uORBCommon.hpp

@ -45,23 +45,11 @@ namespace uORB @@ -45,23 +45,11 @@ namespace uORB
{
static const unsigned orb_maxpath = 64;
#ifdef ERROR
# undef ERROR
#endif
/* ERROR is not defined for c++ */
const int ERROR = -1;
enum Flavor {
PUBSUB = 0,
PARAM,
Flavor_count
};
struct orb_advertdata {
const struct orb_metadata *meta;
int *instance;
int priority;
};
}
#endif // _uORBCommon_hpp_

47
src/modules/uORB/uORBDevices.cpp

@ -429,13 +429,13 @@ uORB::DeviceNode::publish(const orb_metadata *meta, orb_advert_t handle, const v @@ -429,13 +429,13 @@ uORB::DeviceNode::publish(const orb_metadata *meta, orb_advert_t handle, const v
/* check if the device handle is initialized */
if ((devnode == nullptr) || (meta == nullptr)) {
errno = EFAULT;
return ERROR;
return PX4_ERROR;
}
/* check if the orb meta data matches the publication */
if (devnode->_meta != meta) {
errno = EINVAL;
return ERROR;
return PX4_ERROR;
}
/* call the devnode write method with no file pointer */
@ -443,12 +443,12 @@ uORB::DeviceNode::publish(const orb_metadata *meta, orb_advert_t handle, const v @@ -443,12 +443,12 @@ uORB::DeviceNode::publish(const orb_metadata *meta, orb_advert_t handle, const v
if (ret < 0) {
errno = -ret;
return ERROR;
return PX4_ERROR;
}
if (ret != (int)meta->o_size) {
errno = EIO;
return ERROR;
return PX4_ERROR;
}
/*
@ -458,9 +458,8 @@ uORB::DeviceNode::publish(const orb_metadata *meta, orb_advert_t handle, const v @@ -458,9 +458,8 @@ uORB::DeviceNode::publish(const orb_metadata *meta, orb_advert_t handle, const v
if (ch != nullptr) {
if (ch->send_message(meta->o_name, meta->o_size, (uint8_t *)data) != 0) {
warnx("[uORB::DeviceNode::publish(%d)]: Error Sending [%s] topic data over comm_channel",
__LINE__, meta->o_name);
return ERROR;
PX4_ERR("Error Sending [%s] topic data over comm_channel", meta->o_name);
return PX4_ERROR;
}
}
@ -778,7 +777,7 @@ int uORB::DeviceNode::update_queue_size(unsigned int queue_size) @@ -778,7 +777,7 @@ int uORB::DeviceNode::update_queue_size(unsigned int queue_size)
//queue size is limited to 255 for the single reason that we use uint8 to store it
if (_data || _queue_size > queue_size || queue_size > 255) {
return ERROR;
return PX4_ERROR;
}
_queue_size = queue_size;
@ -815,38 +814,31 @@ int16_t uORB::DeviceNode::process_received_message(int32_t length, uint8_t *data @@ -815,38 +814,31 @@ int16_t uORB::DeviceNode::process_received_message(int32_t length, uint8_t *data
int16_t ret = -1;
if (length != (int32_t)(_meta->o_size)) {
warnx("[uORB::DeviceNode::process_received_message(%d)]Error:[%s] Received DataLength[%d] != ExpectedLen[%d]",
__LINE__, _meta->o_name, (int)length, (int)_meta->o_size);
return ERROR;
PX4_ERR("Received DataLength[%d] != ExpectedLen[%d]", _meta->o_name, (int)length, (int)_meta->o_size);
return PX4_ERROR;
}
/* call the devnode write method with no file pointer */
ret = write(nullptr, (const char *)data, _meta->o_size);
if (ret < 0) {
return ERROR;
return PX4_ERROR;
}
if (ret != (int)_meta->o_size) {
errno = EIO;
return ERROR;
return PX4_ERROR;
}
return PX4_OK;
}
uORB::DeviceMaster::DeviceMaster(Flavor f) :
CDev((f == PUBSUB) ? "obj_master" : "param_master",
(f == PUBSUB) ? TOPIC_MASTER_DEVICE_PATH : PARAM_MASTER_DEVICE_PATH),
_flavor(f)
uORB::DeviceMaster::DeviceMaster() :
CDev("obj_master", TOPIC_MASTER_DEVICE_PATH)
{
_last_statistics_output = hrt_absolute_time();
}
uORB::DeviceMaster::~DeviceMaster()
{
}
int
uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
{
@ -856,19 +848,16 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg) @@ -856,19 +848,16 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
case ORBIOCADVERTISE: {
const struct orb_advertdata *adv = (const struct orb_advertdata *)arg;
const struct orb_metadata *meta = adv->meta;
const char *objname;
const char *devpath;
char nodepath[orb_maxpath];
uORB::DeviceNode *node;
/* construct a path to the node - this also checks the node name */
ret = uORB::Utils::node_mkpath(nodepath, _flavor, meta, adv->instance);
ret = uORB::Utils::node_mkpath(nodepath, meta, adv->instance);
if (ret != PX4_OK) {
return ret;
}
ret = ERROR;
ret = PX4_ERROR;
/* try for topic groups */
const unsigned max_group_tries = (adv->instance != nullptr) ? ORB_MULTI_MAX_INSTANCES : 1;
@ -895,17 +884,17 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg) @@ -895,17 +884,17 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
*(adv->instance) = group_tries;
}
objname = meta->o_name; //no need for a copy, meta->o_name will never be freed or changed
const char *objname = meta->o_name; //no need for a copy, meta->o_name will never be freed or changed
/* driver wants a permanent copy of the path, so make one here */
devpath = strdup(nodepath);
const char *devpath = strdup(nodepath);
if (devpath == nullptr) {
return -ENOMEM;
}
/* construct the new node */
node = new uORB::DeviceNode(meta, objname, devpath, adv->priority);
uORB::DeviceNode *node = new uORB::DeviceNode(meta, objname, devpath, adv->priority);
/* if we didn't get a device, that's bad */
if (node == nullptr) {

6
src/modules/uORB/uORBDevices.hpp

@ -298,8 +298,8 @@ public: @@ -298,8 +298,8 @@ public:
private:
// Private constructor, uORB::Manager takes care of its creation
DeviceMaster(Flavor f);
virtual ~DeviceMaster();
DeviceMaster();
virtual ~DeviceMaster() = default;
struct DeviceNodeStatisticsData {
DeviceNode *node;
@ -322,8 +322,6 @@ private: @@ -322,8 +322,6 @@ private:
*/
uORB::DeviceNode *getDeviceNodeLocked(const char *node_name);
const Flavor _flavor;
#ifdef __PX4_NUTTX
ORBMap _node_map;
#else

2
src/modules/uORB/uORBMain.cpp

@ -105,7 +105,7 @@ uorb_main(int argc, char *argv[]) @@ -105,7 +105,7 @@ uorb_main(int argc, char *argv[])
}
/* create the driver */
g_dev = uORB::Manager::get_instance()->get_device_master(uORB::PUBSUB);
g_dev = uORB::Manager::get_instance()->get_device_master();
if (g_dev == nullptr) {
return -errno;

108
src/modules/uORB/uORBManager.cpp

@ -64,9 +64,7 @@ bool uORB::Manager::initialize() @@ -64,9 +64,7 @@ bool uORB::Manager::initialize()
uORB::Manager::Manager()
: _comm_channel(nullptr)
{
for (int i = 0; i < Flavor_count; ++i) {
_device_masters[i] = nullptr;
}
_device_master = nullptr;
#ifdef ORB_USE_PUBLISHER_RULES
const char *file_name = "./rootfs/orb_publisher.rules";
@ -86,26 +84,22 @@ uORB::Manager::Manager() @@ -86,26 +84,22 @@ uORB::Manager::Manager()
uORB::Manager::~Manager()
{
for (int i = 0; i < Flavor_count; ++i) {
if (_device_masters[i]) {
delete _device_masters[i];
}
}
delete _device_master;
}
uORB::DeviceMaster *uORB::Manager::get_device_master(Flavor flavor)
uORB::DeviceMaster *uORB::Manager::get_device_master()
{
if (!_device_masters[flavor]) {
_device_masters[flavor] = new DeviceMaster(flavor);
if (!_device_master) {
_device_master = new DeviceMaster();
if (_device_masters[flavor]) {
int ret = _device_masters[flavor]->init();
if (_device_master) {
int ret = _device_master->init();
if (ret != PX4_OK) {
PX4_ERR("Initialization of DeviceMaster failed (%i)", ret);
errno = -ret;
delete _device_masters[flavor];
_device_masters[flavor] = nullptr;
delete _device_master;
_device_master = nullptr;
}
} else {
@ -114,7 +108,7 @@ uORB::DeviceMaster *uORB::Manager::get_device_master(Flavor flavor) @@ -114,7 +108,7 @@ uORB::DeviceMaster *uORB::Manager::get_device_master(Flavor flavor)
}
}
return _device_masters[flavor];
return _device_master;
}
int uORB::Manager::orb_exists(const struct orb_metadata *meta, int instance)
@ -124,11 +118,11 @@ int uORB::Manager::orb_exists(const struct orb_metadata *meta, int instance) @@ -124,11 +118,11 @@ int uORB::Manager::orb_exists(const struct orb_metadata *meta, int instance)
*/
char path[orb_maxpath];
int inst = instance;
int ret = uORB::Utils::node_mkpath(path, PUBSUB, meta, &inst);
int ret = uORB::Utils::node_mkpath(path, meta, &inst);
if (ret != OK) {
errno = -ret;
return ERROR;
return PX4_ERROR;
}
#if defined(__PX4_NUTTX)
@ -138,7 +132,7 @@ int uORB::Manager::orb_exists(const struct orb_metadata *meta, int instance) @@ -138,7 +132,7 @@ int uORB::Manager::orb_exists(const struct orb_metadata *meta, int instance)
ret = px4_access(path, F_OK);
if (ret == -1 && meta != nullptr && !_remote_topics.empty()) {
ret = (_remote_topics.find(meta->o_name) != _remote_topics.end()) ? OK : ERROR;
ret = (_remote_topics.find(meta->o_name) != _remote_topics.end()) ? OK : PX4_ERROR;
}
#endif
@ -154,7 +148,7 @@ int uORB::Manager::orb_exists(const struct orb_metadata *meta, int instance) @@ -154,7 +148,7 @@ int uORB::Manager::orb_exists(const struct orb_metadata *meta, int instance)
if (px4_ioctl(fd, ORBIOCISPUBLISHED, (unsigned long)&is_published) == 0) {
if (!is_published) {
ret = ERROR;
ret = PX4_ERROR;
}
}
@ -196,9 +190,9 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta, @@ -196,9 +190,9 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
orb_advert_t advertiser;
/* open the node as an advertiser */
fd = node_open(PUBSUB, meta, data, true, instance, priority);
fd = node_open(meta, data, true, instance, priority);
if (fd == ERROR) {
if (fd == PX4_ERROR) {
PX4_ERR("%s advertise failed", meta->o_name);
return nullptr;
}
@ -216,7 +210,7 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta, @@ -216,7 +210,7 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
result = px4_ioctl(fd, ORBIOCGADVERTISER, (unsigned long)&advertiser);
px4_close(fd);
if (result == ERROR) {
if (result == PX4_ERROR) {
PX4_WARN("px4_ioctl ORBIOCGADVERTISER failed. fd = %d", fd);
return nullptr;
}
@ -227,7 +221,7 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta, @@ -227,7 +221,7 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
/* the advertiser must perform an initial publish to initialise the object */
result = orb_publish(meta, advertiser, data);
if (result == ERROR) {
if (result == PX4_ERROR) {
PX4_WARN("orb_publish failed");
return nullptr;
}
@ -250,13 +244,13 @@ int uORB::Manager::orb_unadvertise(orb_advert_t handle) @@ -250,13 +244,13 @@ int uORB::Manager::orb_unadvertise(orb_advert_t handle)
int uORB::Manager::orb_subscribe(const struct orb_metadata *meta)
{
return node_open(PUBSUB, meta, nullptr, false);
return node_open(meta, nullptr, false);
}
int uORB::Manager::orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
{
int inst = instance;
return node_open(PUBSUB, meta, nullptr, false, &inst);
return node_open(meta, nullptr, false, &inst);
}
int uORB::Manager::orb_unsubscribe(int fd)
@ -284,12 +278,12 @@ int uORB::Manager::orb_copy(const struct orb_metadata *meta, int handle, void *b @@ -284,12 +278,12 @@ int uORB::Manager::orb_copy(const struct orb_metadata *meta, int handle, void *b
ret = px4_read(handle, buffer, meta->o_size);
if (ret < 0) {
return ERROR;
return PX4_ERROR;
}
if (ret != (int)meta->o_size) {
errno = EIO;
return ERROR;
return PX4_ERROR;
}
return PX4_OK;
@ -333,7 +327,7 @@ int uORB::Manager::node_advertise @@ -333,7 +327,7 @@ int uORB::Manager::node_advertise
)
{
int fd = -1;
int ret = ERROR;
int ret = PX4_ERROR;
/* fill advertiser data */
const struct orb_advertdata adv = { meta, instance, priority };
@ -362,15 +356,8 @@ out: @@ -362,15 +356,8 @@ out:
return ret;
}
int uORB::Manager::node_open
(
Flavor f,
const struct orb_metadata *meta,
const void *data,
bool advertiser,
int *instance,
int priority
)
int uORB::Manager::node_open(const struct orb_metadata *meta, const void *data, bool advertiser, int *instance,
int priority)
{
char path[orb_maxpath];
int fd = -1, ret;
@ -381,7 +368,7 @@ int uORB::Manager::node_open @@ -381,7 +368,7 @@ int uORB::Manager::node_open
*/
if (nullptr == meta) {
errno = ENOENT;
return ERROR;
return PX4_ERROR;
}
/*
@ -389,7 +376,7 @@ int uORB::Manager::node_open @@ -389,7 +376,7 @@ int uORB::Manager::node_open
*/
if (advertiser && (data == nullptr)) {
errno = EINVAL;
return ERROR;
return PX4_ERROR;
}
/* if we have an instance and are an advertiser, we will generate a new node and set the instance,
@ -398,11 +385,11 @@ int uORB::Manager::node_open @@ -398,11 +385,11 @@ int uORB::Manager::node_open
/*
* Generate the path to the node and try to open it.
*/
ret = uORB::Utils::node_mkpath(path, f, meta, instance);
ret = uORB::Utils::node_mkpath(path, meta, instance);
if (ret != OK) {
errno = -ret;
return ERROR;
return PX4_ERROR;
}
/* open the path as either the advertiser or the subscriber */
@ -420,11 +407,11 @@ int uORB::Manager::node_open @@ -420,11 +407,11 @@ int uORB::Manager::node_open
if (ret == PX4_OK) {
/* update the path, as it might have been updated during the node_advertise call */
ret = uORB::Utils::node_mkpath(path, f, meta, instance);
ret = uORB::Utils::node_mkpath(path, meta, instance);
if (ret != PX4_OK) {
errno = -ret;
return ERROR;
return PX4_ERROR;
}
}
@ -447,7 +434,7 @@ int uORB::Manager::node_open @@ -447,7 +434,7 @@ int uORB::Manager::node_open
if (fd < 0) {
errno = EIO;
return ERROR;
return PX4_ERROR;
}
/* everything has been OK, we can return the handle now */
@ -488,23 +475,21 @@ int16_t uORB::Manager::process_remote_topic(const char *topic_name, bool isAdver @@ -488,23 +475,21 @@ int16_t uORB::Manager::process_remote_topic(const char *topic_name, bool isAdver
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int16_t uORB::Manager::process_add_subscription(const char *messageName,
int32_t msgRateInHz)
int16_t uORB::Manager::process_add_subscription(const char *messageName, int32_t msgRateInHz)
{
PX4_DEBUG("[posix-uORB::Manager::process_add_subscription(%d)] entering Manager_process_add_subscription: name: %s",
__LINE__, messageName);
PX4_DEBUG("entering Manager_process_add_subscription: name: %s", messageName);
int16_t rc = 0;
_remote_subscriber_topics.insert(messageName);
char nodepath[orb_maxpath];
int ret = uORB::Utils::node_mkpath(nodepath, PUBSUB, messageName);
DeviceMaster *device_master = get_device_master(PUBSUB);
int ret = uORB::Utils::node_mkpath(nodepath, messageName);
DeviceMaster *device_master = get_device_master();
if (ret == OK && device_master) {
uORB::DeviceNode *node = device_master->getDeviceNode(nodepath);
if (node == nullptr) {
PX4_DEBUG("[posix-uORB::Manager::process_add_subscription(%d)]DeviceNode(%s) not created yet",
__LINE__, messageName);
PX4_DEBUG("DeviceNode(%s) not created yet", messageName);
} else {
// node is present.
@ -520,14 +505,13 @@ int16_t uORB::Manager::process_add_subscription(const char *messageName, @@ -520,14 +505,13 @@ int16_t uORB::Manager::process_add_subscription(const char *messageName,
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int16_t uORB::Manager::process_remove_subscription(
const char *messageName)
int16_t uORB::Manager::process_remove_subscription(const char *messageName)
{
int16_t rc = -1;
_remote_subscriber_topics.erase(messageName);
char nodepath[orb_maxpath];
int ret = uORB::Utils::node_mkpath(nodepath, PUBSUB, messageName);
DeviceMaster *device_master = get_device_master(PUBSUB);
int ret = uORB::Utils::node_mkpath(nodepath, messageName);
DeviceMaster *device_master = get_device_master();
if (ret == OK && device_master) {
uORB::DeviceNode *node = device_master->getDeviceNode(nodepath);
@ -549,21 +533,19 @@ int16_t uORB::Manager::process_remove_subscription( @@ -549,21 +533,19 @@ int16_t uORB::Manager::process_remove_subscription(
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int16_t uORB::Manager::process_received_message(const char *messageName,
int32_t length, uint8_t *data)
int16_t uORB::Manager::process_received_message(const char *messageName, int32_t length, uint8_t *data)
{
int16_t rc = -1;
char nodepath[orb_maxpath];
int ret = uORB::Utils::node_mkpath(nodepath, PUBSUB, messageName);
DeviceMaster *device_master = get_device_master(PUBSUB);
int ret = uORB::Utils::node_mkpath(nodepath, messageName);
DeviceMaster *device_master = get_device_master();
if (ret == OK && device_master) {
uORB::DeviceNode *node = device_master->getDeviceNode(nodepath);
// get the node name.
if (node == nullptr) {
PX4_DEBUG("[uORB::Manager::process_received_message(%d)]Error No existing subscriber found for message: [%s] nodepath:[%s]",
__LINE__, messageName, nodepath);
PX4_DEBUG("No existing subscriber found for message: [%s] nodepath:[%s]", messageName, nodepath);
} else {
// node is present.

43
src/modules/uORB/uORBManager.hpp

@ -79,12 +79,12 @@ public: @@ -79,12 +79,12 @@ public:
}
/**
* Get the DeviceMaster for a given Flavor. If it does not exist,
* Get the DeviceMaster. If it does not exist,
* it will be created and initialized.
* Note: the first call to this is not thread-safe.
* @return nullptr if initialization failed (and errno will be set)
*/
uORB::DeviceMaster *get_device_master(Flavor flavor);
uORB::DeviceMaster *get_device_master();
// ==== uORB interface methods ====
/**
@ -145,7 +145,7 @@ public: @@ -145,7 +145,7 @@ public:
* and handle different priorities (@see orb_priority()).
* @param queue_size Maximum number of buffered elements. If this is 1, no queuing is
* used.
* @return ERROR on error, otherwise returns a handle
* @return PX4_ERROR on error, otherwise returns a handle
* that can be used to publish to the topic.
* If the topic in question is not known (due to an
* ORB_DEFINE with no corresponding ORB_DECLARE)
@ -174,7 +174,7 @@ public: @@ -174,7 +174,7 @@ public:
* for the topic.
* @handle The handle returned from orb_advertise.
* @param data A pointer to the data to be published.
* @return OK on success, ERROR otherwise with errno set accordingly.
* @return OK on success, PX4_ERROR otherwise with errno set accordingly.
*/
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data);
@ -200,7 +200,7 @@ public: @@ -200,7 +200,7 @@ public:
*
* @param meta The uORB metadata (usually from the ORB_ID() macro)
* for the topic.
* @return ERROR on error, otherwise returns a handle
* @return PX4_ERROR on error, otherwise returns a handle
* that can be used to read and update the topic.
*/
int orb_subscribe(const struct orb_metadata *meta);
@ -232,7 +232,7 @@ public: @@ -232,7 +232,7 @@ public:
* @param instance The instance of the topic. Instance 0 matches the
* topic of the orb_subscribe() call, higher indices
* are for topics created with orb_advertise_multi().
* @return ERROR on error, otherwise returns a handle
* @return PX4_ERROR on error, otherwise returns a handle
* that can be used to read and update the topic.
* If the topic in question is not known (due to an
* ORB_DEFINE_OPTIONAL with no corresponding ORB_DECLARE)
@ -244,7 +244,7 @@ public: @@ -244,7 +244,7 @@ public:
* Unsubscribe from a topic.
*
* @param handle A handle returned from orb_subscribe.
* @return OK on success, ERROR otherwise with errno set accordingly.
* @return OK on success, PX4_ERROR otherwise with errno set accordingly.
*/
int orb_unsubscribe(int handle);
@ -262,7 +262,7 @@ public: @@ -262,7 +262,7 @@ public:
* @param buffer Pointer to the buffer receiving the data, or NULL
* if the caller wants to clear the updated flag without
* using the data.
* @return OK on success, ERROR otherwise with errno set accordingly.
* @return OK on success, PX4_ERROR otherwise with errno set accordingly.
*/
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer);
@ -281,7 +281,7 @@ public: @@ -281,7 +281,7 @@ public:
* @param handle A handle returned from orb_subscribe.
* @param updated Set to true if the topic has been updated since the
* last time it was copied using this handle.
* @return OK if the check was successful, ERROR otherwise with
* @return OK if the check was successful, PX4_ERROR otherwise with
* errno set accordingly.
*/
int orb_check(int handle, bool *updated);
@ -293,7 +293,7 @@ public: @@ -293,7 +293,7 @@ public:
* @param handle A handle returned from orb_subscribe.
* @param time Returns the absolute time that the topic was updated, or zero if it has
* never been updated. Time is measured in microseconds.
* @return OK on success, ERROR otherwise with errno set accordingly.
* @return OK on success, PX4_ERROR otherwise with errno set accordingly.
*/
int orb_stat(int handle, uint64_t *time);
@ -302,7 +302,7 @@ public: @@ -302,7 +302,7 @@ public:
*
* @param meta ORB topic metadata.
* @param instance ORB instance
* @return OK if the topic exists, ERROR otherwise.
* @return OK if the topic exists, PX4_ERROR otherwise.
*/
int orb_exists(const struct orb_metadata *meta, int instance);
@ -314,7 +314,7 @@ public: @@ -314,7 +314,7 @@ public:
* topics which are published by multiple publishers (e.g. mag0, mag1, etc.)
* and allows a subscriber to pick the topic with the highest priority,
* independent of the startup order of the associated publishers.
* @return OK on success, ERROR otherwise with errno set accordingly.
* @return OK on success, PX4_ERROR otherwise with errno set accordingly.
*/
int orb_priority(int handle, int32_t *priority);
@ -334,7 +334,7 @@ public: @@ -334,7 +334,7 @@ public:
*
* @param handle A handle returned from orb_subscribe.
* @param interval An interval period in milliseconds.
* @return OK on success, ERROR otherwise with ERRNO set accordingly.
* @return OK on success, PX4_ERROR otherwise with ERRNO set accordingly.
*/
int orb_set_interval(int handle, unsigned interval);
@ -346,7 +346,7 @@ public: @@ -346,7 +346,7 @@ public:
*
* @param handle A handle returned from orb_subscribe.
* @param interval The returned interval period in milliseconds.
* @return OK on success, ERROR otherwise with ERRNO set accordingly.
* @return OK on success, PX4_ERROR otherwise with ERRNO set accordingly.
*/
int orb_get_interval(int handle, unsigned *interval);
@ -393,25 +393,18 @@ private: // class methods @@ -393,25 +393,18 @@ private: // class methods
* Handles creation of the object and the initial publication for
* advertisers.
*/
int
node_open
(
Flavor f,
const struct orb_metadata *meta,
const void *data,
bool advertiser,
int *instance = nullptr,
int priority = ORB_PRIO_DEFAULT
);
int node_open(const struct orb_metadata *meta, const void *data, bool advertiser, int *instance = nullptr,
int priority = ORB_PRIO_DEFAULT);
private: // data members
static Manager *_Instance;
// the communicator channel instance.
uORBCommunicator::IChannel *_comm_channel;
ORBSet _remote_subscriber_topics;
ORBSet _remote_topics;
DeviceMaster *_device_masters[Flavor_count]; ///< Allow at most one DeviceMaster per Flavor
DeviceMaster *_device_master{nullptr};
private: //class methods
Manager();

18
src/modules/uORB/uORBUtils.cpp

@ -35,13 +35,7 @@ @@ -35,13 +35,7 @@
#include <stdio.h>
#include <errno.h>
int uORB::Utils::node_mkpath
(
char *buf,
Flavor f,
const struct orb_metadata *meta,
int *instance
)
int uORB::Utils::node_mkpath(char *buf, const struct orb_metadata *meta, int *instance)
{
unsigned len;
@ -51,9 +45,7 @@ int uORB::Utils::node_mkpath @@ -51,9 +45,7 @@ int uORB::Utils::node_mkpath
index = *instance;
}
len = snprintf(buf, orb_maxpath, "/%s/%s%d",
(f == PUBSUB) ? "obj" : "param",
meta->o_name, index);
len = snprintf(buf, orb_maxpath, "/%s/%s%d", "obj", meta->o_name, index);
if (len >= orb_maxpath) {
return -ENAMETOOLONG;
@ -64,15 +56,13 @@ int uORB::Utils::node_mkpath @@ -64,15 +56,13 @@ int uORB::Utils::node_mkpath
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int uORB::Utils::node_mkpath(char *buf, Flavor f,
const char *orbMsgName)
int uORB::Utils::node_mkpath(char *buf, const char *orbMsgName)
{
unsigned len;
unsigned index = 0;
len = snprintf(buf, orb_maxpath, "/%s/%s%d", (f == PUBSUB) ? "obj" : "param",
orbMsgName, index);
len = snprintf(buf, orb_maxpath, "/%s/%s%d", "obj", orbMsgName, index);
if (len >= orb_maxpath) {
return -ENAMETOOLONG;

10
src/modules/uORB/uORBUtils.hpp

@ -43,18 +43,12 @@ class Utils; @@ -43,18 +43,12 @@ class Utils;
class uORB::Utils
{
public:
static int node_mkpath
(
char *buf,
Flavor f,
const struct orb_metadata *meta,
int *instance = nullptr
);
static int node_mkpath(char *buf, const struct orb_metadata *meta, int *instance = nullptr);
/**
* same as above except this generators the path based on the string.
*/
static int node_mkpath(char *buf, Flavor f, const char *orbMsgName);
static int node_mkpath(char *buf, const char *orbMsgName);
};

7
src/modules/uORB/uORB_tests/uORBTest_UnitTest.cpp

@ -131,7 +131,7 @@ int uORBTest::UnitTest::pubsublatency_main() @@ -131,7 +131,7 @@ int uORBTest::UnitTest::pubsublatency_main()
if (f == nullptr) {
warnx("Error opening file!\n");
delete[] timings;
return uORB::ERROR;
return PX4_ERROR;
}
for (unsigned i = 0; i < maxruns; i++) {
@ -148,7 +148,7 @@ int uORBTest::UnitTest::pubsublatency_main() @@ -148,7 +148,7 @@ int uORBTest::UnitTest::pubsublatency_main()
pubsubtest_passed = true;
if (static_cast<float>(latency_integral / maxruns) > 100.0f) {
pubsubtest_res = uORB::ERROR;
pubsubtest_res = PX4_ERROR;
} else {
pubsubtest_res = PX4_OK;
@ -825,7 +825,8 @@ int uORBTest::UnitTest::test_fail(const char *fmt, ...) @@ -825,7 +825,8 @@ int uORBTest::UnitTest::test_fail(const char *fmt, ...)
va_end(ap);
fprintf(stderr, "\n");
fflush(stderr);
return uORB::ERROR;
return PX4_ERROR;
}
int uORBTest::UnitTest::test_note(const char *fmt, ...)

Loading…
Cancel
Save