From 428f926ac2c25aa91f47548da648517fbed7b82a Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 16 Feb 2024 16:05:47 -0500 Subject: [PATCH] Actually properly match cameras by name fr this time (#1237) Our current code matches cameras in this order (which I think is objectively wrong and stupid) - by-id (/dev/v4l/by-id/product-string) - by path (/dev/videoN) - product string/name, but ascii only - asks cscore to reconnect to cameras using `path`, which on linux is actually /dev/videoN. This isn't guaranteed to stick to a camera if you replug them weirdly at runtime. This is silly and does not consider the actual physical usb port. I propose instead, in this order: - By physical usb port path and base name - by physical usb port path and USB VID/PID - By base name only (with a toggle switch to disable this, and create a new VisionModule instead) - Give cscore /dev/video/by-path on Linux systems, pinning Photon USBCameras to a particular usb port once created. This changes lots of things so stay paranoid! --- .../components/settings/NetworkingCard.vue | 17 +- .../stores/settings/GeneralSettingsStore.ts | 4 +- photon-client/src/types/SettingTypes.ts | 1 + .../configuration/CameraConfiguration.java | 24 +- .../configuration/HardwareSettings.java | 18 ++ .../common/configuration/NetworkConfig.java | 10 +- .../vision/camera/CameraInfo.java | 26 ++ .../vision/camera/USBCameraSource.java | 10 +- .../vision/processes/VisionSourceManager.java | 283 +++++++++++------- .../common/configuration/ConfigTest.java | 27 +- .../common/configuration/SQLConfigTest.java | 4 +- .../processes/VisionSourceManagerTest.java | 10 + 12 files changed, 313 insertions(+), 121 deletions(-) diff --git a/photon-client/src/components/settings/NetworkingCard.vue b/photon-client/src/components/settings/NetworkingCard.vue index 82c6a17a1..1b3b7bb56 100644 --- a/photon-client/src/components/settings/NetworkingCard.vue +++ b/photon-client/src/components/settings/NetworkingCard.vue @@ -59,7 +59,8 @@ const settingsHaveChanged = (): boolean => { a.shouldPublishProto !== b.shouldPublishProto || a.networkManagerIface !== b.networkManagerIface || a.setStaticCommand !== b.setStaticCommand || - a.setDHCPcommand !== b.setDHCPcommand + a.setDHCPcommand !== b.setDHCPcommand || + a.matchCamerasOnlyByPath !== b.matchCamerasOnlyByPath ); }; @@ -77,6 +78,7 @@ const saveGeneralSettings = () => { setStaticCommand: tempSettingsStruct.value.setStaticCommand || "", shouldManage: tempSettingsStruct.value.shouldManage, shouldPublishProto: tempSettingsStruct.value.shouldPublishProto, + matchCamerasOnlyByPath: tempSettingsStruct.value.matchCamerasOnlyByPath, staticIp: tempSettingsStruct.value.staticIp }; @@ -137,6 +139,8 @@ watchEffect(() => {