From a8425817851816259dfdac0d64abb3fadca5f5ad Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 6 Nov 2024 21:51:31 -0500 Subject: [PATCH] Fix windows NPEs around exposure+klogs (#1529) --- .../org/photonvision/common/logging/KernelLogLogger.java | 4 ++++ .../camera/USBCameras/GenericUSBCameraSettables.java | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/photon-core/src/main/java/org/photonvision/common/logging/KernelLogLogger.java b/photon-core/src/main/java/org/photonvision/common/logging/KernelLogLogger.java index 2335e5a24f..d97ca6f466 100644 --- a/photon-core/src/main/java/org/photonvision/common/logging/KernelLogLogger.java +++ b/photon-core/src/main/java/org/photonvision/common/logging/KernelLogLogger.java @@ -65,6 +65,10 @@ public KernelLogLogger() { } public void outputNewPrintks() { + if (listener == null) { + return; + } + for (var msg : listener.getNewlines()) { // We currently set all logs to debug regardless of their actual level logger.log(msg, LogLevel.DEBUG); diff --git a/photon-core/src/main/java/org/photonvision/vision/camera/USBCameras/GenericUSBCameraSettables.java b/photon-core/src/main/java/org/photonvision/vision/camera/USBCameras/GenericUSBCameraSettables.java index 8d272d15e2..179d37502e 100644 --- a/photon-core/src/main/java/org/photonvision/vision/camera/USBCameras/GenericUSBCameraSettables.java +++ b/photon-core/src/main/java/org/photonvision/vision/camera/USBCameras/GenericUSBCameraSettables.java @@ -96,9 +96,12 @@ protected void setUpExposureProperties() { var autoExpProp = findProperty("exposure_auto", "auto_exposure"); exposureAbsProp = expProp.get(); - autoExposureProp = autoExpProp.get(); this.minExposure = exposureAbsProp.getMin(); this.maxExposure = exposureAbsProp.getMax(); + + if (autoExpProp.isPresent()) { + autoExposureProp = autoExpProp.get(); + } } public void setAllCamDefaults() { @@ -169,7 +172,7 @@ public void setAutoExposure(boolean cameraAutoExposure) { softSet("auto_exposure_bias", 0); softSet("iso_sensitivity_auto", 0); // Disable auto ISO adjustment softSet("iso_sensitivity", 0); // Manual ISO adjustment - autoExposureProp.set(PROP_AUTO_EXPOSURE_DISABLED); + if (autoExposureProp != null) autoExposureProp.set(PROP_AUTO_EXPOSURE_DISABLED); // Most cameras leave exposure time absolute at the last value from their AE // algorithm. @@ -199,7 +202,7 @@ public double getMaxExposureRaw() { public void setExposureRaw(double exposureRaw) { if (exposureRaw >= 0.0) { try { - autoExposureProp.set(PROP_AUTO_EXPOSURE_DISABLED); + if (autoExposureProp != null) autoExposureProp.set(PROP_AUTO_EXPOSURE_DISABLED); int propVal = (int) MathUtil.clamp(exposureRaw, minExposure, maxExposure);