[chronojump] Force sensor connect is more robust
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Force sensor connect is more robust
- Date: Fri, 20 Sep 2019 16:26:54 +0000 (UTC)
commit 8f55bd8924d14ffe5b07dbcccfa89b746fbcf152
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Sep 20 18:22:14 2019 +0200
Force sensor connect is more robust
src/gui/forceSensor.cs | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index d1f5a6d9..3cc92bbb 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -600,6 +600,9 @@ public partial class ChronoJumpWindow
//Attention: no GTK here!!
private string forceSensorCheckVersionDo()
{
+ if (portFS.BytesToRead > 0)
+ LogB.Information("check_version read possible bytes: " + portFS.ReadExisting());
+
if(! forceSensorSendCommand("get_version:", "Checking version ...", "Catched checking
version"))
return "";
@@ -619,8 +622,20 @@ public partial class ChronoJumpWindow
forceSensorOtherMessageShowSeconds = false;
forceSensorOtherMessage = str;
- //return the version without "Force_Sensor-"
- return(str.Remove(0,13));
+ /*
+ * //return the version without "Force_Sensor-"
+ * return(str.Remove(0,13));
+ * //can be problematic, once detected:
+ * //init string: ^@;Force_Sensor-0.3
+ * //Version found: [r-0.3]
+ * //so now using portFS.ReadExisting() above, and also regex and not the 0,13 positions
+ */
+
+ Match match = Regex.Match(str, @"Force_Sensor-(\d+\.\d+)");
+ if(match.Groups.Count == 1)
+ return str = match.Value;
+ else
+ return "0.3"; //if there is a problem default to 0.3
}
//Attention: no GTK here!!
@@ -645,7 +660,7 @@ public partial class ChronoJumpWindow
forceSensorOtherMessageShowSeconds = false;
forceSensorOtherMessage = str;
- return (str == "binary");
+ return (str.Contains("binary"));
}
//Attention: no GTK here!!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]