diff --git a/photon-client/src/router/index.ts b/photon-client/src/router/index.ts index 37bcc2cf91..9e3e78f259 100644 --- a/photon-client/src/router/index.ts +++ b/photon-client/src/router/index.ts @@ -10,7 +10,8 @@ import NotFoundView from "@/views/NotFoundView.vue"; Vue.use(VueRouter); const router = new VueRouter({ - mode: "history", + // Using HTML5 History Mode is problematic with Javalin because each route is treated as a server endpoint which causes Javalin to return a 404 error before being redirected to the UI. + // mode: "history", base: import.meta.env.BASE_URL, routes: [ { diff --git a/photon-core/src/main/java/org/photonvision/common/networking/NetworkUtils.java b/photon-core/src/main/java/org/photonvision/common/networking/NetworkUtils.java index 91d762e205..2bcf0072a0 100644 --- a/photon-core/src/main/java/org/photonvision/common/networking/NetworkUtils.java +++ b/photon-core/src/main/java/org/photonvision/common/networking/NetworkUtils.java @@ -75,16 +75,23 @@ public String toString() { } } - public static ArrayList getAllInterfaces() { + private static List allInterfaces = new ArrayList<>(); + private static long lastReadTimestamp = 0; + + public static List getAllInterfaces() { + long now = System.currentTimeMillis(); + if (now - lastReadTimestamp < 5000) return allInterfaces; + else lastReadTimestamp = now; + var ret = new ArrayList(); if (!Platform.isLinux()) { - // Can't determine interface name on Linux, give up + // Can only determine interface name on Linux, give up return ret; } try { - var shell = new ShellExec(true, true); + var shell = new ShellExec(true, false); shell.executeBashCommand( "nmcli -t -f GENERAL.CONNECTION,GENERAL.DEVICE,GENERAL.TYPE device show"); String out = shell.getOutput(); @@ -103,6 +110,7 @@ public static ArrayList getAllInterfaces() { logger.debug("Found network interfaces:\n" + ret.toString()); + allInterfaces = ret; return ret; } diff --git a/photon-core/src/main/java/org/photonvision/vision/camera/LibcameraGpuSettables.java b/photon-core/src/main/java/org/photonvision/vision/camera/LibcameraGpuSettables.java index f3b32d44c2..22c76131aa 100644 --- a/photon-core/src/main/java/org/photonvision/vision/camera/LibcameraGpuSettables.java +++ b/photon-core/src/main/java/org/photonvision/vision/camera/LibcameraGpuSettables.java @@ -199,26 +199,27 @@ protected void setVideoModeInternal(VideoMode videoMode) { // We need to make sure that other threads don't try to do anything funny while we're recreating // the camera synchronized (LibCameraJNI.CAMERA_LOCK) { - boolean success = false; if (m_initialized) { - success |= LibCameraJNI.stopCamera(); - success |= LibCameraJNI.destroyCamera(); + logger.debug("Stopping libcamera"); + if (!LibCameraJNI.stopCamera()) { + logger.error("Couldn't stop a zero copy Pi Camera while switching video modes"); + } + logger.debug("Destroying libcamera"); + if (!LibCameraJNI.destroyCamera()) { + logger.error("Couldn't destroy a zero copy Pi Camera while switching video modes"); + } } - // if (!success) { - // throw new RuntimeException( - // "Couldn't destroy a zero copy Pi Camera while switching video modes"); - // } - - System.out.println("Starting camera"); - success |= - LibCameraJNI.createCamera( - mode.width, mode.height, (m_rotationMode == ImageRotationMode.DEG_180 ? 180 : 0)); - success |= LibCameraJNI.startCamera(); - if (!success) { - throw new RuntimeException( - "Couldn't create a zero copy Pi Camera while switching video modes"); + logger.debug("Creating libcamera"); + if (!LibCameraJNI.createCamera( + mode.width, mode.height, (m_rotationMode == ImageRotationMode.DEG_180 ? 180 : 0))) { + logger.error("Couldn't create a zero copy Pi Camera while switching video modes"); } + logger.debug("Starting libcamera"); + if (!LibCameraJNI.startCamera()) { + logger.error("Couldn't start a zero copy Pi Camera while switching video modes"); + } + m_initialized = true; } diff --git a/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceManager.java b/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceManager.java index 3d9c27046c..bcb75e7f32 100644 --- a/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceManager.java +++ b/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceManager.java @@ -326,7 +326,7 @@ private static List loadVisionSourcesFromCamConfigs( List camConfigs) { var cameraSources = new ArrayList(); for (var configuration : camConfigs) { - System.out.println("Creating VisionSource for " + configuration); + logger.debug("Creating VisionSource for " + configuration); // Picams should have csi-video in the path boolean is_picam = diff --git a/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceSettables.java b/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceSettables.java index 63e643c8bb..cda7d08e6f 100644 --- a/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceSettables.java +++ b/photon-core/src/main/java/org/photonvision/vision/processes/VisionSourceSettables.java @@ -26,7 +26,7 @@ import org.photonvision.vision.frame.FrameStaticProperties; public abstract class VisionSourceSettables { - private static final Logger logger = + protected static final Logger logger = new Logger(VisionSourceSettables.class, LogGroup.VisionModule); private final CameraConfiguration configuration; diff --git a/photon-server/src/main/java/org/photonvision/Main.java b/photon-server/src/main/java/org/photonvision/Main.java index 008dad0d54..db8787208d 100644 --- a/photon-server/src/main/java/org/photonvision/Main.java +++ b/photon-server/src/main/java/org/photonvision/Main.java @@ -344,18 +344,23 @@ public static void main(String[] args) { + Platform.getPlatformName() + (Platform.isRaspberryPi() ? (" (Pi " + PiVersion.getPiVersion() + ")") : "")); + logger.debug("Loading ConfigManager..."); ConfigManager.getInstance().load(); // init config manager ConfigManager.getInstance().requestSave(); + logger.debug("Loading HardwareManager..."); // Force load the hardware manager HardwareManager.getInstance(); + logger.debug("Loading NetworkManager..."); NetworkManager.getInstance().reinitialize(); + logger.debug("Loading NetworkTablesManager..."); NetworkTablesManager.getInstance() .setConfig(ConfigManager.getInstance().getConfig().getNetworkConfig()); if (!isTestMode) { + logger.debug("Loading VisionSourceManager..."); VisionSourceManager.getInstance() .registerLoadedConfigs( ConfigManager.getInstance().getConfig().getCameraConfigurations().values()); @@ -369,6 +374,7 @@ public static void main(String[] args) { } } + logger.info("Starting server..."); Server.start(DEFAULT_WEBPORT); } }