From f1a1ffd7fc96649df2293e6337e02f25b557682c Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 25 Feb 2024 11:25:46 -0800 Subject: [PATCH] [wpiutil] Rate-limit FPGA error from Now() (#6394) --- wpiutil/src/main/native/cpp/timestamp.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/wpiutil/src/main/native/cpp/timestamp.cpp b/wpiutil/src/main/native/cpp/timestamp.cpp index dd76fb9c05..cc7e2e0f47 100644 --- a/wpiutil/src/main/native/cpp/timestamp.cpp +++ b/wpiutil/src/main/native/cpp/timestamp.cpp @@ -273,10 +273,15 @@ uint64_t wpi::Now() { if (nowUseDefaultOnFailure.test()) { return timestamp() - offset_val; } else { - fmt::print( - stderr, - "FPGA not yet configured in wpi::Now(). Time will not be correct.\n"); - std::fflush(stderr); + static uint64_t last = 0; + uint64_t cur = timestamp(); + if ((cur - last) > 100000) { + last = cur; + fmt::print(stderr, + "FPGA not yet configured in wpi::Now(). Time will not be " + "correct.\n"); + std::fflush(stderr); + } return 1; } }