From 27f9a21a2c3b6717249f86f036da8d84cfae3544 Mon Sep 17 00:00:00 2001 From: Starlight220 <53231611+Starlight220@users.noreply.github.com> Date: Thu, 21 May 2020 06:57:06 +0300 Subject: [PATCH] [wpilib] Moved Watchdog output to reportWarning() (#2413) --- wpilibc/src/main/native/cpp/Watchdog.cpp | 13 +++++++++---- .../main/java/edu/wpi/first/wpilibj/Watchdog.java | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp index 1db1cf866d..69bdf71cb6 100644 --- a/wpilibc/src/main/native/cpp/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/Watchdog.cpp @@ -9,8 +9,11 @@ #include #include +#include #include +#include "frc/DriverStation.h" + using namespace frc; constexpr std::chrono::milliseconds Watchdog::kMinPrintPeriod; @@ -52,10 +55,12 @@ void Watchdog::Thread::Main() { if (now - watchdog->m_lastTimeoutPrintTime > kMinPrintPeriod) { watchdog->m_lastTimeoutPrintTime = now; if (!watchdog->m_suppressTimeoutMessage) { - wpi::outs() << "Watchdog not fed within " - << wpi::format("%.6f", - watchdog->m_timeout.count() / 1.0e9) - << "s\n"; + wpi::SmallString<128> buf; + wpi::raw_svector_ostream err(buf); + err << "Watchdog not fed within " + << wpi::format("%.6f", watchdog->m_timeout.count() / 1.0e9) + << "s\n"; + frc::DriverStation::ReportWarning(err.str()); } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java index fe5d0b98c9..afb6cbe1f8 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java @@ -227,7 +227,9 @@ public class Watchdog implements Closeable, Comparable { if (now - watchdog.m_lastTimeoutPrintTime > kMinPrintPeriod) { watchdog.m_lastTimeoutPrintTime = now; if (!watchdog.m_suppressTimeoutMessage) { - System.out.format("Watchdog not fed within %.6fs\n", watchdog.m_timeout / 1.0e6); + DriverStation.reportWarning( + String.format("Watchdog not fed within %.6fs\n", watchdog.m_timeout / 1.0e6), + false); } }