Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All!

How can i get data from RFID reader, which is in USB port - port?
when reader reads the tag, tags ID should get to Windows form.

Please help me in this regard.

Thanks in Advance.
Posted
Updated 13-May-11 18:54pm
v2
Comments
Sandeep Mewara 14-May-11 1:37am    
Tried anything?
anshumandas 13-Jun-16 23:29pm    
I am also using this code but the delegate is not reading the card and not showing any data in the text box.I am using the following configuration:
Port No : Com3
Baud Rate: 9600
Parity None
Data Bit 8
Stop bit 1
Environment C#/ASP.net 4.5
USB port
Code

private void Form1_Load(object sender, EventArgs e)
{
RFID = new SerialPort();
RFID.PortName = "COM3";
RFID.BaudRate = 9600;
RFID.DataBits = 8;
RFID.Parity = Parity.None;
RFID.StopBits = StopBits.One;
RFID.Open();
RFID.ReadTimeout = 2000;
if (RFID.IsOpen)
{
DispString = "";
txtAccessCardNo.Text = "";
}
else
{
RFID.Close();
}
RFID.DataReceived += new SerialDataReceivedEventHandler(RFID_DataReceived);
}
private void RFID_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (txtAccessCardNo.Text.Length >= 12)
{
RFID.Close();
}
else
{
DispString = RFID.ReadExisting();
this.Invoke(new EventHandler(DisplayText));
}
}
private void DisplayText(object sender, EventArgs e)
{
txtAccessCardNo.AppendText(DispString);
}

Please help me Thanks in advance...

1 solution

Just treat it as a standard serial port: Open it, set up a receive data event handler, and process the data.
The only complication you might get is if the RFID reader does any data blocking, and / or encryption, but I can't help you there as I have no idea about the specific reader you are using.

private SerialPort RFID;

// In your form load event
        RFID = new SerialPort();
        RFID.PortName = "COM1";
        RFID.BaudRate = 9600;
        RFID.DataBits = 8;
        RFID.Parity = Parity.None;
        RFID.StopBits = StopBits.One;
        RFID.Open();
        RFID.DataReceived += new SerialDataReceivedEventHandler(RFID_DataReceived);
//
private void RFID_DataReceived(object sender, SerialDataReceivedEventArgs e)
   {
   string data = RFID.ReadExisting();
   myTextBox.Text += data;
   }
Should get you the raw data; it's then up to you to process it appropriately.

[edit]I can't even spell "object" this morning: corrected - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
thadaya666 30-Aug-12 10:39am    
I also have the same problem.But there is an error @ Open() - "COM1 does not exist"
is COM1 referring to rs232?
OriginalGriff 30-Aug-12 11:00am    
:laugh:
No, COM1 is a "physical" communications port on your PC. You probably want a different port number - I can't tell you which, you will have to look at your system. Have a look under the Device Manager - you should have a Ports branch (I think).
Rushali Gulhane 22-Dec-18 7:00am    
HI am also developing rfid reader i have reader RS232 bt my laptop doesn't have any COM free and also i want to ask which ddl file should use

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900