Account for socketcan providing realtime timestamps
We are getting realtime timestamps back, but were treating them as
monotonic times. Fix that.
Change-Id: Ib92ced05870dcfa7a476ce2509b28eb307bda5ac
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/frc971/can_logger/asc_logger.cc b/frc971/can_logger/asc_logger.cc
index 6848938..5282d13 100644
--- a/frc971/can_logger/asc_logger.cc
+++ b/frc971/can_logger/asc_logger.cc
@@ -12,11 +12,11 @@
}
void AscLogger::HandleFrame(const CanFrame &frame) {
- if (!first_frame_monotonic_) {
- aos::monotonic_clock::time_point time(
- std::chrono::nanoseconds(frame.monotonic_timestamp_ns()));
+ if (!first_frame_realtime_) {
+ aos::realtime_clock::time_point time(
+ std::chrono::nanoseconds(frame.realtime_timestamp_ns()));
- first_frame_monotonic_ = time;
+ first_frame_realtime_ = time;
WriteHeader(output_, event_loop_->realtime_now());
}
@@ -60,11 +60,11 @@
} // namespace
void AscLogger::WriteFrame(std::ostream &file, const CanFrame &frame) {
- aos::monotonic_clock::time_point frame_timestamp(
- std::chrono::nanoseconds(frame.monotonic_timestamp_ns()));
+ aos::realtime_clock::time_point frame_timestamp(
+ std::chrono::nanoseconds(frame.realtime_timestamp_ns()));
std::chrono::duration<double> time(frame_timestamp -
- first_frame_monotonic_.value());
+ first_frame_realtime_.value());
// TODO: maybe this should not be hardcoded
const int device_id = 1;