当前位置:网站首页>PX4模块设计之十五:PX4 Log设计
PX4模块设计之十五:PX4 Log设计
2022-08-01 21:08:00 【lida2003】
PX4模块设计之十五:PX4 Log设计
1. PX4 Log介绍
PX4 Log主要是用于记录飞控内部数据状态和信息,应用场景主要有以下几种:
- 黑匣子数据记录
- 模拟飞行重现
- 程序异常记录
为此,PX4 Log在设计上通过以下进行切割:
- ULog文件格式
- Logger模块
- Replay模块
- HardFault模块
2. ULog文件格式
2.1. ULog文件结构
+--------------------+
| Header |
+--------------------+
| Definitions |
+--------------------+
| Data |
+--------------------+
2.2. ULog文件头结构
文件头结构
+------------------------------------+--------------+----------------+
| 0x55 0x4c 0x6f 0x67 0x01 0x12 0x35 | 0x01 | uint64_t |
| File magic (7B) | Version (1B) | Timestamp (8B) |
+------------------------------------+--------------+----------------+
- File Magic (7 Bytes): File type indicator that reads “ULogXYZ where XYZ is the magic bytes sequence 0x01 0x12 0x35”
- Version (1 Byte): File format version (currently 1)
- Timestamp (8 Bytes): uint64_t integer that denotes when the logging started in microseconds
2.3. ULog消息结构定义
消息体中的消息头结构
struct message_header_s {
uint16_t msg_size;
uint8_t msg_type;
};
2.3.1 B: Flag Bits 消息
struct ulog_message_flag_bits_s {
struct message_header_s header; // msg_type = 'B'
uint8_t compat_flags[8];
uint8_t incompat_flags[8];
uint64_t appended_offsets[3]; // file offset(s) for appended data if appending bit is set
};
2.3.2 F: Format 消息
struct message_format_s {
struct message_header_s header; // msg_type = 'F'
char format[header.msg_size];
};
2.3.3 I: Information 消息
struct ulog_message_info_header_s {
struct message_header_s header; // msg_type = 'I'
uint8_t key_len;
char key[key_len];
char value[header.msg_size-1-key_len]
};
2.3.4 M: Multi Information 消息
struct ulog_message_info_multiple_header_s {
struct message_header_s header; // msg_type = 'M'
uint8_t is_continued; // can be used for arrays
uint8_t key_len;
char key[key_len];
char value[header.msg_size-2-key_len]
};
2.3.5 P: Parameter 消息
struct message_info_s {
struct message_header_s header; // msg_type = 'P'
uint8_t key_len;
char key[key_len];
char value[header.msg_size-1-key_len]
};
2.3.6 Q: Default Parameter 消息
struct ulog_message_parameter_default_header_s {
struct message_header_s header; // msg_type = 'Q'
uint8_t default_types;
uint8_t key_len;
char key[key_len];
char value[header.msg_size-2-key_len]
};
2.4. ULog数据结构定义
2.4.1 A: Subscription 消息
struct message_add_logged_s {
struct message_header_s header; // msg_type = 'A'
uint8_t multi_id;
uint16_t msg_id;
char message_name[header.msg_size-3];
};
2.4.2 R: Unsubscription 消息
struct message_remove_logged_s {
struct message_header_s header; // msg_type = 'R'
uint16_t msg_id;
};
2.4.3 D: Logged Data 消息
struct message_data_s {
struct message_header_s header; // msg_type = 'D'
uint16_t msg_id;
uint8_t data[header.msg_size-2];
};
2.4.4 【*】L: Logged String 消息
struct message_logging_s {
struct message_header_s header; // msg_type = 'L'
uint8_t log_level;
uint64_t timestamp;
char message[header.msg_size-9]
};
2.4.5 【*】C: Tagged Logged String 消息
struct message_logging_tagged_s {
struct message_header_s header; // msg_type = 'C'
uint8_t log_level;
uint16_t tag;
uint64_t timestamp;
char message[header.msg_size-9]
};
2.4.6 S: Synchronization 消息
struct message_sync_s {
struct message_header_s header; // msg_type = 'S'
uint8_t sync_magic[8];
};
2.4.7 O: Dropout 消息
struct message_dropout_s {
struct message_header_s header; // msg_type = 'O'
uint16_t duration;
};
2.4.8 I: Information 消息
略:与3.3 I: Information 消息共用同样的消息结构体
2.4.9 M: Multi Information 消息
略:与3.4 M: Multi Information 消息共用同样的消息结构体
2.4.10 P: Parameter 消息
略:与3.5 P: Parameter 消息共用同样的消息结构体
2.4.11 Q: Default Parameter 消息
略:与3.6 Q: Default Parameter 消息共用同样的消息结构体
3. Logger模块
pxh> logger
### Description
System logger which logs a configurable set of uORB topics and system printf messages
(`PX4_WARN` and
Usage: logger <command> [arguments...]
Commands:
start
[-m <val>] Backend mode
values: file|mavlink|all, default: all
[-x] Enable/disable logging via Aux1 RC channel
[-e] Enable logging right after start until disarm (otherwise only when armed)
[-f] Log until shutdown (implies -e)
[-t] Use date/time for naming log directories and files
[-r <val>] Log rate in Hz, 0 means unlimited rate
default: 280
[-b <val>] Log buffer size in KiB
default: 12
[-p <val>] Poll on a topic instead of running with fixed rate (Log rate and topic intervals are ignored if this i
values: <topic_name>
[-c <val>] Log rate factor (higher is faster)
default: 1.0
on start logging now, override arming (logger must be running)
off stop logging now, override arming (logger must be running)
stop
status print status info
注:模块细节后续给出进一步研究和分析。
4. Replay模块
pxh> replay
### Description
This module is used to replay ULog files.
There are 2 environment variables used for configuration: `
Usage: replay <command> [arguments...]
Commands:
start Start replay, using log file from ENV variable 'replay'
trystart Same as 'start', but silently exit if no log file given
tryapplyparams Try to apply the parameters from the log file
stop
status print status info
注:模块细节后续给出进一步研究和分析。
5. Hardfault模块
pxh> hardfault_log
### Description
Hardfault utility
Used in startup scripts to handle hardfaults
Usage: hardfault_log command
check Check if there's an uncommited hardfault
rearm Drop an uncommited hardfault
fault Generate a hardfault (this command crashes the system :)
0|1 Hardfault type: 0=divide by 0, 1=Assertion (default=0)
commit Write uncommited hardfault to /fs/microsd/fault_-1816558944.txt (and rearm, but don't reset)
count Read the reboot counter, counts the number of reboots of an uncommited hardfault (returned as the exit code of the program)
reset Reset the reboot counter
注:模块细节后续给出进一步研究和分析。
6. 参考资料
【1】PX4开源软件框架简明简介
【2】PX4 Logging
【3】PX4 ULog File Format
【4】PX4 logger模块
【5】PX4 replay模块
【6】PX4 hardfault log模块
边栏推荐
猜你喜欢
随机推荐
空间数据库开源路,超图+openGauss风起禹贡
LeetCode·每日一题·1374.生成每种字符都是奇数个的字符串·模拟
移植MQTT源码到STM32F407开发板上
360借条安全专家:陌生微信好友不要轻易加贷款推广多是诈骗
C陷阱与缺陷 第8章 建议与答案 8.1 建议
STAHL触摸屏维修一体机显示屏ET-316-TX-TFT常见故障
Protocol Buffer usage
附录A printf、varargs与stdarg A.3 stdarg.h ANSI版的varargs.h
[Chinese tree tags - CTB]
案例:MySQL主从复制与读写分离
Interview Blitz 70: What are sticky packs and half packs?How to deal with it?
string
excel高级绘图技巧100讲(二十二)-如何对不规则数据进行分列
测试开发人均年薪30w+?软件测试工程师如何进阶拿到高薪?
织梦通过数据库查询调用当前文章的留言
15 分钟带你入门 Grafana
图的邻接矩阵存储
R语言 线性回归的有关方法
C专家编程 第1章 C:穿越时空的迷雾 1.1 C语言的史前阶段
(七)《数电》——CMOS与TTL门电路








