mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-11 02:18:29 -04:00
Log: prevent looping forever
this happened with an empty dataflash
This commit is contained in:
parent
154c55c9dc
commit
d9f32ce5b8
@ -376,12 +376,19 @@ static int find_last_log_page(uint16_t log_number)
|
|||||||
bottom_page_filepage = top_page_filepage;
|
bottom_page_filepage = top_page_filepage;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
int16_t last_bottom_page_file;
|
||||||
top_page = bottom_page;
|
top_page = bottom_page;
|
||||||
bottom_page = bottom_page - bottom_page_filepage;
|
bottom_page = bottom_page - bottom_page_filepage;
|
||||||
if(bottom_page < 1) bottom_page = 1;
|
if(bottom_page < 1) bottom_page = 1;
|
||||||
DataFlash.StartRead(bottom_page);
|
DataFlash.StartRead(bottom_page);
|
||||||
|
last_bottom_page_file = bottom_page_file;
|
||||||
bottom_page_file = DataFlash.GetFileNumber();
|
bottom_page_file = DataFlash.GetFileNumber();
|
||||||
bottom_page_filepage = DataFlash.GetFilePage();
|
bottom_page_filepage = DataFlash.GetFilePage();
|
||||||
|
if (bottom_page_file == last_bottom_page_file &&
|
||||||
|
bottom_page_filepage == 0) {
|
||||||
|
/* no progress can be made - give up. The log may be corrupt */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} while (bottom_page_file != log_number && bottom_page != 1);
|
} while (bottom_page_file != log_number && bottom_page != 1);
|
||||||
|
|
||||||
// Deal with stepping down too far due to overwriting a file
|
// Deal with stepping down too far due to overwriting a file
|
||||||
|
Loading…
Reference in New Issue
Block a user