Technical Discussion on the PhidgetRFID
Danelly
Phidgetsian
Posts: 6 Joined: Wed Dec 20, 2017 3:45 pm
Post
by Danelly » Thu Feb 01, 2018 4:53 pm
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
Post
by Danelly » Thu Feb 01, 2018 5:38 pm
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;
}
}
mparadis
Site Admin
Posts: 679 Joined: Fri Oct 28, 2011 12:17 pm
Post
by mparadis » Fri Feb 02, 2018 8:35 am
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
Post
by Danelly » Fri Feb 02, 2018 8:59 am
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
Engineering
Posts: 184 Joined: Mon Nov 13, 2017 10:20 am
Post
by jdecoux » Fri Feb 02, 2018 10:49 am
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...
}