How to know which reader is reading??

Technical Discussion on the PhidgetRFID
Post Reply
Danelly
Phidgetsian
Posts: 6
Joined: Wed Dec 20, 2017 3:45 pm
Contact:

How to know which reader is reading??

Post by Danelly »

I have a few readers connected to a computer and I need to know which one is reading a tag.
Is there a way to know that?.
Identify which one is reading by the serial number. I need it to know where is the tag in the working process.

My code is below and it's wrote in c#

Code: Select all

	 public partial class Form1 : Form
    {
        Manager manager;
        RFID rfid1, rfid2;
        string cad = "";
        bool cachado = false;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {

                rfid1 = new RFID();
                rfid1.Tag += rfid_Tag;
                rfid1.TagLost += rfid_TagLost;
                rfid2 = new RFID();
                rfid2.Tag += rfid_Tag;
                rfid2.TagLost += rfid_TagLost;
                //428566 this is the serial number of my readers
                //428706
                rfid1.Open();
                rfid2.Open();
            }
            catch (PhidgetException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        void rfid_TagLost(object sender, RFIDTagLostEventArgs e)
        {
            label1.Text = "";

        }


        void rfid_Tag(object sender, RFIDTagEventArgs e)
        {
            cad = e.Tag;
            label1.Text = e.Tag;
            
        }


    }
Danelly
Phidgetsian
Posts: 6
Joined: Wed Dec 20, 2017 3:45 pm
Contact:

How to know which 1024_0 reader is the one that is reading?

Post by Danelly »

Hi, I'm trying to know where is a tag by identifying with which reader it's being read, maybe it can be getting which serial number once the tag is read, I'm working with multiple readers and I want to know which detected it.
They're 1024_0 readers.

My code is below and it's written in C#

Code: Select all

 public partial class Form1 : Form
    {
        Manager manager;
        RFID rfid1, rfid2;
        string cad = "";
        bool cachado = false;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {

                rfid1 = new RFID();
                rfid1.Tag += rfid_Tag;
                rfid1.TagLost += rfid_TagLost;
                rfid2 = new RFID();
                rfid2.Tag += rfid_Tag;
                rfid2.TagLost += rfid_TagLost;
                //428566 this is the serial number of my readers
                //428706
                rfid1.Open();
                rfid2.Open();
            }
            catch (PhidgetException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        void rfid_TagLost(object sender, RFIDTagLostEventArgs e)
        {
            label1.Text = "";

        }


        void rfid_Tag(object sender, RFIDTagEventArgs e)
        {
            cad = e.Tag;
            label1.Text = e.Tag;
            
        }


    }
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: How to know which reader is reading??

Post by mparadis »

You can set the serial numbers for rfid1 and rfid2 before opening them so your computer knows which board to assign to which:

Code: Select all

rfid1.DeviceSerialNumber = 324781;
rfid2.DeviceSerialNumber = 295819;
Danelly
Phidgetsian
Posts: 6
Joined: Wed Dec 20, 2017 3:45 pm
Contact:

Re: How to know which reader is reading??

Post by Danelly »

Ok, I know how to assign the serial number at the beginning, but how to use it to identify which is the one reading?
jdecoux
Labview Developer
Posts: 161
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: How to know which reader is reading??

Post by jdecoux »

In C#, a reference to the channel that fires an event is passed in the form of the sender parameter.

To get the serial number of the RFID device that that fired the event, use

Code: Select all

void rfid_Tag(object sender, RFIDTagEventArgs e)
{
	RFID channel = (RFID)sender;
	int serialNumber = channel.DeviceSerialNumber;
	
	//Other Code Here...
}
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests