loggerd: rotate if segment length is >20% longer than expected (#27193)

* loggerd: rotate if segment length is >20% expected

* add that back

* comment

---------

Co-authored-by: Comma Device <device@comma.ai>
pull/27191/head
Adeeb Shihadeh 2 years ago committed by GitHub
parent 20fb2b9bb3
commit 2ecdb2857e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      selfdrive/loggerd/loggerd.cc

@ -24,15 +24,25 @@ void logger_rotate(LoggerdState *s) {
} }
void rotate_if_needed(LoggerdState *s) { void rotate_if_needed(LoggerdState *s) {
if (s->ready_to_rotate == s->max_waiting) { // all encoders ready, trigger rotation
logger_rotate(s); bool all_ready = s->ready_to_rotate == s->max_waiting;
}
// fallback logic to prevent extremely long segments in the case of camera, encoder, etc. malfunctions
bool timed_out = false;
double tms = millis_since_boot(); double tms = millis_since_boot();
if ((tms - s->last_rotate_tms) > SEGMENT_LENGTH * 1000 && double seg_length_secs = (tms - s->last_rotate_tms) / 1000.;
(tms - s->last_camera_seen_tms) > NO_CAMERA_PATIENCE && if ((seg_length_secs > SEGMENT_LENGTH) && !LOGGERD_TEST) {
!LOGGERD_TEST) { // TODO: might be nice to put these reasons in the sentinel
LOGW("no camera packet seen. auto rotating"); if ((tms - s->last_camera_seen_tms) > NO_CAMERA_PATIENCE) {
timed_out = true;
LOGE("no camera packets seen. auto rotating");
} else if (seg_length_secs > SEGMENT_LENGTH*1.2) {
timed_out = true;
LOGE("segment too long. auto rotating");
}
}
if (all_ready || timed_out) {
logger_rotate(s); logger_rotate(s);
} }
} }

Loading…
Cancel
Save