Skip to content

Commit

Permalink
Handle remote UUID mismatch properly (PhotonVision#1590)
Browse files Browse the repository at this point in the history
Check for no response
Only throw if incorrect version, and not when missing

Resolves PhotonVision#1569
  • Loading branch information
james-ward authored Nov 19, 2024
1 parent 417e1a6 commit 3a9d22c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
69 changes: 34 additions & 35 deletions photon-lib/py/photonlibpy/photonCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,43 +298,42 @@ def _versionCheck(self) -> None:

# Check mdef UUID
localUUID = PhotonPipelineResult.photonStruct.MESSAGE_VERSION
remoteUUID = str(self._rawBytesEntry.getTopic().getProperty("message_uuid"))
remoteUUID = self._rawBytesEntry.getTopic().getProperty("message_uuid")

if not remoteUUID:
if remoteUUID is None:
wpilib.reportWarning(
f"PhotonVision coprocessor at path {self._path} has not reported a message interface UUID - is your coprocessor's camera started?",
True,
)

assert isinstance(remoteUUID, str)
# ntcore hands us a JSON string with leading/trailing quotes - remove those
remoteUUID = remoteUUID.replace('"', "")

if localUUID != remoteUUID:
# Verified version mismatch

bfw = """
\n\n\n
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>>
>>> You are running an incompatible version
>>> of PhotonVision on your coprocessor!
>>>
>>> This is neither tested nor supported.
>>> You MUST update PhotonVision,
>>> PhotonLib, or both.
>>>
>>> Your code will now crash.
>>> We hope your day gets better.
>>>
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
\n\n
"""

wpilib.reportWarning(bfw)

errText = f"Photonlibpy version {PHOTONLIB_VERSION} (With message UUID {localUUID}) does not match coprocessor version {versionString} (with message UUID {remoteUUID}). Please install photonlibpy version {versionString}, or update your coprocessor to {PHOTONLIB_VERSION}."
wpilib.reportError(errText, True)
raise Exception(errText)
else:
# ntcore hands us a JSON string with leading/trailing quotes - remove those
remoteUUID = str(remoteUUID).replace('"', "")

if localUUID != remoteUUID:
# Verified version mismatch

bfw = """
\n\n\n
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>>
>>> You are running an incompatible version
>>> of PhotonVision on your coprocessor!
>>>
>>> This is neither tested nor supported.
>>> You MUST update PhotonVision,
>>> PhotonLib, or both.
>>>
>>> Your code will now crash.
>>> We hope your day gets better.
>>>
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
\n\n
"""

wpilib.reportWarning(bfw)

errText = f"Photonlibpy version {PHOTONLIB_VERSION} (With message UUID {localUUID}) does not match coprocessor version {versionString} (with message UUID {remoteUUID}). Please install photonlibpy version {versionString}, or update your coprocessor to {PHOTONLIB_VERSION}."
wpilib.reportError(errText, True)
raise Exception(errText)
1 change: 1 addition & 0 deletions photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ void PhotonCamera::VerifyVersion() {
FRC_ReportError(frc::warn::Warning,
"Cannot find property message_uuid for PhotonCamera {}",
path);
return;
}
std::string remote_uuid{remote_uuid_json};

Expand Down

0 comments on commit 3a9d22c

Please sign in to comment.