File tree Expand file tree Collapse file tree 4 files changed +17
-1
lines changed
photon-core/src/main/java/org/photonvision/common/hardware Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ public class HardwareManager {
4444 private final HardwareConfig hardwareConfig ;
4545 private final HardwareSettings hardwareSettings ;
4646
47- private final MetricsManager metricsManager ;
47+ public final MetricsManager metricsManager ;
4848
4949 @ SuppressWarnings ({"FieldCanBeLocal" , "unused" })
5050 private final StatusLED statusLED ;
Original file line number Diff line number Diff line change @@ -190,6 +190,19 @@ public double getUsedDiskPct() {
190190 }
191191 }
192192
193+ /**
194+ * Get the percentage of disk space that's available.
195+ *
196+ * @return The available disk space in bytes, or -1.0 if the command fails or parsing fails.
197+ */
198+ public double getDiskSpaceAvailable () {
199+ try {
200+ return Double .parseDouble (safeExecute (cmds .diskSpaceAvailableCommand ));
201+ } catch (NumberFormatException e ) {
202+ return -1.0 ;
203+ }
204+ }
205+
193206 // This is here so we don't spam logs if it fails
194207 boolean npuParseWarning = false ;
195208
Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ public class CmdBase {
3434 public String npuUsageCommand = "" ;
3535 // Disk
3636 public String diskUsageCommand = "" ;
37+ public String diskSpaceAvailableCommand = "" ;
38+
3739 // Uptime
3840 public String uptimeCommand = "" ;
3941
Original file line number Diff line number Diff line change @@ -36,5 +36,6 @@ public void initCmds(HardwareConfig config) {
3636
3737 // Disk
3838 diskUsageCommand = "df ./ --output=pcent | tail -n +2 | tr -d '%'" ;
39+ diskSpaceAvailableCommand = "df ./ --output=avail | tail -n +2" ;
3940 }
4041}
You can’t perform that action at this time.
0 commit comments