mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
log_writer_file: register hardfault handler before opening the log file
hardfault_store_filename() opens and closes a file descriptor, so if we do it before opening the log file, we need one file descriptor less
This commit is contained in:
parent
9e01842c6a
commit
ebafa5698d
@ -84,6 +84,16 @@ LogWriterFile::~LogWriterFile()
|
||||
|
||||
void LogWriterFile::start_log(const char *filename)
|
||||
{
|
||||
// register the current file with the hardfault handler: if the system crashes,
|
||||
// the hardfault handler will append the crash log to that file on the next reboot.
|
||||
// Note that we don't deregister it when closing the log, so that crashes after disarming
|
||||
// are appended as well (the same holds for crashes before arming, which can be a bit misleading)
|
||||
int ret = hardfault_store_filename(filename);
|
||||
|
||||
if (ret) {
|
||||
PX4_ERR("Failed to register ULog file to the hardfault handler (%i)", ret);
|
||||
}
|
||||
|
||||
_fd = ::open(filename, O_CREAT | O_WRONLY, PX4_O_MODE_666);
|
||||
|
||||
if (_fd < 0) {
|
||||
@ -104,17 +114,6 @@ void LogWriterFile::start_log(const char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
// register the current file with the hardfault handler: if the system crashes,
|
||||
// the hardfault handler will append the crash log to that file on the next reboot.
|
||||
// Note that we don't deregister it when closing the log, so that crashes after disarming
|
||||
// are appended as well (the same holds for crashes before arming, which can be a bit misleading)
|
||||
int ret = hardfault_store_filename(filename);
|
||||
|
||||
if (ret) {
|
||||
PX4_ERR("Failed to register ULog file to the hardfault handler (%i)", ret);
|
||||
}
|
||||
|
||||
|
||||
PX4_INFO("Opened log file: %s", filename);
|
||||
_should_run = true;
|
||||
_running = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user