Page 1 of 1

How to know which reader is reading??

Posted: Thu Feb 01, 2018 4:53 pm
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;
            
        }


    }

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

Posted: Thu Feb 01, 2018 5:38 pm
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;
            
        }


    }

Re: How to know which reader is reading??

Posted: Fri Feb 02, 2018 8:35 am
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;

Re: How to know which reader is reading??

Posted: Fri Feb 02, 2018 8:59 am
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?

Re: How to know which reader is reading??

Posted: Fri Feb 02, 2018 10:49 am
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...
}