Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.
Posted
Updated 9-Jun-10 1:50am
v3

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.
C#
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 :)
 
Share this answer
 
v4
Comments
ares_phobes 21-Mar-11 10:52am    
i tried the coding which u gave above its not doing anything at all... the code goes through the all the steps and stops at the end but it doesnt write in the tag
yutalolap 18-Mar-12 6:32am    
Mr Sivakumar! I need your help! I am doing a project using RFID. i need to learn how to program it. i have seen the code above and can you tell me step by step how to go about it please. I really need your help
Sivakumar Koteeswaran 18-Mar-12 10:11am    
Hi Yutalolap,
First decide the what kind of RFID your going to use for your project and do the below process, use the above code.
1. For connecting the RFID Reader you need a Serial cable, Serial port in your PC or Laptop.(Here i have used Passive RFID).
2. Then detect the COM Port which the RFID is connected using device manager and assign the port name to the above code.
yutalolap 18-Mar-12 12:57pm    
sir the above code is in VB! i need it in C#! is there much difference in it?
Member 12702326 20-Jul-19 15:44pm    
Delete the code
serialPort.Close();
and Select The right COM Port!
this worked for me!
Well, you must, at least, know the protocol your RFID device is using.
:)
 
Share this answer
 
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.
 
Share this answer
 
v2
Comments
Rushali Gulhane 7-Dec-18 8:28am    
Hi am developing RFID Writer in C# but i do not know how to start developing
#realJSOP 7-Dec-18 11:54am    
Take a class.
Rushali Gulhane 11-Dec-18 6:59am    
where ??
#realJSOP 11-Dec-18 7:27am    
I always though everyone in India was going to school to learn to be a developer - or a call center person.
Rushali Gulhane 11-Dec-18 8:17am    
Actually I dont have not much time to learn if there is any online course please suggest me .
does your smart device has the RFID reader attached? what does the specifications for the reader say? how do you communicate to it? does it include the commands list for the reader?.

btw, make sure the RFID is not encrypted, if so, you will need to handle the encryption before reading the data...
 
Share this answer
 
hello,

my name is nitin.

Can anyone help me to make connection with thingmagic m6 reader.
how can i develop a middleware software because i am new to this.
please help me .............
how can i establish the connection and how can i read the tag.
and i am developing it on asp.net using c#.



with regards,
Nitin Singhal
 
Share this answer
 
Comments
reyona 5-Apr-12 2:03am    
Hey NitIN , i AM ALSO working on M4 RFID reader. I have developed the complete application of RFID Read and Write.

To make the connection Fisrt you should know about the Socket programming then after go for further steps .

You can mail me as well on my email id-tarun.sam123@gmail.com.
Hi , i Develop application before with Reader Device "Reader2600" but the Company who provide the device Support me With SDK even they Give me sample of the code i was just modifying i believe if you ask the Supplier he you will provide you of what you want .
 
Share this answer
 
Comments
Maryam3028 11-Apr-12 11:23am    
Hi Mohamed,

I am doing a project with Reader2600. I have 2 antennas connected to my reader. I need to know which antenna has detected which tag. I have digged into SDK and manual but I haven't found any thing that can help me with that. I only can see tags id that have been detected by the antennas.

Do you know how I can get antenna's id as output?
I really appreciate your help.

Maryam
Mohamed Mitwalli 12-Apr-12 21:45pm    
Hi Maryam ,
I didn't face this issue in my application but i will search on solution for it ,by the way in my application it was separated in two pieces like there was Fixed reader for entrance and another reader for exist that's why i didn't face this issue
Mohamed Mitwalli 1-May-13 1:31am    
Why you get this feeling i was trying to help nothing more :) any way just ignore it ,you can down voted the answer it's your call .
1.Use Terminal application, Serial Port Terminal Application to communicate with your reader first.
see that the data you are sending and get the response.

2. once you find all ok and getting expected response, port it on serial port C#.net application.

3. you might like to use serial port HDD sniffer. which will give you view of what communication is going on betwwen your application and reader.
 
Share this answer
 

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