Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Dec 30, 2023
1 parent a3e0502 commit 7f0f015
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 47 deletions.
40 changes: 19 additions & 21 deletions photon-lib/src/main/java/org/photonvision/PhotonCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 30 additions & 26 deletions photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <hal/FRCUsageReporting.h>

#include <string_view>

#include <frc/Errors.h>
#include <frc/Timer.h>
#include <opencv2/core.hpp>
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 7f0f015

Please sign in to comment.