[chronojump] Don't need to check RFID port. Faster detection.
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Don't need to check RFID port. Faster detection.
- Date: Wed, 28 Jun 2017 19:08:36 +0000 (UTC)
commit 76b50b7da59860fe2d181f689690e6838f8ca867
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jun 28 20:54:31 2017 +0200
Don't need to check RFID port. Faster detection.
src/RFID.cs | 73 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 37 insertions(+), 36 deletions(-)
---
diff --git a/src/RFID.cs b/src/RFID.cs
index a95819c..d45411c 100644
--- a/src/RFID.cs
+++ b/src/RFID.cs
@@ -47,55 +47,56 @@ public class RFID
*/
//List<string> l = getPorts(false);
//LogB.Information("getPorts");
- List<string> l = new List<string>();
- l.Add(portName);
+
+ //List<string> l = new List<string>();
+ //l.Add(portName);
string lastRFID = "";
string str = "";
- if(findRFIDPort(l))
+
+ LogB.Information("portName: " + portName);
+ port = new SerialPort(portName, 9600); //for the rfid
+ port.Open();
+
+ LogB.Information("AT RFID.cs");
+ while(! stop)
{
- //don't need to open port because it's still opened
- //port.Open();
- while(! stop)
+ //str = port.ReadLine(); //don't use this because gets waiting some stop signal
+ if (port.BytesToRead > 0)
{
- LogB.Information("AT RFID.cs");
- //str = port.ReadLine(); //don't use this because gets waiting some stop
signal
- if (port.BytesToRead > 0)
- {
- str = port.ReadExisting();
- LogB.Information("No trim str" + str);
+ str = port.ReadExisting();
+ LogB.Information("No trim str" + str);
+
+ //get only the first line and trim it
+ if(str.IndexOf(Environment.NewLine) > 0)
+ str = str.Substring(0, str.IndexOf(Environment.NewLine)).Trim();
- //get only the first line and trim it
- if(str.IndexOf(Environment.NewLine) > 0)
- str = str.Substring(0,
str.IndexOf(Environment.NewLine)).Trim();
-
- LogB.Information("Yes one line and trim str" + str);
+ LogB.Information("Yes one line and trim str" + str);
- //this first line should have a 's' and 'e' (mark of 's'tart and
'e'nd of rfid)
- if(str.IndexOf('s') == 0 && str[str.Length -1] == 'e')
+ //this first line should have a 's' and 'e' (mark of 's'tart and 'e'nd of
rfid)
+ if(str.IndexOf('s') == 0 && str[str.Length -1] == 'e')
+ {
+ str = str.Substring(1, str.Length -2);
+
+ if(str != lastRFID)
{
- str = str.Substring(1, str.Length -2);
-
- if(str != lastRFID)
- {
- Captured = str;
-
- //Firing the event
- fakeButtonChange.Click();
- /*
- EventHandler handler = ChangedEvent;
- if (handler != null)
- handler(this, new EventArgs());
- */
- lastRFID = str;
- }
+ Captured = str;
+
+ //Firing the event
+ fakeButtonChange.Click();
+ /*
+ EventHandler handler = ChangedEvent;
+ if (handler != null)
+ handler(this, new EventArgs());
+ */
+ lastRFID = str;
}
}
- Thread.Sleep(100);
}
- LogB.Information("AT RFID.cs: STOPPED");
- port.Close();
+ Thread.Sleep(100);
}
+ LogB.Information("AT RFID.cs: STOPPED");
+ port.Close();
}
public void Stop()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]