mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 05:33:33 +08:00
drivers/modules: changes after mavlink_log change
The mavlink_log API changes lead to changes in all drivers/modules using it.
This commit is contained in:
+13
-22
@@ -118,10 +118,9 @@
|
||||
#include <systemlib/perf_counter.h>
|
||||
#include <systemlib/git_version.h>
|
||||
#include <systemlib/printload.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <version/version.h>
|
||||
|
||||
#include <mavlink/mavlink_log.h>
|
||||
|
||||
#include "logbuffer.h"
|
||||
#include "sdlog2_format.h"
|
||||
#include "sdlog2_messages.h"
|
||||
@@ -159,7 +158,7 @@ static int32_t _utc_offset = 0;
|
||||
#endif
|
||||
static const char *mountpoint = MOUNTPOINT;
|
||||
static const char *log_root = MOUNTPOINT "/log";
|
||||
static int mavlink_fd = -1;
|
||||
static orb_advert_t mavlink_log_pub = NULL;
|
||||
struct logbuffer_s lb;
|
||||
|
||||
/* mutex / condition to synchronize threads */
|
||||
@@ -480,7 +479,7 @@ int create_log_dir()
|
||||
}
|
||||
|
||||
/* print logging path, important to find log file later */
|
||||
mavlink_and_console_log_info(mavlink_fd, "[blackbox] %s", log_dir);
|
||||
mavlink_and_console_log_info(&mavlink_log_pub, "[blackbox] %s", log_dir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -517,7 +516,7 @@ int open_log_file()
|
||||
|
||||
if (file_number > MAX_NO_LOGFILE) {
|
||||
/* we should not end up here, either we have more than MAX_NO_LOGFILE on the SD card, or another problem */
|
||||
mavlink_and_console_log_critical(mavlink_fd, "[blackbox] ERR: max files %d", MAX_NO_LOGFILE);
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] ERR: max files %d", MAX_NO_LOGFILE);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -529,10 +528,10 @@ int open_log_file()
|
||||
#endif
|
||||
|
||||
if (fd < 0) {
|
||||
mavlink_and_console_log_critical(mavlink_fd, "[blackbox] failed: %s", log_file_name);
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] failed: %s", log_file_name);
|
||||
|
||||
} else {
|
||||
mavlink_and_console_log_info(mavlink_fd, "[blackbox] recording: %s", log_file_name);
|
||||
mavlink_and_console_log_info(&mavlink_log_pub, "[blackbox] recording: %s", log_file_name);
|
||||
}
|
||||
|
||||
return fd;
|
||||
@@ -569,7 +568,7 @@ int open_perf_file(const char* str)
|
||||
|
||||
if (file_number > MAX_NO_LOGFILE) {
|
||||
/* we should not end up here, either we have more than MAX_NO_LOGFILE on the SD card, or another problem */
|
||||
mavlink_and_console_log_critical(mavlink_fd, "[blackbox] ERR: max files %d", MAX_NO_LOGFILE);
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] ERR: max files %d", MAX_NO_LOGFILE);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -581,7 +580,7 @@ int open_perf_file(const char* str)
|
||||
#endif
|
||||
|
||||
if (fd < 0) {
|
||||
mavlink_and_console_log_critical(mavlink_fd, "[blackbox] failed: %s", log_file_name);
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] failed: %s", log_file_name);
|
||||
|
||||
}
|
||||
|
||||
@@ -710,7 +709,7 @@ void sdlog2_start_log()
|
||||
|
||||
/* create log dir if needed */
|
||||
if (create_log_dir() != 0) {
|
||||
mavlink_and_console_log_critical(mavlink_fd, "[blackbox] error creating log dir");
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] error creating log dir");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -811,7 +810,7 @@ void sdlog2_stop_log()
|
||||
/* free log buffer */
|
||||
logbuffer_free(&lb);
|
||||
|
||||
mavlink_and_console_log_info(mavlink_fd, "[blackbox] stopped (%lu drops)", skipped_count);
|
||||
mavlink_and_console_log_info(&mavlink_log_pub, "[blackbox] stopped (%lu drops)", skipped_count);
|
||||
|
||||
sdlog2_status();
|
||||
}
|
||||
@@ -925,12 +924,6 @@ bool copy_if_updated_multi(orb_id_t topic, int multi_instance, int *handle, void
|
||||
|
||||
int sdlog2_thread_main(int argc, char *argv[])
|
||||
{
|
||||
mavlink_fd = px4_open(MAVLINK_LOG_DEVICE, 0);
|
||||
|
||||
if (mavlink_fd < 0) {
|
||||
warnx("ERR: log stream, start mavlink app first");
|
||||
}
|
||||
|
||||
/* default log rate: 50 Hz */
|
||||
int32_t log_rate = 50;
|
||||
int log_buffer_size = LOG_BUFFER_SIZE_DEFAULT;
|
||||
@@ -2163,7 +2156,7 @@ void sdlog2_status()
|
||||
float seconds = ((float)(hrt_absolute_time() - start_time)) / 1000000.0f;
|
||||
|
||||
warnx("wrote %lu msgs, %4.2f MiB (average %5.3f KiB/s), skipped %lu msgs", log_msgs_written, (double)mebibytes, (double)(kibibytes / seconds), log_msgs_skipped);
|
||||
mavlink_log_info(mavlink_fd, "[blackbox] wrote %lu msgs, skipped %lu msgs", log_msgs_written, log_msgs_skipped);
|
||||
mavlink_log_info(&mavlink_log_pub, "[blackbox] wrote %lu msgs, skipped %lu msgs", log_msgs_written, log_msgs_skipped);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2187,16 +2180,14 @@ int check_free_space()
|
||||
|
||||
/* use a threshold of 50 MiB */
|
||||
if (statfs_buf.f_bavail < (px4_statfs_buf_f_bavail_t)(50 * 1024 * 1024 / statfs_buf.f_bsize)) {
|
||||
mavlink_and_console_log_critical(mavlink_fd,
|
||||
"[blackbox] no space on MicroSD: %u MiB",
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] no space on MicroSD: %u MiB",
|
||||
(unsigned int)(statfs_buf.f_bavail * statfs_buf.f_bsize) / (1024U * 1024U));
|
||||
/* we do not need a flag to remember that we sent this warning because we will exit anyway */
|
||||
return PX4_ERROR;
|
||||
|
||||
/* use a threshold of 100 MiB to send a warning */
|
||||
} else if (!space_warning_sent && statfs_buf.f_bavail < (px4_statfs_buf_f_bavail_t)(100 * 1024 * 1024 / statfs_buf.f_bsize)) {
|
||||
mavlink_and_console_log_critical(mavlink_fd,
|
||||
"[blackbox] space on MicroSD low: %u MiB",
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] space on MicroSD low: %u MiB",
|
||||
(unsigned int)(statfs_buf.f_bavail * statfs_buf.f_bsize) / (1024U * 1024U));
|
||||
/* we don't want to flood the user with warnings */
|
||||
space_warning_sent = true;
|
||||
|
||||
Reference in New Issue
Block a user