Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version mismatch is harder to miss. #1088

Merged
merged 5 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions photon-lib/py/photonlibpy/photonCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,31 @@ 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

bfw = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a multiline string instead. Those use triple quotation marks.

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)
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";
mcm001 marked this conversation as resolved.
Show resolved Hide resolved

DriverStation.reportWarning("\n\n\n\n", false);
DriverStation.reportWarning(bfw, false);
DriverStation.reportWarning("\n\n", false);
gerth2 marked this conversation as resolved.
Show resolved Hide resolved
var versionMismatchMessage =
"Photon version "
+ PhotonVersion.versionString
+ " does not match coprocessor version "
+ versionString
+ "!",
true);
+ "!";
DriverStation.reportError(versionMismatchMessage, false);
throw new UnsupportedOperationException(versionMismatchMessage);
}
}
}
26 changes: 25 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,33 @@ void PhotonCamera::VerifyVersion() {
cameraNameOutString);
}
} else if (!VersionMatches(versionString)) {
FRC_ReportError(frc::warn::Warning,
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";
mcm001 marked this conversation as resolved.
Show resolved Hide resolved

FRC_ReportError(frc::warn::Warning, "\n\n\n\n");
FRC_ReportError(frc::warn::Warning, bfw);
FRC_ReportError(frc::warn::Warning, "\n\n");
mcm001 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading