From 66f9f6b16229558374297834b5475ff9872d1705 Mon Sep 17 00:00:00 2001 From: Matthew Morley Date: Fri, 28 Jul 2023 08:00:09 -0700 Subject: [PATCH 1/3] Add disable-networking and clear-config command line opts --- photon-client/src/store/index.js | 1 + .../src/views/SettingsViews/Networking.vue | 19 ++++++++++++++++-- .../common/configuration/ConfigManager.java | 8 +++++++- .../common/configuration/ConfigProvider.java | 6 +++++- .../common/configuration/NetworkConfig.java | 10 +++++++--- .../configuration/PhotonConfiguration.java | 17 ++++------------ .../configuration/SqlConfigProvider.java | 1 - .../common/networking/NetworkManager.java | 3 ++- .../src/main/java/org/photonvision/Main.java | 20 +++++++++++++++++-- 9 files changed, 61 insertions(+), 24 deletions(-) diff --git a/photon-client/src/store/index.js b/photon-client/src/store/index.js index 748e20a19f..7e7ccf6129 100644 --- a/photon-client/src/store/index.js +++ b/photon-client/src/store/index.js @@ -140,6 +140,7 @@ export default new Vuex.Store({ ntServerAddress: "", supported: true, + shouldManage: true, // Below options are only configurable if supported is true connectionType: 0, // 0 = DHCP, 1 = Static staticIp: "", diff --git a/photon-client/src/views/SettingsViews/Networking.vue b/photon-client/src/views/SettingsViews/Networking.vue index 83ce709f9e..5efd93a703 100644 --- a/photon-client/src/views/SettingsViews/Networking.vue +++ b/photon-client/src/views/SettingsViews/Networking.vue @@ -23,9 +23,16 @@ > NetworkTables Server Address is unset or invalid. NetworkTables is unable to connect + toHashMap() { @JsonGetter("shouldManage") public boolean shouldManage() { - return this.shouldManage || Platform.isLinux(); + return this.shouldManage; } @JsonSetter("shouldManage") public void setShouldManage(boolean shouldManage) { - this.shouldManage = shouldManage || Platform.isLinux(); + this.shouldManage = shouldManage && this.deviceCanManageNetwork(); + } + + private boolean deviceCanManageNetwork() { + return Platform.isLinux(); } @Override diff --git a/photon-core/src/main/java/org/photonvision/common/configuration/PhotonConfiguration.java b/photon-core/src/main/java/org/photonvision/common/configuration/PhotonConfiguration.java index 1b5431571c..fccccc554f 100644 --- a/photon-core/src/main/java/org/photonvision/common/configuration/PhotonConfiguration.java +++ b/photon-core/src/main/java/org/photonvision/common/configuration/PhotonConfiguration.java @@ -55,6 +55,10 @@ public PhotonConfiguration( this.cameraConfigurations = cameraConfigurations; } + public PhotonConfiguration() { + this(new HardwareConfig(), new HardwareSettings(), new NetworkConfig()); + } + public HardwareConfig getHardwareConfig() { return hardwareConfig; } @@ -140,17 +144,4 @@ public static class UICameraConfiguration { public List> calibrations; public boolean isFovConfigurable = true; } - - @Override - public String toString() { - return "PhotonConfiguration [hardwareConfig=" - + hardwareConfig - + ", hardwareSettings=" - + hardwareSettings - + ", networkConfig=" - + networkConfig - + ", cameraConfigurations=" - + cameraConfigurations - + "]"; - } } diff --git a/photon-core/src/main/java/org/photonvision/common/configuration/SqlConfigProvider.java b/photon-core/src/main/java/org/photonvision/common/configuration/SqlConfigProvider.java index cad4325c4b..e9957eb161 100644 --- a/photon-core/src/main/java/org/photonvision/common/configuration/SqlConfigProvider.java +++ b/photon-core/src/main/java/org/photonvision/common/configuration/SqlConfigProvider.java @@ -62,7 +62,6 @@ static class TableKeys { private static final String dbName = "photon.sqlite"; private final String dbPath; - private PhotonConfiguration config; private final Object m_mutex = new Object(); private final File rootFolder; diff --git a/photon-core/src/main/java/org/photonvision/common/networking/NetworkManager.java b/photon-core/src/main/java/org/photonvision/common/networking/NetworkManager.java index 0a76b093c6..83ccd31e13 100644 --- a/photon-core/src/main/java/org/photonvision/common/networking/NetworkManager.java +++ b/photon-core/src/main/java/org/photonvision/common/networking/NetworkManager.java @@ -38,9 +38,10 @@ public static NetworkManager getInstance() { } private boolean isManaged = false; + public boolean networkingIsDisabled = false; // Passed in via CLI public void initialize(boolean shouldManage) { - isManaged = shouldManage; + isManaged = shouldManage && !networkingIsDisabled; if (!isManaged) { return; } diff --git a/photon-server/src/main/java/org/photonvision/Main.java b/photon-server/src/main/java/org/photonvision/Main.java index 7e363ac8c5..e4b0410def 100644 --- a/photon-server/src/main/java/org/photonvision/Main.java +++ b/photon-server/src/main/java/org/photonvision/Main.java @@ -80,6 +80,12 @@ private static boolean handleArgs(String[] args) throws ParseException { "ignore-cameras", true, "Ignore cameras that match a regex. Uses camera name as provided by cscore."); + options.addOption("n", "disable-networking", false, "Disables control device network settings"); + options.addOption( + "c", + "clear-config", + false, + "Clears PhotonVision pipeline and networking settings. Preserves log files"); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); @@ -109,6 +115,14 @@ private static boolean handleArgs(String[] args) throws ParseException { VisionSourceManager.getInstance() .setIgnoredCamerasRegex(cmd.getOptionValue("ignore-cameras")); } + + if (cmd.hasOption("disable-networking")) { + NetworkManager.getInstance().networkingIsDisabled = true; + } + + if (cmd.hasOption("clear-config")) { + ConfigManager.getInstance().clearConfig(); + } } return true; } @@ -313,9 +327,11 @@ public static void main(String[] args) { } try { - LibCameraJNI.forceLoad(); + if (Platform.isRaspberryPi()) { + LibCameraJNI.forceLoad(); + } } catch (IOException e) { - logger.error("Failed to load native libraries!", e); + logger.error("Failed to load libcamera-JNI!", e); } try { From bd956a9ad28f99443614731961f177888b348cdd Mon Sep 17 00:00:00 2001 From: Matthew Morley Date: Fri, 28 Jul 2023 13:13:57 -0700 Subject: [PATCH 2/3] Update index.js --- photon-client/src/store/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/photon-client/src/store/index.js b/photon-client/src/store/index.js index 7e7ccf6129..66f9588bf0 100644 --- a/photon-client/src/store/index.js +++ b/photon-client/src/store/index.js @@ -139,7 +139,6 @@ export default new Vuex.Store({ networkSettings: { ntServerAddress: "", - supported: true, shouldManage: true, // Below options are only configurable if supported is true connectionType: 0, // 0 = DHCP, 1 = Static From b6dea890fb45b3e727dc8aca72a9dcf60017ace9 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 22 Aug 2023 19:24:21 -0700 Subject: [PATCH 3/3] Update NetworkingCard.vue --- .../components/settings/NetworkingCard.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/photon-client/src/components/settings/NetworkingCard.vue b/photon-client/src/components/settings/NetworkingCard.vue index e13da815c2..ed373271c6 100644 --- a/photon-client/src/components/settings/NetworkingCard.vue +++ b/photon-client/src/components/settings/NetworkingCard.vue @@ -106,27 +106,36 @@ const saveGeneralSettings = () => { The NetworkTables Server Address is not set or is invalid. NetworkTables is unable to connect. + + Advanced Networking +