[chronojump] Better handling of ports on Windows



commit 75865b1c35dc4d0a76b93e0ea79ed9329f4aee32
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Oct 24 16:59:19 2016 +0200

    Better handling of ports on Windows

 diagrams/classes/chronopicConnection-1-6-3.dia |  Bin 4258 -> 4307 bytes
 src/chronopic2016.cs                           |   13 +++++++++++++
 src/gui/chronojump.cs                          |   13 +++++++++++--
 3 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/diagrams/classes/chronopicConnection-1-6-3.dia b/diagrams/classes/chronopicConnection-1-6-3.dia
index 1378f49..a6b2ab2 100644
Binary files a/diagrams/classes/chronopicConnection-1-6-3.dia and 
b/diagrams/classes/chronopicConnection-1-6-3.dia differ
diff --git a/src/chronopic2016.cs b/src/chronopic2016.cs
index b1a9aa1..17a003a 100644
--- a/src/chronopic2016.cs
+++ b/src/chronopic2016.cs
@@ -188,6 +188,19 @@ public class Chronopic2016
                return false;
        }
 
+       //check if last connected real port exists on getFiles()
+       public bool WindowsLastConnectedRealExists()
+       {
+               if(lastConnectedRealPort == null || lastConnectedRealPort == "")
+                       return false;
+
+               foreach(string port in ChronopicPorts.GetPorts())
+                       if(port == lastConnectedRealPort)
+                               return true;
+
+               return false;
+       }
+
        public bool StoredCanCaptureContacts; //store a boolean in order to read info faster
 
        //<-----ConnectContactsReal END -----
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 1877118..d5017f2 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3625,9 +3625,14 @@ public partial class ChronoJumpWindow
 
        void on_button_execute_test_clicked (object o, EventArgs args) 
        {
-               //on Windows check if last connected port is available with chronopicRegister getPorts()
-               if(! UtilAll.IsWindows())
+               if(UtilAll.IsWindows()) {
+                       //on Windows check if last connected port is available with chronopicRegister 
getPorts()
+                       bool windowsLastContactsPortExists = cp2016.WindowsLastConnectedRealExists();
+                       if( ! windowsLastContactsPortExists)
+                               chronopicRegisterUpdate(true);
+               } else {
                        chronopicRegisterUpdate(false);
+               }
 
                int numContacts = chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.CONTACTS);
                //store a boolean in order to read info faster
@@ -6766,6 +6771,10 @@ LogB.Debug("X");
        }
        private void chronopicRegisterUpdate(bool openWindow)
        {
+               //on Windows need to close the port before reading with FTDI dll
+               if(UtilAll.IsWindows())
+                       cp2016.SerialPortsCloseIfNeeded();
+
                ChronopicRegisterSelectOS cros = new ChronopicRegisterSelectOS();
                chronopicRegister = cros.Do();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]