mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-25 19:36:36 +08:00
VOXL2 specific drivers, modules, and miscellaneous support files (#22588)
This commit is contained in:
@@ -385,8 +385,13 @@ int px4muorb_add_subscriber(const char *topic_name)
|
||||
uORBCommunicator::IChannelRxHandler *rxHandler = channel->GetRxHandler();
|
||||
|
||||
if (rxHandler) {
|
||||
channel->AddRemoteSubscriber(topic_name);
|
||||
// Pick a high message rate of 1000 Hz
|
||||
if (channel->AddRemoteSubscriber(topic_name)) {
|
||||
// Only process this subscription if it is the only one for the topic.
|
||||
// Otherwise it will send some data from the queue and, most likely,
|
||||
// mess up the queue on the remote side.
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rxHandler->process_add_subscription(topic_name);
|
||||
|
||||
} else {
|
||||
@@ -476,3 +481,32 @@ int px4muorb_send_topic_data(const char *topic_name, const uint8_t *data,
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
float px4muorb_get_cpu_load(void)
|
||||
{
|
||||
|
||||
// Default value to return if the SLPI code doesn't support
|
||||
// queries for the CPU load
|
||||
float cpu_load = 0.1f;
|
||||
|
||||
uORB::ProtobufChannel *channel = uORB::ProtobufChannel::GetInstance();
|
||||
|
||||
if (channel) {
|
||||
// The method to get the CPU load from the SLPI image is to send
|
||||
// in the special code string to the add_subscription call. If it
|
||||
// isn't supported the only return values can be 0 or -1. If it is
|
||||
// supported then it will be some positive integer.
|
||||
int16_t int_cpu_load = channel->add_subscription("CPULOAD", 0);
|
||||
|
||||
if (int_cpu_load > 1) {
|
||||
// Yay! CPU Load query is supported!
|
||||
cpu_load = (float) int_cpu_load;
|
||||
}
|
||||
|
||||
} else {
|
||||
PX4_ERR("Null channel pointer in %s", __FUNCTION__);
|
||||
}
|
||||
|
||||
return cpu_load;
|
||||
}
|
||||
|
||||
@@ -132,11 +132,13 @@ public:
|
||||
_Aggregator.RegisterSendHandler(func);
|
||||
}
|
||||
|
||||
void AddRemoteSubscriber(const std::string &messageName)
|
||||
int AddRemoteSubscriber(const std::string &messageName)
|
||||
{
|
||||
int currentRemoteSubscribers;
|
||||
pthread_mutex_lock(&_rx_mutex);
|
||||
_AppsSubscriberCache[messageName]++;
|
||||
currentRemoteSubscribers = _AppsSubscriberCache[messageName]++;
|
||||
pthread_mutex_unlock(&_rx_mutex);
|
||||
return currentRemoteSubscribers;
|
||||
}
|
||||
|
||||
void RemoveRemoteSubscriber(const std::string &messageName)
|
||||
@@ -214,6 +216,8 @@ extern "C" {
|
||||
int px4muorb_remove_subscriber(const char *name) __EXPORT;
|
||||
|
||||
int px4muorb_send_topic_data(const char *name, const uint8_t *data, int data_len_in_bytes) __EXPORT;
|
||||
|
||||
float px4muorb_get_cpu_load(void) __EXPORT;
|
||||
}
|
||||
|
||||
#endif // _uORBProtobufChannel_hpp_
|
||||
|
||||
Reference in New Issue
Block a user