diff --git a/RFIDIdReader/RFIDIdReader.sln b/RFIDIdReader/RFIDIdReader.sln new file mode 100644 index 0000000..f2eb4f5 --- /dev/null +++ b/RFIDIdReader/RFIDIdReader.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFIDIdReader", "RFIDIdReader\RFIDIdReader.csproj", "{F23222A1-AE2D-4782-89F3-5DA054C5FEE1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RfidClass", "RfidClass\RfidClass.csproj", "{2F816B95-069B-4D48-9FBF-9B805A1049A8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F23222A1-AE2D-4782-89F3-5DA054C5FEE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F23222A1-AE2D-4782-89F3-5DA054C5FEE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F23222A1-AE2D-4782-89F3-5DA054C5FEE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F23222A1-AE2D-4782-89F3-5DA054C5FEE1}.Release|Any CPU.Build.0 = Release|Any CPU + {2F816B95-069B-4D48-9FBF-9B805A1049A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F816B95-069B-4D48-9FBF-9B805A1049A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F816B95-069B-4D48-9FBF-9B805A1049A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F816B95-069B-4D48-9FBF-9B805A1049A8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RFIDIdReader/RFIDIdReader/Program.cs b/RFIDIdReader/RFIDIdReader/Program.cs new file mode 100644 index 0000000..48ea2dd --- /dev/null +++ b/RFIDIdReader/RFIDIdReader/Program.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RfidClass; +using System.Threading; + +namespace RFIDIdReader +{ + class Program + { + private static RFIDReaderClass r; + private static bool _stop = false; + static void Main(string[] args) + { + r = new RFIDReaderClass("COM1"); + Thread t = new Thread(reader); + t.Start(); + while (!t.IsAlive) ; + char c = '0'; + while (c != 'c') + { + c = Console.ReadKey().KeyChar; + } + _stop = true; + r.abort(); + Console.WriteLine("program halt"); + + } + private static void reader() + { + while (!_stop) + { + long id = r.readKey(); + Console.WriteLine(id); + } + } + + } +} diff --git a/RFIDIdReader/RFIDIdReader/Properties/AssemblyInfo.cs b/RFIDIdReader/RFIDIdReader/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c5aea01 --- /dev/null +++ b/RFIDIdReader/RFIDIdReader/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("RFIDIdReader")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("RFIDIdReader")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("73e1ffeb-9bf6-4d47-83a6-a62a3d616dc9")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RFIDIdReader/RFIDIdReader/RFIDIdReader.csproj b/RFIDIdReader/RFIDIdReader/RFIDIdReader.csproj new file mode 100644 index 0000000..9333e9a --- /dev/null +++ b/RFIDIdReader/RFIDIdReader/RFIDIdReader.csproj @@ -0,0 +1,107 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {F23222A1-AE2D-4782-89F3-5DA054C5FEE1} + Exe + Properties + RFIDIdReader + RFIDIdReader + v4.0 + 512 + + + 3.5 + + Client + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + {2F816B95-069B-4D48-9FBF-9B805A1049A8} + RfidClass + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + \ No newline at end of file diff --git a/RFIDIdReader/RFIDIdReader/RFIDIdReader.csproj.user b/RFIDIdReader/RFIDIdReader/RFIDIdReader.csproj.user new file mode 100644 index 0000000..521cb3c --- /dev/null +++ b/RFIDIdReader/RFIDIdReader/RFIDIdReader.csproj.user @@ -0,0 +1,13 @@ + + + + + + + + + + de-DE + false + + \ No newline at end of file diff --git a/RFIDIdReader/RFIDIdReader/app.config b/RFIDIdReader/RFIDIdReader/app.config new file mode 100644 index 0000000..f76deb9 --- /dev/null +++ b/RFIDIdReader/RFIDIdReader/app.config @@ -0,0 +1,3 @@ + + + diff --git a/RFIDIdReader/RfidClass/Properties/AssemblyInfo.cs b/RFIDIdReader/RfidClass/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a6679d6 --- /dev/null +++ b/RFIDIdReader/RfidClass/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("RfidClass")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RfidClass")] +[assembly: AssemblyCopyright("Copyright © 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("eb701fb5-14a2-43f9-89c2-527a60f989fd")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RFIDIdReader/RfidClass/RFIDReaderClass.cs b/RFIDIdReader/RfidClass/RFIDReaderClass.cs new file mode 100644 index 0000000..0a44034 --- /dev/null +++ b/RFIDIdReader/RfidClass/RFIDReaderClass.cs @@ -0,0 +1,100 @@ +using System; +using System.Diagnostics; +using System.Threading; +using System.IO.Ports; +using System.Text.RegularExpressions; + +namespace RfidClass +{ + public class RFIDReaderClass + { + private Thread t; + private SerialPort s; + private long id; + private bool _stop; + private Exception e; + public RFIDReaderClass(string com) + { + this.t = new Thread(this.reader); + s = new SerialPort(com, 9600, Parity.None, 8, StopBits.One); + } + + private void reader() + { + while (!_stop) + { + Process r = new Process(); + r.StartInfo.FileName = "librfid-tool.exe"; + r.StartInfo.Arguments = "-s"; + r.StartInfo.UseShellExecute = false; + r.StartInfo.RedirectStandardOutput = true; + r.StartInfo.RedirectStandardError = true; + try + { + r.Start(); + } + catch (Exception exeption) + { + this.e = exeption; + return; + } + string a = r.StandardOutput.ReadToEnd(); + string err = r.StandardError.ReadToEnd(); + if (err.Contains("No OpenPCD found either")) + { + this.e = new Exception("No OpenPCD found"); + return; + } + if (a.Contains("Layer 2 success") && a.Contains("Protocol success")) + { + string ids = a.Substring(a.IndexOf("):")+2,13); + ids = Regex.Replace(ids.Trim(), @"[^0-9a-fA-F]", ""); + try + { + this.id = Int64.Parse(ids, System.Globalization.NumberStyles.HexNumber); + } + catch (Exception exeption) + { + this.e = exeption; + return; + } + } + Thread.Sleep(1000); + } + } + + public long readKey() + { + this.t = new Thread(this.reader); + this.id = 0; + this._stop = false; + try + { + this.s.Open(); + } + catch (Exception exeption) + { + //throw exeption; + } + this.t.Start(); + while (!this.t.IsAlive) ; + while (this.t.IsAlive) + { + if (this.id != 0 || this.e != null) + { + this._stop = true; + } + } + if (this.e != null) + { + throw this.e; + } + return this.id; + } + + public void abort() + { + this._stop = true; + } + } +} diff --git a/RFIDIdReader/RfidClass/RfidClass.csproj b/RFIDIdReader/RfidClass/RfidClass.csproj new file mode 100644 index 0000000..91f4e01 --- /dev/null +++ b/RFIDIdReader/RfidClass/RfidClass.csproj @@ -0,0 +1,59 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {2F816B95-069B-4D48-9FBF-9B805A1049A8} + Library + Properties + RfidClass + RfidClass + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + PreserveNewest + + + + + \ No newline at end of file diff --git a/RFIDIdReader/RfidClass/bin/Release/RfidClass.dll b/RFIDIdReader/RfidClass/bin/Release/RfidClass.dll new file mode 100644 index 0000000..7796e22 Binary files /dev/null and b/RFIDIdReader/RfidClass/bin/Release/RfidClass.dll differ diff --git a/RFIDIdReader/RfidClass/bin/Release/librfid-tool.exe b/RFIDIdReader/RfidClass/bin/Release/librfid-tool.exe new file mode 100644 index 0000000..9becc5c Binary files /dev/null and b/RFIDIdReader/RfidClass/bin/Release/librfid-tool.exe differ diff --git a/RFIDIdReader/RfidClass/librfid-tool.exe b/RFIDIdReader/RfidClass/librfid-tool.exe new file mode 100644 index 0000000..9becc5c Binary files /dev/null and b/RFIDIdReader/RfidClass/librfid-tool.exe differ