[chronojump] Better closing ports



commit 640b03485d5076cf40be1d8fc6d02e0bab6d5718
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Jan 1 03:12:20 2017 +0100

    Better closing ports

 src/chronopic2016.cs  |   15 ++++++++++-----
 src/gui/chronojump.cs |   14 +++++++-------
 2 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/src/chronopic2016.cs b/src/chronopic2016.cs
index 0c21873..22ec435 100644
--- a/src/chronopic2016.cs
+++ b/src/chronopic2016.cs
@@ -368,7 +368,8 @@ public class Chronopic2016
 
        // <----- change multitest firmware END
 
-       public void SerialPortsCloseIfNeeded()
+       //nullify only when exit software
+       public void SerialPortsCloseIfNeeded(bool nullify)
        {
                if(sp != null && sp.IsOpen) {
                        LogB.Information("Closing sp");
@@ -377,8 +378,10 @@ public class Chronopic2016
                        LogB.Information("Flushing cp to see if helps on OSX port busy");
                        cp.FlushByTimeOut();
 
-                       LogB.Information("Disposing cp to see if helps on OSX port busy");
-                       cp = null;
+                       if(nullify) {
+                               LogB.Information("Disposing cp to see if helps on OSX port busy");
+                               cp = null;
+                       }
                }
 
                if(sp2 != null && sp2.IsOpen) {
@@ -388,8 +391,10 @@ public class Chronopic2016
                        LogB.Information("Flushing cp2 to see if helps on OSX port busy");
                        cp2.FlushByTimeOut();
 
-                       LogB.Information("Disposing cp2 to see if helps on OSX port busy");
-                       cp2 = null;
+                       if(nullify) {
+                               LogB.Information("Disposing cp2 to see if helps on OSX port busy");
+                               cp2 = null;
+                       }
                }
        }
 
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 6b2a99e..a13162d 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2303,7 +2303,7 @@ public partial class ChronoJumpWindow
                        chronopicWin.SerialPortsCloseIfNeeded();
                }
                */
-               cp2016.SerialPortsCloseIfNeeded();
+               cp2016.SerialPortsCloseIfNeeded(true);
 
                //exit start ping if has not ended
                if(pingThread.IsAlive)
@@ -3938,7 +3938,7 @@ public partial class ChronoJumpWindow
                         * and maybe is the cause for blocking the port on OSX
                         * close the port if opened
                         */
-                       cp2016.SerialPortsCloseIfNeeded();
+                       cp2016.SerialPortsCloseIfNeeded(true);
 
                        //simulated tests are only allowed on SIMULATED session
                        if(currentSession.Name != Constants.SessionSimulatedName) {
@@ -7054,8 +7054,8 @@ 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();
+//             if(UtilAll.IsWindows())
+                       cp2016.SerialPortsCloseIfNeeded(false);
 
                ChronopicRegisterSelectOS cros = new ChronopicRegisterSelectOS();
                chronopicRegister = cros.Do();
@@ -7068,7 +7068,7 @@ LogB.Debug("X");
                if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX && 
                                chronopicRegister.Crpl.L.Count == 0)
                {
-                       cp2016.SerialPortsCloseIfNeeded();
+                       cp2016.SerialPortsCloseIfNeeded(true);
                        Thread.Sleep(250);
                        chronopicRegister = cros.Do();
                }
@@ -7083,7 +7083,7 @@ LogB.Debug("X");
 
                if(openWindow) {
                        ChronopicRegisterWindow crWin = new ChronopicRegisterWindow(app1, 
chronopicRegister.Crpl.L);
-                       crWin.FakeButtonCloseSerialPort.Clicked += new EventHandler(closeSerialPort);
+                       //crWin.FakeButtonCloseSerialPort.Clicked += new EventHandler(closeSerialPort);
                        cp2016.WindowOpened = true;
                }
        }
@@ -7091,7 +7091,7 @@ LogB.Debug("X");
        //trying to fix when an OSX disconnects and reconnects same chronopic (and it has captured)
        private void closeSerialPort (object o, EventArgs args)
        {
-               cp2016.SerialPortsCloseIfNeeded();
+               //cp2016.SerialPortsCloseIfNeeded();
        }
 
        //start/end auto mode


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