mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-27 19:10:34 +08:00
console buffer: write to log as 'boot_console_output' message
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_console_buffer.h>
|
||||
#include "logger.h"
|
||||
#include "messages.h"
|
||||
#include "watchdog.h"
|
||||
@@ -53,6 +54,7 @@
|
||||
#include <uORB/topics/manual_control_setpoint.h>
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <mathlib/math/Limits.hpp>
|
||||
#include <px4_getopt.h>
|
||||
#include <px4_log.h>
|
||||
#include <px4_posix.h>
|
||||
@@ -1628,6 +1630,7 @@ void Logger::start_log_file(LogType type)
|
||||
if (type == LogType::Full) {
|
||||
write_parameters(type);
|
||||
write_perf_data(true);
|
||||
write_console_output();
|
||||
}
|
||||
write_all_add_logged_msg(type);
|
||||
_writer.set_need_reliable_transfer(false);
|
||||
@@ -1675,6 +1678,7 @@ void Logger::start_log_mavlink()
|
||||
write_formats(LogType::Full);
|
||||
write_parameters(LogType::Full);
|
||||
write_perf_data(true);
|
||||
write_console_output();
|
||||
write_all_add_logged_msg(LogType::Full);
|
||||
_writer.set_need_reliable_transfer(false);
|
||||
_writer.unselect_write_backend();
|
||||
@@ -1700,7 +1704,7 @@ struct perf_callback_data_t {
|
||||
void Logger::perf_iterate_callback(perf_counter_t handle, void *user)
|
||||
{
|
||||
perf_callback_data_t *callback_data = (perf_callback_data_t *)user;
|
||||
const int buffer_length = 256;
|
||||
const int buffer_length = 220;
|
||||
char buffer[buffer_length];
|
||||
const char *perf_name;
|
||||
|
||||
@@ -1790,6 +1794,25 @@ void Logger::write_load_output()
|
||||
_writer.set_need_reliable_transfer(false);
|
||||
}
|
||||
|
||||
void Logger::write_console_output()
|
||||
{
|
||||
const int buffer_length = 220;
|
||||
char buffer[buffer_length];
|
||||
int size = px4_console_buffer_size();
|
||||
int offset = -1;
|
||||
bool first = true;
|
||||
while (size > 0) {
|
||||
int read_size = px4_console_buffer_read(buffer, buffer_length-1, &offset);
|
||||
if (read_size <= 0) { break; }
|
||||
buffer[math::min(read_size, size)] = '\0';
|
||||
write_info_multiple(LogType::Full, "boot_console_output", buffer, !first);
|
||||
|
||||
size -= read_size;
|
||||
first = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Logger::write_format(LogType type, const orb_metadata &meta, WrittenFormats &written_formats, ulog_message_format_s& msg, int level)
|
||||
{
|
||||
if (level > 3) {
|
||||
@@ -1996,6 +2019,8 @@ void Logger::write_info_multiple(LogType type, const char *name, const char *val
|
||||
msg.msg_size = msg_size - ULOG_MSG_HEADER_LEN;
|
||||
|
||||
write_message(type, buffer, msg_size);
|
||||
} else {
|
||||
PX4_ERR("info_multiple str too long (%i), key=%s", msg.key_len, msg.key);
|
||||
}
|
||||
|
||||
_writer.unlock();
|
||||
|
||||
Reference in New Issue
Block a user