mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 06:23:34 +08:00
write git and hw version records to log
This commit is contained in:
committed by
Lorenz Meier
parent
90ce04654d
commit
fb4d72df86
@@ -669,6 +669,7 @@ void Logger::start_log()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_writer.start_log(file_name);
|
_writer.start_log(file_name);
|
||||||
|
write_version();
|
||||||
write_formats();
|
write_formats();
|
||||||
write_parameters();
|
write_parameters();
|
||||||
_enabled = true;
|
_enabled = true;
|
||||||
@@ -707,6 +708,44 @@ void Logger::write_formats()
|
|||||||
_writer.notify();
|
_writer.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* write info message */
|
||||||
|
void Logger::write_info(const char *name, const char *value)
|
||||||
|
{
|
||||||
|
_writer.lock();
|
||||||
|
uint8_t buffer[sizeof(message_info_header_s)];
|
||||||
|
message_info_header_s *msg = reinterpret_cast<message_info_header_s *>(buffer);
|
||||||
|
msg->msg_type = static_cast<uint8_t>(MessageType::INFO);
|
||||||
|
|
||||||
|
/* construct format key (type and name) */
|
||||||
|
size_t vlen = strlen(value);
|
||||||
|
msg->key_len = snprintf(msg->key, sizeof(msg->key), "char[%d] %s", vlen, name);
|
||||||
|
size_t msg_size = sizeof(*msg) - sizeof(msg->key) + msg->key_len;
|
||||||
|
|
||||||
|
/* copy string value directly to buffer */
|
||||||
|
if (vlen < (sizeof(*msg) - msg_size)) {
|
||||||
|
memcpy(&buffer[msg_size], value, vlen);
|
||||||
|
msg_size += vlen;
|
||||||
|
|
||||||
|
msg->msg_size = msg_size - 2;
|
||||||
|
|
||||||
|
/* write message */
|
||||||
|
while (!_writer.write(buffer, msg_size)) {
|
||||||
|
/* wait if buffer is full, don't skip INFO messages */
|
||||||
|
_writer.unlock();
|
||||||
|
_writer.notify();
|
||||||
|
usleep(_log_interval);
|
||||||
|
_writer.lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* write version info messages */
|
||||||
|
void Logger::write_version()
|
||||||
|
{
|
||||||
|
write_info("ver_sw", PX4_GIT_VERSION_STR);
|
||||||
|
write_info("ver_hw", HW_ARCH);
|
||||||
|
}
|
||||||
|
|
||||||
void Logger::write_parameters()
|
void Logger::write_parameters()
|
||||||
{
|
{
|
||||||
_writer.lock();
|
_writer.lock();
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include <drivers/drv_hrt.h>
|
#include <drivers/drv_hrt.h>
|
||||||
#include <uORB/Subscription.hpp>
|
#include <uORB/Subscription.hpp>
|
||||||
#include <uORB/topics/vehicle_status.h>
|
#include <uORB/topics/vehicle_status.h>
|
||||||
|
#include <version/version.h>
|
||||||
|
#include <systemlib/git_version.h>
|
||||||
|
|
||||||
extern "C" __EXPORT int logger_main(int argc, char *argv[]);
|
extern "C" __EXPORT int logger_main(int argc, char *argv[]);
|
||||||
|
|
||||||
@@ -68,6 +70,10 @@ private:
|
|||||||
|
|
||||||
void write_formats();
|
void write_formats();
|
||||||
|
|
||||||
|
void write_version();
|
||||||
|
|
||||||
|
void write_info(const char *name, const char *value);
|
||||||
|
|
||||||
void write_parameters();
|
void write_parameters();
|
||||||
|
|
||||||
bool copy_if_updated_multi(orb_id_t topic, int multi_instance, int *handle, void *buffer, uint64_t *time_last_checked);
|
bool copy_if_updated_multi(orb_id_t topic, int multi_instance, int *handle, void *buffer, uint64_t *time_last_checked);
|
||||||
|
|||||||
Reference in New Issue
Block a user