Skip to content

Commit 166b64d

Browse files
committed
user warn usb
1 parent 39e4134 commit 166b64d

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

src/main/java/org/dpsoftware/NativeExecutor.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import com.sun.jna.platform.win32.Advapi32Util;
2525
import com.sun.jna.platform.win32.WinReg;
26-
import javafx.scene.control.Alert;
2726
import jdk.incubator.vector.IntVector;
2827
import lombok.NoArgsConstructor;
2928
import lombok.extern.slf4j.Slf4j;
@@ -539,22 +538,6 @@ public static boolean isNightLight() {
539538
return nightLightEnabled;
540539
}
541540

542-
/**
543-
* Check if user is dialout or uucp to use USB
544-
*/
545-
public static void checkUsbGroup() {
546-
try {
547-
List<String> scrProcess = runNative(Constants.USB_GRP, Constants.CMD_WAIT_DELAY);
548-
boolean isUserAbleToUseUsb = scrProcess.stream().anyMatch(s -> s.contains(Constants.USB_DIALOUT) || s.contains(Constants.USB_UUCP));
549-
if (!isUserAbleToUseUsb) {
550-
MainSingleton.getInstance().guiManager.showLocalizedAlert(Constants.USB_NOT_AVAILABLE_TITLE, Constants.USB_NOT_AVAILABLE_HEADER,
551-
Constants.USB_NOT_AVAILABLE_CONTENT, Alert.AlertType.WARNING);
552-
}
553-
} catch (Exception e) {
554-
log.warn(e.getMessage());
555-
}
556-
}
557-
558541
/**
559542
* Remove Windows registry key used to Launch Firefly Luciferin when system starts
560543
*/

src/main/java/org/dpsoftware/config/Constants.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,9 +778,6 @@ public class Constants {
778778
public static final String[] CMD_CUDA_CHECK = {"/bin/sh", "-c", "gst-inspect-1.0 nvcodec | grep cuda"};
779779
public static final String[] PING_WINDOWS = {"ping", "-n", "1"};
780780
public static final String[] PING_LINUX = {"ping", "-c", "1"};
781-
public static final String[] USB_GRP = {"id", "-Gn"};
782-
public static final String USB_DIALOUT = "dialout";
783-
public static final String USB_UUCP = "uucp";
784781
public static final String[] CUDA_REQUIRED_PLUGINS = {"cudaupload", "cudascale", "cudaconvert", "cudadownload"};
785782
public static final String OBJPATH_KDE_NIGHTLIGHT = "/org/kde/KWin/NightLight";
786783
public static final String PROP_KDE_NIGHTLIGHT = "enabled";

src/main/java/org/dpsoftware/managers/SerialManager.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import com.fazecast.jSerialComm.SerialPort;
2525
import com.fazecast.jSerialComm.SerialPortDataListener;
2626
import com.fazecast.jSerialComm.SerialPortEvent;
27+
import javafx.application.Platform;
28+
import javafx.scene.control.Alert;
2729
import lombok.extern.slf4j.Slf4j;
2830
import org.dpsoftware.MainSingleton;
2931
import org.dpsoftware.NativeExecutor;
@@ -58,6 +60,7 @@ public class SerialManager {
5860

5961
ScheduledExecutorService serialAttachScheduler = Executors.newScheduledThreadPool(1);
6062
private ScheduledFuture<?> scheduledFuture;
63+
boolean alertSent = false;
6164

6265
/**
6366
* Initialize Serial communication
@@ -70,9 +73,6 @@ public void initSerial() {
7073
* Initialize Serial communication
7174
*/
7275
public void initSerial(String portName, String baudrate) {
73-
if (NativeExecutor.isLinux()) {
74-
NativeExecutor.checkUsbGroup();
75-
}
7676
if (!MainSingleton.getInstance().config.isWirelessStream() || !portName.isEmpty()) {
7777
CommonUtility.delayMilliseconds(() -> {
7878
try {
@@ -140,6 +140,11 @@ private void openSerial(String portName, String baudrate, int readTimeout, int w
140140
MainSingleton.getInstance().output = MainSingleton.getInstance().serial.getOutputStream();
141141
listenSerialEvents();
142142
} else {
143+
if (NativeExecutor.isLinux() && !alertSent) {
144+
alertSent = true;
145+
Platform.runLater(() -> MainSingleton.getInstance().guiManager.showLocalizedAlert(Constants.USB_NOT_AVAILABLE_TITLE, Constants.USB_NOT_AVAILABLE_HEADER,
146+
Constants.USB_NOT_AVAILABLE_CONTENT, Alert.AlertType.WARNING));
147+
}
143148
MainSingleton.getInstance().communicationError = true;
144149
}
145150
}

0 commit comments

Comments
 (0)