Skip to content

Commit 3a9d22c

Browse files
authored
Handle remote UUID mismatch properly (#1590)
Check for no response Only throw if incorrect version, and not when missing Resolves #1569
1 parent 417e1a6 commit 3a9d22c

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

photon-lib/py/photonlibpy/photonCamera.py

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -298,43 +298,42 @@ def _versionCheck(self) -> None:
298298

299299
# Check mdef UUID
300300
localUUID = PhotonPipelineResult.photonStruct.MESSAGE_VERSION
301-
remoteUUID = str(self._rawBytesEntry.getTopic().getProperty("message_uuid"))
301+
remoteUUID = self._rawBytesEntry.getTopic().getProperty("message_uuid")
302302

303-
if not remoteUUID:
303+
if remoteUUID is None:
304304
wpilib.reportWarning(
305305
f"PhotonVision coprocessor at path {self._path} has not reported a message interface UUID - is your coprocessor's camera started?",
306306
True,
307307
)
308-
309-
assert isinstance(remoteUUID, str)
310-
# ntcore hands us a JSON string with leading/trailing quotes - remove those
311-
remoteUUID = remoteUUID.replace('"', "")
312-
313-
if localUUID != remoteUUID:
314-
# Verified version mismatch
315-
316-
bfw = """
317-
\n\n\n
318-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
319-
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
320-
>>>
321-
>>> You are running an incompatible version
322-
>>> of PhotonVision on your coprocessor!
323-
>>>
324-
>>> This is neither tested nor supported.
325-
>>> You MUST update PhotonVision,
326-
>>> PhotonLib, or both.
327-
>>>
328-
>>> Your code will now crash.
329-
>>> We hope your day gets better.
330-
>>>
331-
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
332-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
333-
\n\n
334-
"""
335-
336-
wpilib.reportWarning(bfw)
337-
338-
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}."
339-
wpilib.reportError(errText, True)
340-
raise Exception(errText)
308+
else:
309+
# ntcore hands us a JSON string with leading/trailing quotes - remove those
310+
remoteUUID = str(remoteUUID).replace('"', "")
311+
312+
if localUUID != remoteUUID:
313+
# Verified version mismatch
314+
315+
bfw = """
316+
\n\n\n
317+
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
318+
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
319+
>>>
320+
>>> You are running an incompatible version
321+
>>> of PhotonVision on your coprocessor!
322+
>>>
323+
>>> This is neither tested nor supported.
324+
>>> You MUST update PhotonVision,
325+
>>> PhotonLib, or both.
326+
>>>
327+
>>> Your code will now crash.
328+
>>> We hope your day gets better.
329+
>>>
330+
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
331+
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
332+
\n\n
333+
"""
334+
335+
wpilib.reportWarning(bfw)
336+
337+
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}."
338+
wpilib.reportError(errText, True)
339+
raise Exception(errText)

photon-lib/src/main/native/cpp/photon/PhotonCamera.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ void PhotonCamera::VerifyVersion() {
305305
FRC_ReportError(frc::warn::Warning,
306306
"Cannot find property message_uuid for PhotonCamera {}",
307307
path);
308+
return;
308309
}
309310
std::string remote_uuid{remote_uuid_json};
310311

0 commit comments

Comments
 (0)