diff --git a/photon-lib/src/main/java/org/photonvision/PhotonCamera.java b/photon-lib/src/main/java/org/photonvision/PhotonCamera.java index 79269fc0ab..f202b2c520 100644 --- a/photon-lib/src/main/java/org/photonvision/PhotonCamera.java +++ b/photon-lib/src/main/java/org/photonvision/PhotonCamera.java @@ -375,28 +375,26 @@ else if (!isConnected()) { // Error on a verified version mismatch // But stay silent otherwise - String bfw = ""; - bfw += ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; - bfw += ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; - bfw += ">>> ____ _________ ____ ________ ___________ __ \n"; - bfw += ">>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / \n"; - bfw += ">>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / \n"; - bfw += ">>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ \n"; - bfw += ">>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) \n"; - bfw += ">>> \n"; - bfw += ">>> You are running an incompatible version \n"; - bfw += ">>> of PhotonVision on your coprocessor! \n"; - bfw += ">>> \n"; - bfw += ">>> This is neither tested nor supported. \n"; - bfw += ">>> You MUST update either PhotonVision, PhotonLib, or both. \n"; - bfw += ">>> \n"; - bfw += ">>> Your code will now crash. We hope your day gets better. \n"; - bfw += ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; - bfw += ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"; - - DriverStation.reportWarning("\n\n\n\n", false); + String bfw = + "\n\n\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + + ">>> ____ _________ ____ ________ ___________ __ \n" + + ">>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / \n" + + ">>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / \n" + + ">>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ \n" + + ">>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) \n" + + ">>> \n" + + ">>> You are running an incompatible version \n" + + ">>> of PhotonVision on your coprocessor! \n" + + ">>> \n" + + ">>> This is neither tested nor supported. \n" + + ">>> You MUST update either PhotonVision, PhotonLib, or both. \n" + + ">>> \n" + + ">>> Your code will now crash. We hope your day gets better. \n" + + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n"; + DriverStation.reportWarning(bfw, false); - DriverStation.reportWarning("\n\n", false); var versionMismatchMessage = "Photon version " + PhotonVersion.versionString diff --git a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp index 9d3b81482c..3ede0c3247 100644 --- a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp +++ b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp @@ -26,6 +26,8 @@ #include +#include + #include #include #include @@ -34,6 +36,29 @@ #include "PhotonVersion.h" #include "photon/dataflow/structures/Packet.h" +namespace { +static constexpr const std::string_view bfw = + "\n\n\n\n" + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + ">>> ____ _________ ____ ________ ___________ __ \n" + ">>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / \n" + ">>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / \n" + ">>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ \n" + ">>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) \n" + ">>> \n" + ">>> You are running an incompatible version \n" + ">>> of PhotonVision on your coprocessor! \n" + ">>> \n" + ">>> This is neither tested nor supported. \n" + ">>> You MUST update either PhotonVision, PhotonLib, or both. \n" + ">>> \n" + ">>> Your code will now crash. We hope your day gets better. \n" + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + "\n\n"; +} // namespace + namespace photon { constexpr const units::second_t VERSION_CHECK_INTERVAL = 5_s; @@ -200,33 +225,12 @@ void PhotonCamera::VerifyVersion() { cameraNameOutString); } } else if (!VersionMatches(versionString)) { - std::string bfw = - "\n\n\n\n" - ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" - ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" - ">>> ____ _________ ____ ________ ___________ __ \n" - ">>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / \n" - ">>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / \n" - ">>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ \n" - ">>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) \n" - ">>> \n" - ">>> You are running an incompatible version \n" - ">>> of PhotonVision on your coprocessor! \n" - ">>> \n" - ">>> This is neither tested nor supported. \n" - ">>> You MUST update either PhotonVision, PhotonLib, or both. \n" - ">>> \n" - ">>> Your code will now crash. We hope your day gets better. \n" - ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" - ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" - "\n\n"; - FRC_ReportError(frc::warn::Warning, bfw); - FRC_ReportError(frc::err::Error, - "Photon version {} does not match coprocessor version {}!", - PhotonVersion::versionString, versionString); - throw std::runtime_error( - "PhotonVision Coprocessor and PhotonLib Version Mismatch!"); + std::string error_str = fmt::format( + "Photonlib version {} does not match coprocessor version {}!", + PhotonVersion::versionString, versionString); + FRC_ReportError(frc::err::Error, "{}", error_str); + throw std::runtime_error(error_str); } }