From 32354839482012dd57058b31389ce0ae0240ecd1 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 23 Feb 2024 09:17:25 -0800 Subject: [PATCH 1/2] [wpiutil] Rate-limit FPGA error from Now() --- 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 dd76fb9c05f..eb2d37c8c28 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; } } From c8dfb67adf9a2259d8ed4d78a433a74753e43bd7 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 23 Feb 2024 09:18:41 -0800 Subject: [PATCH 2/2] Formatting --- wpiutil/src/main/native/cpp/timestamp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpiutil/src/main/native/cpp/timestamp.cpp b/wpiutil/src/main/native/cpp/timestamp.cpp index eb2d37c8c28..cc7e2e0f47a 100644 --- a/wpiutil/src/main/native/cpp/timestamp.cpp +++ b/wpiutil/src/main/native/cpp/timestamp.cpp @@ -277,9 +277,9 @@ uint64_t wpi::Now() { 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"); + fmt::print(stderr, + "FPGA not yet configured in wpi::Now(). Time will not be " + "correct.\n"); std::fflush(stderr); } return 1;