[chronojump] ArduinoCapture flush before each new capture



commit 6aeeaaa84c550816310c21800ea89fe29fb52cd8
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Sep 28 16:00:52 2021 +0200

    ArduinoCapture flush before each new capture

 src/execute/arduinoCapture.cs | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/execute/arduinoCapture.cs b/src/execute/arduinoCapture.cs
index 1592ce5c5..7adf1242f 100644
--- a/src/execute/arduinoCapture.cs
+++ b/src/execute/arduinoCapture.cs
@@ -185,6 +185,9 @@ public class PhotocellWirelessCapture: ArduinoCapture
 
                LogB.Information(string.Format("arduinoCapture portName: {0}, bauds: {1}", portName, bauds));
 
+               //empty the port after new capture
+               flush();
+
                /*
                   disabled start_capture
                if (! sendCommand("start_capture:", "Catched at start_capture:"))
@@ -213,17 +216,22 @@ public class PhotocellWirelessCapture: ArduinoCapture
                return true;
        }
 
+       private void flush ()
+       {
+               string str = "";
+               if (port.BytesToRead > 0)
+                       str = port.ReadExisting();
+
+               LogB.Information(string.Format("flushed: |{0}|", str));
+       }
+
        public override bool Stop()
        {
                LogB.Information("AT Capture: STOPPING");
 
                string str = "";
                //empty any pending port read to be able to read correctly the Capture ended message
-               if (port.BytesToRead > 0)
-               {
-                       str = port.ReadExisting();
-                       LogB.Information("At Stop, readed: " + str);
-               }
+               flush();
 
                /*
                   disabled end_capture


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