mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 02:23:33 +08:00
introduce uORB::PublicationQueued and transition most orb_advertise_queue usage
This commit is contained in:
@@ -35,7 +35,7 @@ set(SRCS
|
||||
conversions.c
|
||||
cpuload.c
|
||||
crc.c
|
||||
mavlink_log.c
|
||||
mavlink_log.cpp
|
||||
otp.c
|
||||
)
|
||||
|
||||
|
||||
@@ -48,9 +48,6 @@
|
||||
#include <uORB/topics/mavlink_log.h>
|
||||
#include "mavlink_log.h"
|
||||
|
||||
#define MAVLINK_LOG_QUEUE_SIZE 5
|
||||
|
||||
|
||||
__EXPORT void mavlink_vasprintf(int severity, orb_advert_t *mavlink_log_pub, const char *fmt, ...)
|
||||
{
|
||||
// TODO: add compile check for maxlen
|
||||
@@ -59,31 +56,23 @@ __EXPORT void mavlink_vasprintf(int severity, orb_advert_t *mavlink_log_pub, con
|
||||
return;
|
||||
}
|
||||
|
||||
if (mavlink_log_pub == NULL) {
|
||||
if (mavlink_log_pub == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct mavlink_log_s log_msg;
|
||||
|
||||
mavlink_log_s log_msg;
|
||||
log_msg.severity = severity;
|
||||
|
||||
log_msg.timestamp = hrt_absolute_time();
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
vsnprintf((char *)log_msg.text, sizeof(log_msg.text), fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
if (*mavlink_log_pub != NULL) {
|
||||
if (*mavlink_log_pub != nullptr) {
|
||||
orb_publish(ORB_ID(mavlink_log), *mavlink_log_pub, &log_msg);
|
||||
|
||||
} else {
|
||||
*mavlink_log_pub = orb_advertise_queue(ORB_ID(mavlink_log),
|
||||
&log_msg,
|
||||
MAVLINK_LOG_QUEUE_SIZE);
|
||||
*mavlink_log_pub = orb_advertise_queue(ORB_ID(mavlink_log), &log_msg, mavlink_log_s::ORB_QUEUE_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user