From 1df8ab2984084c4d54694407681e8a6dc15ee96a Mon Sep 17 00:00:00 2001 From: intvsteve Date: Sat, 2 Dec 2017 15:32:29 -0600 Subject: [PATCH 1/2] Address Issue #41 - Dialog prompt when adding non-LTO Flash! device to system. We were ignoring the directive to force device attachment when switching between devices, resulting in the device selection dialog appearing. --- INTV.LtoFlash/Model/Device.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/INTV.LtoFlash/Model/Device.cs b/INTV.LtoFlash/Model/Device.cs index e12a2bc8..d47afffc 100644 --- a/INTV.LtoFlash/Model/Device.cs +++ b/INTV.LtoFlash/Model/Device.cs @@ -569,6 +569,15 @@ public static IPeripheral GetLtoFlashDevice(IConnection connection, object state { var creationInfo = state as DeviceCreationInfo; if (creationInfo == null) + { + var stateDictionaryData = state as Dictionary; + object creationInfoObject = null; + if ((stateDictionaryData != null) && stateDictionaryData.TryGetValue(DeviceCreationInfo.ConfigName, out creationInfoObject)) + { + creationInfo = (DeviceCreationInfo)creationInfoObject; + } + } + if (creationInfo == null) { creationInfo = new DeviceCreationInfo(Properties.Settings.Default.AutomaticallyConnectToDevices, false, Properties.Settings.Default.AutomaticallyConnectToDevices ? ActivationMode.ActivateIfFirst : ActivationMode.UserSettings); } From a0b12c652bf626f9f3749ac585d51eb515778515 Mon Sep 17 00:00:00 2001 From: intvsteve Date: Sat, 2 Dec 2017 15:41:08 -0600 Subject: [PATCH 2/2] Address two related problems found when investigating issue #41: * If the only newly arrived serial ports are not *real* LTO Flash! devices, don't show the dialog * Ensure that if >1 ***LTO Flash!*** is connected, all will be available in the dialog. Added a method to really, really check the device. So if you have a ***LTO Flash!*** whose FTDI chip hasn't been configured, you'll need to manually connect to it and disable the 'only connect to validated devices' option. --- INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs b/INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs index bec0b947..1bd90816 100644 --- a/INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs +++ b/INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs @@ -457,6 +457,16 @@ internal void PromptForDeviceSelection(IList ports) { SelectionDialogShowing = true; SingleInstanceApplication.Instance.IsBusy = true; + if (!ports.Select(p => Connection.CreatePseudoConnection(p, ConnectionType.Serial)).Where(p => IsLtoFlashSerialPortConnection(p)).Any()) + { + // The newly arrived ports do does not appear to contain any LTO Flash! hardware, so skip showing the dialog. + return; + } + foreach (var additionalKnownLtoFlashPort in PotentialDevicePorts.Select(p => p.Name).Except(ports)) + { + ports.Add(additionalKnownLtoFlashPort); + } + OSWindow dialog = null; var multiSelect = ports.Count() > 1; var title = multiSelect ? Resources.Strings.SelectDeviceDialog_Title : Resources.Strings.ConnectToDevice_Title; @@ -511,6 +521,13 @@ internal void ResetCachedFileSystemsCompareResult() _cachedFileSystemsCompareResult = null; } + private static bool IsLtoFlashSerialPortConnection(IConnection connection) + { + // Always check the given connection regardless of the user setting. We *really* want to know if this is an LTO Flash! device. + var isLtoFlashPort = SerialConnectionPolicy.Instance.ExclusiveAccess(connection); + return isLtoFlashPort; + } + private static bool MessageBoxExceptionFilter(System.Exception exception) { var report = true;