Skip to content

Commit

Permalink
Version mismatch is harder to miss.
Browse files Browse the repository at this point in the history
  • Loading branch information
gerth2 committed Dec 29, 2023
1 parent ef039da commit 407caa7
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 12 deletions.
31 changes: 23 additions & 8 deletions photon-lib/py/photonlibpy/photonCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
30 changes: 27 additions & 3 deletions photon-lib/src/main/java/org/photonvision/PhotonCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
25 changes: 24 additions & 1 deletion photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!" );


}
}

Expand Down

0 comments on commit 407caa7

Please sign in to comment.