[chronojump] RunEncoder checks version



commit 1b9eb1c0c8e271328e31a9b06f6c069f2579d97f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Feb 14 13:54:26 2019 +0100

    RunEncoder checks version

 src/gui/runEncoder.cs | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index 225ca38b..1364c1c6 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -100,16 +100,9 @@ public partial class ChronoJumpWindow
 
                LogB.Information(" RE connect 6: get version");
 
-               /*
                string version = runEncoderCheckVersionDo();
                LogB.Information("Version found: [" + version + "]");
 
-               if(version == "0.1")
-               {
-                       LogB.Information(" RE connect 6b, version 0.1: adjusting parameters...");
-               }
-               */
-
                portREOpened = true;
                event_execute_label_message.Text = "Connected!";
                LogB.Information(" RE connect 7: connected and adjusted!");
@@ -122,6 +115,33 @@ public partial class ChronoJumpWindow
                event_execute_label_message.Text = "Disconnected!";
        }
 
+       private string runEncoderCheckVersionDo()
+       {
+               if(! runEncoderSendCommand("get_version:", "Checking version ...", "Catched checking 
version"))
+                       return "";
+
+               string str = "";
+               do {
+                       Thread.Sleep(100); //sleep to let arduino start reading
+                       try {
+                               str = portRE.ReadLine().Trim();
+                       } catch {
+                               //forceSensorOtherMessage = "Disconnected";
+                               LogB.Information("catched! checking version");
+                               return "";
+                       }
+                       LogB.Information("init string: " + str);
+               }
+               while(! str.Contains("Race_Analyzer-"));
+
+               //forceSensorOtherMessageShowSeconds = false;
+               //forceSensorOtherMessage = str;
+
+               //return the version without "Race_Analyzer-"
+               return(str.Remove(0,14));
+       }
+
+
        //Attention: no GTK here!!
        private bool runEncoderSendCommand(string command, string displayMessage, string errorMessage)
        {


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