mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Merge branch 'networkmanager' into dev
This commit is contained in:
@@ -105,6 +105,13 @@ public class Main {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (CurrentPlatform.equals(Platform.UNSUPPORTED)) {
|
||||
System.err.printf("Sorry, this platform is not supported. Give these details to the developers.\n%s\n", CurrentPlatform.toString());
|
||||
return;
|
||||
} else {
|
||||
System.out.printf("Starting Chameleon Vision on platform %s\n", CurrentPlatform.toString());
|
||||
}
|
||||
|
||||
handleArgs(args);
|
||||
|
||||
if (!CurrentPlatform.isRoot()) {
|
||||
|
||||
@@ -33,6 +33,10 @@ public class NetworkManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (networking == null) {
|
||||
throw new RuntimeException("Failed to detect platform!");
|
||||
}
|
||||
|
||||
List<java.net.NetworkInterface> interfaces = new ArrayList<>();
|
||||
List<NetworkInterface> goodInterfaces = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@ package com.chameleonvision.settings;
|
||||
|
||||
import com.chameleonvision.util.ShellExec;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public enum Platform {
|
||||
WINDOWS_64("Windows x64"),
|
||||
LINUX_64("Linux x64"),
|
||||
LINUX_RASPBIAN("Linux Raspbian"),
|
||||
LINUX_TEGRA("Linux For Tegra"),
|
||||
LINUX_ARM64("Linux ARM64"),
|
||||
MACOS_64("Mac OS x64"),
|
||||
UNSUPPORTED("Unsupported Platform");
|
||||
@@ -19,12 +21,15 @@ public enum Platform {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private static final String OS_NAME = System.getProperty("os.name");
|
||||
private static final String OS_ARCH = System.getProperty("os.arch");
|
||||
|
||||
public boolean isWindows() {
|
||||
return this == WINDOWS_64;
|
||||
}
|
||||
|
||||
public boolean isLinux() {
|
||||
return this == LINUX_64 || this == LINUX_RASPBIAN || this == LINUX_ARM64 || this == LINUX_TEGRA;
|
||||
return this == LINUX_64 || this == LINUX_RASPBIAN || this == LINUX_ARM64;
|
||||
}
|
||||
|
||||
public boolean isMac() {
|
||||
@@ -54,28 +59,39 @@ public enum Platform {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isRaspbian() {
|
||||
try (BufferedReader reader = Files.newBufferedReader(Paths.get("/etc/os-release"))) {
|
||||
String value = reader.readLine();
|
||||
return value.contains("Raspbian");
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Platform getCurrentPlatform() {
|
||||
var osName = System.getProperty("os.name");
|
||||
var osArch = System.getProperty("os.arch");
|
||||
|
||||
if (osName.contains("Windows")) {
|
||||
if (osArch.equals("amd64")) return Platform.WINDOWS_64;
|
||||
return Platform.UNSUPPORTED;
|
||||
if (OS_NAME.contains("Windows")) {
|
||||
if (OS_ARCH.equals("amd64")) return Platform.WINDOWS_64;
|
||||
}
|
||||
|
||||
if (osName.contains("Linux")) {
|
||||
if (osName.contains("Tegra")) return Platform.LINUX_TEGRA;
|
||||
if (osArch.equals("amd64")) return Platform.LINUX_64;
|
||||
if (osArch.contains("rasp")) return Platform.LINUX_RASPBIAN;
|
||||
if (osArch.contains("aarch")) return Platform.LINUX_ARM64;
|
||||
return Platform.UNSUPPORTED;
|
||||
if (OS_NAME.contains("Linux")) {
|
||||
if (OS_ARCH.equals("amd64")) return Platform.LINUX_64;
|
||||
if (isRaspbian()) return Platform.LINUX_RASPBIAN;
|
||||
if (OS_ARCH.contains("aarch")) return Platform.LINUX_ARM64;
|
||||
}
|
||||
|
||||
if (osName.contains("Mac")) {
|
||||
if (osArch.equals("amd64")) return Platform.MACOS_64;
|
||||
return Platform.UNSUPPORTED;
|
||||
if (OS_NAME.contains("Mac")) {
|
||||
if (OS_ARCH.equals("amd64")) return Platform.MACOS_64;
|
||||
}
|
||||
|
||||
System.out.printf("Unknown Platform! OS: %s, Architecture: %s", OS_NAME, OS_ARCH);
|
||||
return Platform.UNSUPPORTED;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (this.equals(UNSUPPORTED)) {
|
||||
return String.format("Unknown Platform. OS: %s, Architecture: %s", OS_NAME, OS_ARCH);
|
||||
} else {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user