mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 02:06:27 +08:00
Merge pull request #488 from PX4/sdlog2_ver
sdlog2 version message cleanup
This commit is contained in:
@@ -90,6 +90,7 @@
|
|||||||
#include "logbuffer.h"
|
#include "logbuffer.h"
|
||||||
#include "sdlog2_format.h"
|
#include "sdlog2_format.h"
|
||||||
#include "sdlog2_messages.h"
|
#include "sdlog2_messages.h"
|
||||||
|
#include "sdlog2_version.h"
|
||||||
|
|
||||||
#define LOGBUFFER_WRITE_AND_COUNT(_msg) if (logbuffer_write(&lb, &log_msg, LOG_PACKET_SIZE(_msg))) { \
|
#define LOGBUFFER_WRITE_AND_COUNT(_msg) if (logbuffer_write(&lb, &log_msg, LOG_PACKET_SIZE(_msg))) { \
|
||||||
log_msgs_written++; \
|
log_msgs_written++; \
|
||||||
@@ -182,6 +183,10 @@ static void sdlog2_stop_log(void);
|
|||||||
*/
|
*/
|
||||||
static void write_formats(int fd);
|
static void write_formats(int fd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write version message to log file.
|
||||||
|
*/
|
||||||
|
static void write_version(int fd);
|
||||||
|
|
||||||
static bool file_exist(const char *filename);
|
static bool file_exist(const char *filename);
|
||||||
|
|
||||||
@@ -359,6 +364,9 @@ static void *logwriter_thread(void *arg)
|
|||||||
/* write log messages formats */
|
/* write log messages formats */
|
||||||
write_formats(log_file);
|
write_formats(log_file);
|
||||||
|
|
||||||
|
/* write version */
|
||||||
|
write_version(log_file);
|
||||||
|
|
||||||
int poll_count = 0;
|
int poll_count = 0;
|
||||||
|
|
||||||
void *read_ptr;
|
void *read_ptr;
|
||||||
@@ -487,14 +495,13 @@ void sdlog2_stop_log()
|
|||||||
sdlog2_status();
|
sdlog2_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void write_formats(int fd)
|
void write_formats(int fd)
|
||||||
{
|
{
|
||||||
/* construct message format packet */
|
/* construct message format packet */
|
||||||
struct {
|
struct {
|
||||||
LOG_PACKET_HEADER;
|
LOG_PACKET_HEADER;
|
||||||
struct log_format_s body;
|
struct log_format_s body;
|
||||||
} log_format_packet = {
|
} log_msg_format = {
|
||||||
LOG_PACKET_HEADER_INIT(LOG_FORMAT_MSG),
|
LOG_PACKET_HEADER_INIT(LOG_FORMAT_MSG),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -502,13 +509,33 @@ void write_formats(int fd)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < log_formats_num; i++) {
|
for (i = 0; i < log_formats_num; i++) {
|
||||||
log_format_packet.body = log_formats[i];
|
log_msg_format.body = log_formats[i];
|
||||||
log_bytes_written += write(fd, &log_format_packet, sizeof(log_format_packet));
|
log_bytes_written += write(fd, &log_msg_format, sizeof(log_msg_format));
|
||||||
}
|
}
|
||||||
|
|
||||||
fsync(fd);
|
fsync(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void write_version(int fd)
|
||||||
|
{
|
||||||
|
/* construct version message */
|
||||||
|
struct {
|
||||||
|
LOG_PACKET_HEADER;
|
||||||
|
struct log_VER_s body;
|
||||||
|
} log_msg_VER = {
|
||||||
|
LOG_PACKET_HEADER_INIT(127),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* fill message format packet for each format and write to log */
|
||||||
|
int i;
|
||||||
|
|
||||||
|
strncpy(log_msg_VER.body.fw_git, FW_GIT, sizeof(log_msg_VER.body.fw_git));
|
||||||
|
strncpy(log_msg_VER.body.arch, HW_ARCH, sizeof(log_msg_VER.body.arch));
|
||||||
|
log_bytes_written += write(fd, &log_msg_VER, sizeof(log_msg_VER));
|
||||||
|
|
||||||
|
fsync(fd);
|
||||||
|
}
|
||||||
|
|
||||||
int sdlog2_thread_main(int argc, char *argv[])
|
int sdlog2_thread_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
mavlink_fd = open(MAVLINK_LOG_DEVICE, 0);
|
mavlink_fd = open(MAVLINK_LOG_DEVICE, 0);
|
||||||
|
|||||||
@@ -253,28 +253,16 @@ struct log_GVSP_s {
|
|||||||
float vz;
|
float vz;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* --- FWRV - FIRMWARE REVISION --- */
|
/* --- VER - VERSION --- */
|
||||||
#define LOG_FWRV_MSG 20
|
#define LOG_VER_MSG 127
|
||||||
struct log_FWRV_s {
|
struct log_VER_s {
|
||||||
char fw_revision[64];
|
char arch[16];
|
||||||
|
char fw_git[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
GIT_VERSION is defined at build time via a Makefile call to the
|
|
||||||
git command line. We create a fake log message format for
|
|
||||||
the firmware revision "FWRV" that is written to every log
|
|
||||||
header. This makes it easier to determine which version
|
|
||||||
of the firmware was running when a log was created.
|
|
||||||
*/
|
|
||||||
#define FREEZE_STR(s) #s
|
|
||||||
#define STRINGIFY(s) FREEZE_STR(s)
|
|
||||||
#define FW_VERSION_STR STRINGIFY(GIT_VERSION)
|
|
||||||
|
|
||||||
/* construct list of all message formats */
|
/* construct list of all message formats */
|
||||||
|
|
||||||
static const struct log_format_s log_formats[] = {
|
static const struct log_format_s log_formats[] = {
|
||||||
LOG_FORMAT(TIME, "Q", "StartTime"),
|
LOG_FORMAT(TIME, "Q", "StartTime"),
|
||||||
LOG_FORMAT(ATT, "ffffff", "Roll,Pitch,Yaw,RollRate,PitchRate,YawRate"),
|
LOG_FORMAT(ATT, "ffffff", "Roll,Pitch,Yaw,RollRate,PitchRate,YawRate"),
|
||||||
@@ -295,7 +283,7 @@ static const struct log_format_s log_formats[] = {
|
|||||||
LOG_FORMAT(GPSP, "BLLfffbBffff", "AltRel,Lat,Lon,Alt,Yaw,LoiterR,LoiterDir,NavCmd,P1,P2,P3,P4"),
|
LOG_FORMAT(GPSP, "BLLfffbBffff", "AltRel,Lat,Lon,Alt,Yaw,LoiterR,LoiterDir,NavCmd,P1,P2,P3,P4"),
|
||||||
LOG_FORMAT(ESC, "HBBBHHHHHHfH", "Counter,NumESC,Conn,N,Ver,Adr,Volt,Amp,RPM,Temp,SetP,SetPRAW"),
|
LOG_FORMAT(ESC, "HBBBHHHHHHfH", "Counter,NumESC,Conn,N,Ver,Adr,Volt,Amp,RPM,Temp,SetP,SetPRAW"),
|
||||||
LOG_FORMAT(GVSP, "fff", "VX,VY,VZ"),
|
LOG_FORMAT(GVSP, "fff", "VX,VY,VZ"),
|
||||||
LOG_FORMAT(FWRV,"Z",FW_VERSION_STR),
|
LOG_FORMAT(VER, "NZ", "Arch,FwGit"),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int log_formats_num = sizeof(log_formats) / sizeof(struct log_format_s);
|
static const int log_formats_num = sizeof(log_formats) / sizeof(struct log_format_s);
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013 PX4 Development Team. All rights reserved.
|
||||||
|
* Author: Anton Babushkin <anton.babushkin@me.com>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file sdlog2_version.h
|
||||||
|
*
|
||||||
|
* Tools for system version detection.
|
||||||
|
*
|
||||||
|
* @author Anton Babushkin <anton.babushkin@me.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SDLOG2_VERSION_H_
|
||||||
|
#define SDLOG2_VERSION_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
GIT_VERSION is defined at build time via a Makefile call to the
|
||||||
|
git command line.
|
||||||
|
*/
|
||||||
|
#define FREEZE_STR(s) #s
|
||||||
|
#define STRINGIFY(s) FREEZE_STR(s)
|
||||||
|
#define FW_GIT STRINGIFY(GIT_VERSION)
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V1
|
||||||
|
#define HW_ARCH "PX4FMU_V1"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2
|
||||||
|
#define HW_ARCH "PX4FMU_V2"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* SDLOG2_VERSION_H_ */
|
||||||
Reference in New Issue
Block a user