From b0719942f0ce39a04611204570f6510608ddc552 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 29 Nov 2023 10:10:07 -0800 Subject: [PATCH] [wpiutil] Timestamp: Report errors on Rio HMB init failure (#5974) --- wpiutil/src/main/native/cpp/timestamp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wpiutil/src/main/native/cpp/timestamp.cpp b/wpiutil/src/main/native/cpp/timestamp.cpp index 44d15faf42..e030adc81e 100644 --- a/wpiutil/src/main/native/cpp/timestamp.cpp +++ b/wpiutil/src/main/native/cpp/timestamp.cpp @@ -66,6 +66,7 @@ struct HMBHolder { hmb.reset(fpga::tHMB::create(&status)); niFpga = dlopen("libNiFpga.so", RTLD_LAZY); if (!niFpga) { + fmt::print(stderr, "Could not open libNiFpga.so\n"); hmb = nullptr; return; } @@ -74,6 +75,7 @@ struct HMBHolder { closeHmb = reinterpret_cast( dlsym(niFpga, "NiFpgaDll_CloseHmb")); if (openHmb == nullptr || closeHmb == nullptr) { + fmt::print(stderr, "Could not find HMB symbols in libNiFpga.so\n"); closeHmb = nullptr; dlclose(niFpga); hmb = nullptr; @@ -84,6 +86,7 @@ struct HMBHolder { openHmb(hmb->getSystemInterface()->getHandle(), hmbName, &hmbBufferSize, reinterpret_cast(const_cast(&hmbBuffer))); if (status != 0) { + fmt::print(stderr, "Failed to open HMB, status code {}\n", status); closeHmb = nullptr; dlclose(niFpga); hmb = nullptr; @@ -211,9 +214,9 @@ uint64_t wpi::Now() { #ifdef __FRC_ROBORIO__ // Same code as HAL_GetFPGATime() if (!hmbInitialized.test()) { - std::fputs( - "FPGA not yet configured in wpi::Now(). Time will not be correct", - stderr); + fmt::print( + stderr, + "FPGA not yet configured in wpi::Now(). Time will not be correct.\n"); std::fflush(stderr); return 1; }