mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 05:33:35 +08:00
mavlink log: ensure all critical & emergency msgs are also logged to console & ulog
Critical messages that the user sees should also go to the log file, so that the exact error (with time) can later be analyzed from the log file.
This commit is contained in:
@@ -541,7 +541,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_log_pub, "[blackbox] ERR: max files %d", MAX_NO_LOGFILE);
|
||||
mavlink_log_critical(&mavlink_log_pub, "[blackbox] ERR: max files %d", MAX_NO_LOGFILE);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -553,7 +553,7 @@ int open_log_file()
|
||||
#endif
|
||||
|
||||
if (fd < 0) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] failed: %s", log_file_name);
|
||||
mavlink_log_critical(&mavlink_log_pub, "[blackbox] failed: %s", log_file_name);
|
||||
|
||||
} else {
|
||||
mavlink_and_console_log_info(&mavlink_log_pub, "[blackbox] recording: %s", log_file_name);
|
||||
@@ -593,7 +593,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_log_pub, "[blackbox] ERR: max files %d", MAX_NO_LOGFILE);
|
||||
mavlink_log_critical(&mavlink_log_pub, "[blackbox] ERR: max files %d", MAX_NO_LOGFILE);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -605,7 +605,7 @@ int open_perf_file(const char* str)
|
||||
#endif
|
||||
|
||||
if (fd < 0) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] failed: %s", log_file_name);
|
||||
mavlink_log_critical(&mavlink_log_pub, "[blackbox] failed: %s", log_file_name);
|
||||
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ void sdlog2_start_log()
|
||||
|
||||
/* create log dir if needed */
|
||||
if (create_log_dir() != 0) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] error creating log dir");
|
||||
mavlink_log_critical(&mavlink_log_pub, "[blackbox] error creating log dir");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2358,20 +2358,20 @@ int check_free_space()
|
||||
/* use statfs to determine the number of blocks left */
|
||||
FAR struct statfs statfs_buf;
|
||||
if (statfs(mountpoint, &statfs_buf) != OK) {
|
||||
mavlink_and_console_log_critical(&mavlink_log_pub, "[blackbox] no microSD card, disabling logging");
|
||||
mavlink_log_critical(&mavlink_log_pub, "[blackbox] no microSD card, disabling logging");
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
/* 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_log_pub, "[blackbox] no space on MicroSD: %u MiB",
|
||||
mavlink_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_log_pub, "[blackbox] space on MicroSD low: %u MiB",
|
||||
mavlink_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