From 407caa7a9b3fe466ad20ab83f78d585995de012b Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 29 Dec 2023 14:00:29 -0600 Subject: [PATCH 1/5] Version mismatch is harder to miss. --- photon-lib/py/photonlibpy/photonCamera.py | 31 ++++++++++++++----- .../java/org/photonvision/PhotonCamera.java | 30 ++++++++++++++++-- .../main/native/cpp/photon/PhotonCamera.cpp | 25 ++++++++++++++- 3 files changed, 74 insertions(+), 12 deletions(-) diff --git a/photon-lib/py/photonlibpy/photonCamera.py b/photon-lib/py/photonlibpy/photonCamera.py index fd3e0c8660..db68c790ff 100644 --- a/photon-lib/py/photonlibpy/photonCamera.py +++ b/photon-lib/py/photonlibpy/photonCamera.py @@ -165,11 +165,26 @@ def _versionCheck(self) -> None: versionString = self.versionEntry.get(defaultValue="") if len(versionString) > 0 and versionString != PHOTONVISION_VERSION: - wpilib.reportWarning( - "Photon version " - + PHOTONVISION_VERSION - + " does not match coprocessor version " - + versionString - + f"! Please install photonlibpy version {PHOTONLIB_VERSION}", - True, - ) + # Verified version mismatch + + wpilib.reportWarning(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + wpilib.reportWarning(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + wpilib.reportWarning(">>> ____ _________ ____ ________ ___________ __ ") + wpilib.reportWarning(">>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / ") + wpilib.reportWarning(">>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / ") + wpilib.reportWarning(">>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ ") + wpilib.reportWarning(">>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) ") + wpilib.reportWarning(">>> ") + wpilib.reportWarning(">>> You are running an incompatible version ") + wpilib.reportWarning(">>> of PhotonVision on your coprocessor! ") + wpilib.reportWarning(">>> ") + wpilib.reportWarning(">>> This is neither tested nor supported. ") + wpilib.reportWarning(">>> You MUST update either PhotonVision, PhotonLib, or both. ") + wpilib.reportWarning(">>> ") + wpilib.reportWarning(">>> Your code will now crash. We hope your day gets better. ") + wpilib.reportWarning(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + wpilib.reportWarning(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + + errText = f"Photon version {PHOTONLIB_VERSION} does not match coprocessor version {versionString}. Please install photonlibpy version {PHOTONLIB_VERSION}." + wpilib.reportError(errText, True) + raise Exception(errText) diff --git a/photon-lib/src/main/java/org/photonvision/PhotonCamera.java b/photon-lib/src/main/java/org/photonvision/PhotonCamera.java index c5a704460b..79269fc0ab 100644 --- a/photon-lib/src/main/java/org/photonvision/PhotonCamera.java +++ b/photon-lib/src/main/java/org/photonvision/PhotonCamera.java @@ -374,13 +374,37 @@ else if (!isConnected()) { if (!versionString.isEmpty() && !PhotonVersion.versionMatches(versionString)) { // Error on a verified version mismatch // But stay silent otherwise - DriverStation.reportWarning( + + 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); + DriverStation.reportWarning(bfw, false); + DriverStation.reportWarning("\n\n", false); + var versionMismatchMessage = "Photon version " + PhotonVersion.versionString + " does not match coprocessor version " + versionString - + "!", - true); + + "!"; + DriverStation.reportError(versionMismatchMessage, false); + throw new UnsupportedOperationException(versionMismatchMessage); } } } diff --git a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp index 02d9b46527..5c1e2a8dbb 100644 --- a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp +++ b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp @@ -200,9 +200,32 @@ void PhotonCamera::VerifyVersion() { cameraNameOutString); } } else if (!VersionMatches(versionString)) { - FRC_ReportError(frc::warn::Warning, + + FRC_ReportError(frc::warn::Warning,"\n\n\n\n"); + FRC_ReportError(frc::warn::Warning,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + FRC_ReportError(frc::warn::Warning,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + FRC_ReportError(frc::warn::Warning,">>> ____ _________ ____ ________ ___________ __ "); + FRC_ReportError(frc::warn::Warning,">>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / "); + FRC_ReportError(frc::warn::Warning,">>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / "); + FRC_ReportError(frc::warn::Warning,">>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ "); + FRC_ReportError(frc::warn::Warning,">>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) "); + FRC_ReportError(frc::warn::Warning,">>> "); + FRC_ReportError(frc::warn::Warning,">>> You are running an incompatible version "); + FRC_ReportError(frc::warn::Warning,">>> of PhotonVision on your coprocessor! "); + FRC_ReportError(frc::warn::Warning,">>> "); + FRC_ReportError(frc::warn::Warning,">>> This is neither tested nor supported. "); + FRC_ReportError(frc::warn::Warning,">>> You MUST update either PhotonVision, PhotonLib, or both. "); + FRC_ReportError(frc::warn::Warning,">>> "); + FRC_ReportError(frc::warn::Warning,">>> Your code will now crash. We hope your day gets better. "); + FRC_ReportError(frc::warn::Warning,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + FRC_ReportError(frc::warn::Warning,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + FRC_ReportError(frc::warn::Warning,"\n\n"); + 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!" ); + + } } From 82a0f3d567cf4c5fffa8a0e505853769ddf9c281 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 29 Dec 2023 14:13:54 -0600 Subject: [PATCH 2/5] who tf has a screen that can only show 80 character rows now --- photon-lib/py/photonlibpy/photonCamera.py | 39 ++++++++------- .../main/native/cpp/photon/PhotonCamera.cpp | 47 ++++++++++--------- 2 files changed, 46 insertions(+), 40 deletions(-) diff --git a/photon-lib/py/photonlibpy/photonCamera.py b/photon-lib/py/photonlibpy/photonCamera.py index db68c790ff..ff4f5dffa2 100644 --- a/photon-lib/py/photonlibpy/photonCamera.py +++ b/photon-lib/py/photonlibpy/photonCamera.py @@ -167,23 +167,28 @@ def _versionCheck(self) -> None: if len(versionString) > 0 and versionString != PHOTONVISION_VERSION: # Verified version mismatch - wpilib.reportWarning(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") - wpilib.reportWarning(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") - wpilib.reportWarning(">>> ____ _________ ____ ________ ___________ __ ") - wpilib.reportWarning(">>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / ") - wpilib.reportWarning(">>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / ") - wpilib.reportWarning(">>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ ") - wpilib.reportWarning(">>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) ") - wpilib.reportWarning(">>> ") - wpilib.reportWarning(">>> You are running an incompatible version ") - wpilib.reportWarning(">>> of PhotonVision on your coprocessor! ") - wpilib.reportWarning(">>> ") - wpilib.reportWarning(">>> This is neither tested nor supported. ") - wpilib.reportWarning(">>> You MUST update either PhotonVision, PhotonLib, or both. ") - wpilib.reportWarning(">>> ") - wpilib.reportWarning(">>> Your code will now crash. We hope your day gets better. ") - wpilib.reportWarning(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") - wpilib.reportWarning(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + 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" + + wpilib.reportWarning("\n\n\n\n") + wpilib.reportWarning(bfw) + wpilib.reportWarning("\n\n") errText = f"Photon version {PHOTONLIB_VERSION} does not match coprocessor version {versionString}. Please install photonlibpy version {PHOTONLIB_VERSION}." wpilib.reportError(errText, True) diff --git a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp index 5c1e2a8dbb..2eb7aeb8e6 100644 --- a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp +++ b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp @@ -200,32 +200,33 @@ void PhotonCamera::VerifyVersion() { cameraNameOutString); } } else if (!VersionMatches(versionString)) { - - FRC_ReportError(frc::warn::Warning,"\n\n\n\n"); - FRC_ReportError(frc::warn::Warning,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - FRC_ReportError(frc::warn::Warning,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - FRC_ReportError(frc::warn::Warning,">>> ____ _________ ____ ________ ___________ __ "); - FRC_ReportError(frc::warn::Warning,">>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / "); - FRC_ReportError(frc::warn::Warning,">>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / "); - FRC_ReportError(frc::warn::Warning,">>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ "); - FRC_ReportError(frc::warn::Warning,">>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) "); - FRC_ReportError(frc::warn::Warning,">>> "); - FRC_ReportError(frc::warn::Warning,">>> You are running an incompatible version "); - FRC_ReportError(frc::warn::Warning,">>> of PhotonVision on your coprocessor! "); - FRC_ReportError(frc::warn::Warning,">>> "); - FRC_ReportError(frc::warn::Warning,">>> This is neither tested nor supported. "); - FRC_ReportError(frc::warn::Warning,">>> You MUST update either PhotonVision, PhotonLib, or both. "); - FRC_ReportError(frc::warn::Warning,">>> "); - FRC_ReportError(frc::warn::Warning,">>> Your code will now crash. We hope your day gets better. "); - FRC_ReportError(frc::warn::Warning,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - FRC_ReportError(frc::warn::Warning,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - FRC_ReportError(frc::warn::Warning,"\n\n"); + std::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"; + + FRC_ReportError(frc::warn::Warning, "\n\n\n\n"); + FRC_ReportError(frc::warn::Warning, bfw); + FRC_ReportError(frc::warn::Warning, "\n\n"); 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!" ); - - + throw std::runtime_error( + "PhotonVision Coprocessor and PhotonLib Version Mismatch!"); } } From e3836ed894ad861588e6b731f15de2f410ff87ef Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 29 Dec 2023 15:50:30 -0600 Subject: [PATCH 3/5] more CPP wip --- .../main/native/cpp/photon/PhotonCamera.cpp | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp index 2eb7aeb8e6..04ea38160a 100644 --- a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp +++ b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp @@ -200,27 +200,27 @@ void PhotonCamera::VerifyVersion() { cameraNameOutString); } } else if (!VersionMatches(versionString)) { - std::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"; FRC_ReportError(frc::warn::Warning, "\n\n\n\n"); - FRC_ReportError(frc::warn::Warning, bfw); + FRC_ReportError(frc::warn::Warning, + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\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" + ); FRC_ReportError(frc::warn::Warning, "\n\n"); FRC_ReportError(frc::err::Error, "Photon version {} does not match coprocessor version {}!", From a3e050220ec1ccee8914ddfde439a3af51d4d8b8 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 29 Dec 2023 16:00:42 -0600 Subject: [PATCH 4/5] more fiddling --- photon-lib/py/photonlibpy/photonCamera.py | 43 +++++++++--------- .../main/native/cpp/photon/PhotonCamera.cpp | 44 +++++++++---------- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/photon-lib/py/photonlibpy/photonCamera.py b/photon-lib/py/photonlibpy/photonCamera.py index ff4f5dffa2..187013a286 100644 --- a/photon-lib/py/photonlibpy/photonCamera.py +++ b/photon-lib/py/photonlibpy/photonCamera.py @@ -167,28 +167,29 @@ def _versionCheck(self) -> None: if len(versionString) > 0 and versionString != PHOTONVISION_VERSION: # Verified version mismatch - 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" - - wpilib.reportWarning("\n\n\n\n") + bfw = """ + \n\n\n + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + >>> ____ _________ ____ ________ ___________ __ + >>> / __ \\/ ____/ | / __ \\ /_ __/ / / / _/ ___/ / / + >>> / /_/ / __/ / /| | / / / / / / / /_/ // / \\__ \\ / / + >>> / _, _/ /___/ ___ |/ /_/ / / / / __ // / ___/ / /_/ + >>>/_/ |_/_____/_/ |_/_____/ /_/ /_/ /_/___//____/ (_) + >>> + >>> You are running an incompatible version + >>> of PhotonVision on your coprocessor! + >>> + >>> This is neither tested nor supported. + >>> You MUST update either PhotonVision, PhotonLib, or both. + >>> + >>> Your code will now crash. We hope your day gets better. + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + \n\n + """ + wpilib.reportWarning(bfw) - wpilib.reportWarning("\n\n") errText = f"Photon version {PHOTONLIB_VERSION} does not match coprocessor version {versionString}. Please install photonlibpy version {PHOTONLIB_VERSION}." wpilib.reportError(errText, True) diff --git a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp index 04ea38160a..9d3b81482c 100644 --- a/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp +++ b/photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp @@ -200,28 +200,28 @@ void PhotonCamera::VerifyVersion() { cameraNameOutString); } } else if (!VersionMatches(versionString)) { - - FRC_ReportError(frc::warn::Warning, "\n\n\n\n"); - FRC_ReportError(frc::warn::Warning, - ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\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" - ); - FRC_ReportError(frc::warn::Warning, "\n\n"); + 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); From 7f0f01511e95fef31e06a1534841957d3f21a748 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 30 Dec 2023 02:52:07 -0800 Subject: [PATCH 5/5] Address review comments --- .../java/org/photonvision/PhotonCamera.java | 40 +++++++------ .../main/native/cpp/photon/PhotonCamera.cpp | 56 ++++++++++--------- 2 files changed, 49 insertions(+), 47 deletions(-) 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); } }