Browse Source

uORB fix ORB_COMMUNICATOR defined sections

- keep portions of internal add/remove helpers
sbg
Daniel Agar 7 years ago committed by Lorenz Meier
parent
commit
278e4cef84
  1. 25
      src/modules/uORB/uORBDevices.cpp
  2. 6
      src/modules/uORB/uORBDevices.hpp

25
src/modules/uORB/uORBDevices.cpp

@ -161,9 +161,7 @@ uORB::DeviceNode::open(device::file_t *filp) @@ -161,9 +161,7 @@ uORB::DeviceNode::open(device::file_t *filp)
ret = CDev::open(filp);
#ifdef ORB_COMMUNICATOR
add_internal_subscriber();
#endif /* ORB_COMMUNICATOR */
if (ret != PX4_OK) {
PX4_ERR("CDev::open failed");
@ -196,9 +194,7 @@ uORB::DeviceNode::close(device::file_t *filp) @@ -196,9 +194,7 @@ uORB::DeviceNode::close(device::file_t *filp)
hrt_cancel(&sd->update_interval->update_call);
}
#ifdef ORB_COMMUNICATOR
remove_internal_subscriber();
#endif /* ORB_COMMUNICATOR */
delete sd;
sd = nullptr;
@ -737,39 +733,46 @@ uORB::DeviceNode::print_statistics(bool reset) @@ -737,39 +733,46 @@ uORB::DeviceNode::print_statistics(bool reset)
return true;
}
#ifdef ORB_COMMUNICATOR
void uORB::DeviceNode::add_internal_subscriber()
{
uORBCommunicator::IChannel *ch = uORB::Manager::get_instance()->get_uorb_communicator();
lock();
_subscriber_count++;
#ifdef ORB_COMMUNICATOR
uORBCommunicator::IChannel *ch = uORB::Manager::get_instance()->get_uorb_communicator();
if (ch != nullptr && _subscriber_count > 0) {
unlock(); //make sure we cannot deadlock if add_subscription calls back into DeviceNode
ch->add_subscription(_meta->o_name, 1);
} else {
} else
#endif /* ORB_COMMUNICATOR */
{
unlock();
}
}
void uORB::DeviceNode::remove_internal_subscriber()
{
uORBCommunicator::IChannel *ch = uORB::Manager::get_instance()->get_uorb_communicator();
lock();
_subscriber_count--;
#ifdef ORB_COMMUNICATOR
uORBCommunicator::IChannel *ch = uORB::Manager::get_instance()->get_uorb_communicator();
if (ch != nullptr && _subscriber_count == 0) {
unlock(); //make sure we cannot deadlock if remove_subscription calls back into DeviceNode
ch->remove_subscription(_meta->o_name);
} else {
} else
#endif /* ORB_COMMUNICATOR */
{
unlock();
}
}
#ifdef ORB_COMMUNICATOR
int16_t uORB::DeviceNode::process_add_subscription(int32_t rateInHz)
{
// if there is already data in the node, send this out to

6
src/modules/uORB/uORBDevices.hpp

@ -139,6 +139,7 @@ public: @@ -139,6 +139,7 @@ public:
* processed the received data message from remote.
*/
int16_t process_received_message(int32_t length, uint8_t *data);
#endif /* ORB_COMMUNICATOR */
/**
* Add the subscriber to the node's list of subscriber. If there is
@ -156,7 +157,6 @@ public: @@ -156,7 +157,6 @@ public:
* the Subscriber to be removed.
*/
void remove_internal_subscriber();
#endif /* ORB_COMMUNICATOR */
/**
* Return true if this topic has been published.
@ -182,7 +182,7 @@ public: @@ -182,7 +182,7 @@ public:
bool print_statistics(bool reset);
unsigned int get_queue_size() const { return _queue_size; }
int16_t subscriber_count() const { return _subscriber_count; }
int8_t subscriber_count() const { return _subscriber_count; }
uint32_t lost_message_count() const { return _lost_messages; }
unsigned int published_message_count() const { return _generation; }
const struct orb_metadata *get_meta() const { return _meta; }
@ -222,7 +222,7 @@ private: @@ -222,7 +222,7 @@ private:
uint8_t _priority; /**< priority of the topic */
bool _published{false}; /**< has ever data been published */
uint8_t _queue_size; /**< maximum number of elements in the queue */
int16_t _subscriber_count{0};
int8_t _subscriber_count{0};
inline static SubscriberData *filp_to_sd(device::file_t *filp);

Loading…
Cancel
Save