private void SwitchPort() { switchPort.interactable = false; try { if (!nu.IsOpening) { nu.Open(devicePath, baudrate); nu.OnUartOpenChanged += OnUartOpenChanged; } else { nu.Close(); nu.OnUartCloseChanged += OnUartCloseChanged; } } catch (Exception e) { logManager.AddMessage(LogManager.MessageType.Error, "Switch serial port error: " + e.Message); } }