mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 13:23:34 +08:00
LandDetector: use a 64bit counter for total system flight time
The previous 32bit counter wrapped in ~1.19h, this switches to 2 32bit counters, wrapping in 584942 years.
This commit is contained in:
@@ -103,7 +103,8 @@ void LandDetector::_cycle()
|
||||
_landDetected.freefall = false;
|
||||
_landDetected.landed = false;
|
||||
_landDetected.ground_contact = false;
|
||||
_p_total_flight_time = param_find("LND_FLIGHT_TIME");
|
||||
_p_total_flight_time_high = param_find("LND_FLIGHT_T_HI");
|
||||
_p_total_flight_time_low = param_find("LND_FLIGHT_T_LO");
|
||||
|
||||
// Initialize uORB topics.
|
||||
_initialize_topics();
|
||||
@@ -141,7 +142,10 @@ void LandDetector::_cycle()
|
||||
// We landed
|
||||
_total_flight_time += now - _takeoff_time;
|
||||
_takeoff_time = 0;
|
||||
param_set(_p_total_flight_time, &_total_flight_time);
|
||||
int32_t flight_time = (_total_flight_time >> 32) & 0xffffffff;
|
||||
param_set_no_notification(_p_total_flight_time_high, &flight_time);
|
||||
flight_time = _total_flight_time & 0xffffffff;
|
||||
param_set_no_notification(_p_total_flight_time_low, &flight_time);
|
||||
}
|
||||
|
||||
_landDetected.timestamp = hrt_absolute_time();
|
||||
@@ -178,7 +182,11 @@ void LandDetector::_check_params(const bool force)
|
||||
|
||||
if (updated || force) {
|
||||
_update_params();
|
||||
param_get(_p_total_flight_time, &_total_flight_time);
|
||||
int32_t flight_time;
|
||||
param_get(_p_total_flight_time_high, &flight_time);
|
||||
_total_flight_time = ((uint64_t)flight_time) << 32;
|
||||
param_get(_p_total_flight_time_low, &flight_time);
|
||||
_total_flight_time |= flight_time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user