Startup Frame should scan for available hardware #4633
maybe startup improvement or just code simplification
This commit is contained in:
parent
db1d849b45
commit
c7685a1e42
|
@ -19,7 +19,7 @@ public enum SerialPortScanner {
|
|||
|
||||
private volatile boolean isRunning = true;
|
||||
|
||||
private static final boolean SHOW_PCAN = Boolean.parseBoolean(System.getenv().get("RUSEFI_PCAN"));
|
||||
private static final boolean SHOW_PCAN = false;// todo: reimplement with wmic Boolean.parseBoolean(System.getenv().get("RUSEFI_PCAN"));
|
||||
private static final boolean SHOW_SOCKETCAN = isLinux();
|
||||
|
||||
static final String AUTO_SERIAL = "Auto Serial";
|
||||
|
@ -31,7 +31,7 @@ public enum SerialPortScanner {
|
|||
/**
|
||||
* Find all available serial ports and checks if simulator local TCP port is available
|
||||
*/
|
||||
void findAllAvailablePorts(boolean includeSlowTcpLookup) {
|
||||
private void findAllAvailablePorts(boolean includeSlowTcpLookup) {
|
||||
List<String> ports = new ArrayList<>();
|
||||
String[] serialPorts = LinkManager.getCommPorts();
|
||||
if (serialPorts.length > 0)
|
||||
|
@ -65,8 +65,10 @@ public enum SerialPortScanner {
|
|||
|
||||
public void startTimer() {
|
||||
Thread portsScanner = new Thread(() -> {
|
||||
boolean isFirstTime = true;
|
||||
while (isRunning) {
|
||||
findAllAvailablePorts(true);
|
||||
findAllAvailablePorts(!isFirstTime);
|
||||
isFirstTime = false;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class StartupFrame {
|
|||
* closing the application.
|
||||
*/
|
||||
private boolean isProceeding;
|
||||
private final JLabel noPortsMessage = new JLabel("No ports found!");
|
||||
private final JLabel noPortsMessage = new JLabel("<html>No ports found!<br>Confirm blue LED is blinking</html>");
|
||||
|
||||
public StartupFrame() {
|
||||
// AudioPlayback.start();
|
||||
|
@ -172,10 +172,6 @@ public class StartupFrame {
|
|||
|
||||
SerialPortScanner.INSTANCE.listeners.add(() -> SwingUtilities.invokeLater(this::applyKnownPorts));
|
||||
|
||||
// todo: invoke this NOT on AWT thread?
|
||||
SerialPortScanner.INSTANCE.findAllAvailablePorts(false);
|
||||
applyKnownPorts();
|
||||
|
||||
final JButton buttonLogViewer = new JButton();
|
||||
buttonLogViewer.setText("Start " + LinkManager.LOG_VIEWER);
|
||||
buttonLogViewer.addActionListener(new ActionListener() {
|
||||
|
|
Loading…
Reference in New Issue