AP_Logger: use load_file()

save a bit of flash
This commit is contained in:
Andrew Tridgell 2020-11-13 11:56:29 +11:00
parent 3a0e494085
commit 6bf7f9e864
1 changed files with 4 additions and 9 deletions

View File

@ -549,15 +549,10 @@ uint16_t AP_Logger_File::find_last_log()
return ret;
}
EXPECT_DELAY_MS(3000);
int fd = AP::FS().open(fname, O_RDONLY);
free(fname);
if (fd != -1) {
char buf[10];
memset(buf, 0, sizeof(buf));
if (AP::FS().read(fd, buf, sizeof(buf)-1) > 0) {
ret = strtol(buf, NULL, 10);
}
AP::FS().close(fd);
FileData *fd = AP::FS().load_file(fname);
if (fd != nullptr) {
ret = strtol((const char *)fd->data, NULL, 10);
delete fd;
}
return ret;
}