mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-18 14:48:28 -04:00
AP_Logger: fix timestamp on log files opened before GPS lock
This commit is contained in:
parent
ffe0f338d3
commit
8e58cb993d
@ -883,6 +883,11 @@ uint16_t AP_Logger_File::start_new_log(void)
|
|||||||
write_fd_semaphore.give();
|
write_fd_semaphore.give();
|
||||||
return 0xFFFF;
|
return 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remember if we had utc time when we opened the file
|
||||||
|
uint64_t utc_usec;
|
||||||
|
_need_rtc_update = !AP::rtc().get_utc_usec(utc_usec);
|
||||||
|
|
||||||
EXPECT_DELAY_MS(3000);
|
EXPECT_DELAY_MS(3000);
|
||||||
#if HAL_OS_POSIX_IO
|
#if HAL_OS_POSIX_IO
|
||||||
_write_fd = ::open(_write_filename, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666);
|
_write_fd = ::open(_write_filename, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666);
|
||||||
@ -1058,7 +1063,24 @@ void AP_Logger_File::_io_timer(void)
|
|||||||
::fsync(_write_fd);
|
::fsync(_write_fd);
|
||||||
last_io_operation = "";
|
last_io_operation = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
||||||
|
// ChibiOS does not update mtime on writes, so if we opened
|
||||||
|
// without knowing the time we should update it later
|
||||||
|
if (_need_rtc_update) {
|
||||||
|
uint64_t utc_usec;
|
||||||
|
if (AP::rtc().get_utc_usec(utc_usec)) {
|
||||||
|
struct utimbuf t {};
|
||||||
|
t.modtime = utc_usec / (1000UL * 1000UL);
|
||||||
|
t.actime = t.modtime;
|
||||||
|
// we ignore return on utime() as there is nothing useful we can do
|
||||||
|
(void)utime(_write_filename, &t);
|
||||||
|
_need_rtc_update = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
write_fd_semaphore.give();
|
write_fd_semaphore.give();
|
||||||
hal.util->perf_end(_perf_write);
|
hal.util->perf_end(_perf_write);
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ private:
|
|||||||
int _write_fd;
|
int _write_fd;
|
||||||
char *_write_filename;
|
char *_write_filename;
|
||||||
uint32_t _last_write_ms;
|
uint32_t _last_write_ms;
|
||||||
|
bool _need_rtc_update;
|
||||||
|
|
||||||
int _read_fd;
|
int _read_fd;
|
||||||
uint16_t _read_fd_log_num;
|
uint16_t _read_fd_log_num;
|
||||||
|
Loading…
Reference in New Issue
Block a user