[chronojump] forceSensor start communication done!
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] forceSensor start communication done!
- Date: Tue, 4 Apr 2017 16:58:08 +0000 (UTC)
commit 4022b874a0354df02586087e03ab1ec11f4f967d
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Apr 4 18:57:41 2017 +0200
forceSensor start communication done!
src/gui/forceSensor.cs | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 5315165..ed666cf 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -19,6 +19,7 @@
*/
using System;
+using System.IO;
using System.IO.Ports;
using System.Threading;
using Gtk;
@@ -82,6 +83,9 @@ public partial class ChronoJumpWindow
forceThread = new Thread(new ThreadStart(forceSensorCaptureDo));
GLib.Idle.Add (new GLib.IdleHandler (pulseGTKForceSensor));
+
+ LogB.ThreadStart();
+ forceThread.Start();
}
//non GTK on this method
@@ -89,14 +93,28 @@ public partial class ChronoJumpWindow
{
SerialPort port = new SerialPort(forceSensorPortName, 115200);
port.Open();
+ Thread.Sleep(2500); //sleep to let arduino start reading
+
+ port.WriteLine("Start:-920.80:"); //Imp: note decimal is point
+ string str = "";
+ do {
+ Thread.Sleep(100); //sleep to let arduino start reading
+ str = port.ReadLine();
+ LogB.Information("init string: " + str);
+ }
+ while(! str.StartsWith("StartedOk"));
- string str;
+ str = "";
+ TextWriter writer = File.CreateText("/tmp/force.txt"); //TODO: hardcoded
while(! forceProcessFinish && ! forceProcessCancel)
{
str = port.ReadLine();
- LogB.Information("Readed: " + str);
- label_force_sensor_value.Text = str;
+ writer.WriteLine(str);
}
+ port.WriteLine("Stop");
+ writer.Flush();
+ writer.Close();
+ ((IDisposable)writer).Dispose();
port.Close();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]