Skip to content

Commit a842581

Browse files
authored
Fix windows NPEs around exposure+klogs (#1529)
1 parent 8dcf0b3 commit a842581

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

photon-core/src/main/java/org/photonvision/common/logging/KernelLogLogger.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public KernelLogLogger() {
6565
}
6666

6767
public void outputNewPrintks() {
68+
if (listener == null) {
69+
return;
70+
}
71+
6872
for (var msg : listener.getNewlines()) {
6973
// We currently set all logs to debug regardless of their actual level
7074
logger.log(msg, LogLevel.DEBUG);

photon-core/src/main/java/org/photonvision/vision/camera/USBCameras/GenericUSBCameraSettables.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ protected void setUpExposureProperties() {
9696
var autoExpProp = findProperty("exposure_auto", "auto_exposure");
9797

9898
exposureAbsProp = expProp.get();
99-
autoExposureProp = autoExpProp.get();
10099
this.minExposure = exposureAbsProp.getMin();
101100
this.maxExposure = exposureAbsProp.getMax();
101+
102+
if (autoExpProp.isPresent()) {
103+
autoExposureProp = autoExpProp.get();
104+
}
102105
}
103106

104107
public void setAllCamDefaults() {
@@ -169,7 +172,7 @@ public void setAutoExposure(boolean cameraAutoExposure) {
169172
softSet("auto_exposure_bias", 0);
170173
softSet("iso_sensitivity_auto", 0); // Disable auto ISO adjustment
171174
softSet("iso_sensitivity", 0); // Manual ISO adjustment
172-
autoExposureProp.set(PROP_AUTO_EXPOSURE_DISABLED);
175+
if (autoExposureProp != null) autoExposureProp.set(PROP_AUTO_EXPOSURE_DISABLED);
173176

174177
// Most cameras leave exposure time absolute at the last value from their AE
175178
// algorithm.
@@ -199,7 +202,7 @@ public double getMaxExposureRaw() {
199202
public void setExposureRaw(double exposureRaw) {
200203
if (exposureRaw >= 0.0) {
201204
try {
202-
autoExposureProp.set(PROP_AUTO_EXPOSURE_DISABLED);
205+
if (autoExposureProp != null) autoExposureProp.set(PROP_AUTO_EXPOSURE_DISABLED);
203206

204207
int propVal = (int) MathUtil.clamp(exposureRaw, minExposure, maxExposure);
205208

0 commit comments

Comments
 (0)