如何从C#智能设备中的串行端口读取RFID数据? [英] How to read RFID data from serial port in C# smart device?
本文介绍了如何从C#智能设备中的串行端口读取RFID数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我编写了用于在智能设备中打开串行端口的代码.它正在打开可用的串行端口.现在,我需要用于读取RFID数据(从串行端口)的代码.请帮助我.
Hi Friends,
I wrote the code for opening the serial port in smart device. It is opening the available serial ports. Now I need the code for reading the RFID data (from the serial port). Please help me.
推荐答案
Pradeep,
我们可以使用串行端口从RF-ID阅读器读取标签值,为此我们需要使用串行电缆将RF-ID阅读器连接到端口,并使用相关的COM端口号连接到C#的串行端口对象连接.
-通常,System.Net包含串行端口类,并且在工具箱中也可以作为Win Forms应用程序的串行端口组件使用.
-您可以添加Win Forms应用程序.并使用代码的贝娄部分阅读.
Hi Pradeep,
We can use Serial port for Reading the Tag values from the RF-ID Reader.For this we need to connect the RF-ID Reader using the Serial cable to the port and use the relevant COM Port No# to the Serial port Object of C# to Connect.
- Normally the System.Net Contains the Serial Port Class and also available in the Toolbox as Serial port component for your Win Forms App.
-You can add a Win Forms App. and Use the Bellow part of code to read.
private void btnReadTag_Click(object sender, EventArgs e)
{
serialPort = new SerialPort();// if u r not used Serial Port Tool
serialPort.PortName = "COM1";
serialPort.BaudRate = 9600;
serialPort.DataBits = 8;
serialPort.Parity = Parity.None;
serialPort.StopBits = StopBits.One;
serialPort.Open();
serialPort1.ReadTimeout = 2000;
serialPort.DataReceived += new SerialDataReceivedEventHandler(Fun_DataReceived);
serialPort.Close();
}
//Delegate for the Reading the Tag while RFID Card come to the Range.
string data = string.Empty;
private delegate void SetTextDeleg(string text);
void Fun_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Thread.Sleep(500);
data = serialPort.ReadLine();
this.BeginInvoke(new SetTextDeleg(Fun_IsDataReceived), new object[] { data });
}
private void Fun_IsDataReceived(string data)
{
txtAccessCardNo.Text = data.Trim();
}
学得很好:)
Have great learning :)
好吧,至少您必须知道您的RFID设备正在使用的协议.
:)
Well, you must, at least, know the protocol your RFID device is using.
:)
我用Google搜索了"c#读取rfid数据",获得了108,000次点击.我怀疑您会比等我们中的一个人为您找到答案的速度快得多.
I googled "c# read rfid data", and got 108,000 hits. I suspect you''ll find your answer there much faster than waiting for one of us to do the research for you.
这篇关于如何从C#智能设备中的串行端口读取RFID数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文