Multiples RFID READERS for multiples TAGS

Legacy support with Phidget21
charli_e

Multiples RFID READERS for multiples TAGS

Postby charli_e » Sat Nov 29, 2008 6:56 pm

Hi ,
Im trying to get a solution for this set up, that in somewhere of the examples looks like there is , but I have not be able to find it.

In my App, I´m using basically a Setup and main Loop function , this last function its swaping the Antenna of the RFID.

SETUP:

Code: Select all

///////////////////RFID1/////////////////////////////////////////////////////////////////////////////////////
   //create the RFID object
   CPhidgetRFID_create(&rfid);
   rfid1 = rfid;

   //Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error.
   CPhidget_set_OnAttach_Handler((CPhidgetHandle)rfid, AttachHandler, NULL);
   CPhidget_set_OnDetach_Handler((CPhidgetHandle)rfid, DetachHandler, NULL);
   CPhidget_set_OnError_Handler((CPhidgetHandle)rfid, ErrorHandler, NULL);

   //Registers a callback that will run if an output changes.
   //Requires the handle for the Phidget, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
    CPhidgetRFID_set_OnOutputChange_Handler(rfid, OutputChangeHandler, NULL);

   //Registers a callback that will run when a Tag is read.
   //Requires the handle for the PhidgetRFID, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
   CPhidgetRFID_set_OnTag_Handler(rfid, TagHandler, NULL);

   //Registers a callback that will run when a Tag is lost (removed from antenna read range).
   //Requires the handle for the PhidgetRFID, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
   CPhidgetRFID_set_OnTagLost_Handler(rfid, TagLostHandler, NULL);

   //open the RFID for device connections
   CPhidget_open((CPhidgetHandle)rfid, -1);

////////////////RFID2/////////////////////////////////////////////////////////
   //create the RFID object
   CPhidgetRFID_create(&rfid);
   rfid2 = rfid;

   //Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error.
   CPhidget_set_OnAttach_Handler((CPhidgetHandle)rfid, AttachHandler, NULL);
   CPhidget_set_OnDetach_Handler((CPhidgetHandle)rfid, DetachHandler, NULL);
   CPhidget_set_OnError_Handler((CPhidgetHandle)rfid, ErrorHandler, NULL);

   //Registers a callback that will run if an output changes.
   //Requires the handle for the Phidget, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
    CPhidgetRFID_set_OnOutputChange_Handler(rfid, OutputChangeHandler, NULL);

   //Registers a callback that will run when a Tag is read.
   //Requires the handle for the PhidgetRFID, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
   CPhidgetRFID_set_OnTag_Handler(rfid, TagHandler, NULL);

   //Registers a callback that will run when a Tag is lost (removed from antenna read range).
   //Requires the handle for the PhidgetRFID, the function that will be called, and an arbitrary pointer that will be supplied to the callback function (may be NULL).
   CPhidgetRFID_set_OnTagLost_Handler(rfid, TagLostHandler, NULL);

   //open the RFID for device connections
   CPhidget_open((CPhidgetHandle)rfid, -1);


UPDATE:

Code: Select all

void testApp::update(){

timer_milis = ofGetElapsedTimeMillis();
timer_milis = timer_milis + LAST_timer_milis;
//printf("timer_milis %f\n",timer_milis);
if(timer_milis > 200.0)swichAntena = true;// swap Antenna each 200 ms
else swichAntena = false;

   if (swichAntena == true)
   {
      counter_antena ++;if(counter_antena == 2)counter_antena=0; // change to 3
      
      if(counter_antena == 0)
      {
         //set antena OFF
         CPhidgetRFID_setAntennaOn(rfid1, 0);   
         //set antena ON
         CPhidgetRFID_setAntennaOn(rfid2, 1);   
         Antena1 = false;
         Antena2 = true;rfid = rfid2;
         //Antena3 = false;
      }
      else if(counter_antena == 1)
      {
         //set antena OFF
         CPhidgetRFID_setAntennaOn(rfid2, 0);   
         //set antena ON
         CPhidgetRFID_setAntennaOn(rfid1, 1);      
         Antena1 = true;rfid = rfid1;
         Antena2 = false;
         //Antena3 = false; // OJO ELS ORDRES PER A 3
      }
      //else if(counter_antena == 2)
      //{
      //   //set antena OFF
      //   CPhidgetRFID_setAntennaOn(rfid2, 0);   
      //   //set antena ON
      //   CPhidgetRFID_setAntennaOn(rfid1, 1);      
      //}
   swichAntena = false;
   }

LAST_timer_milis = timer_milis;



And my Handlers have some Global Variables that try to Identify with witch Reader the Tag have been detected.

The my hadnlers:

Code: Select all

int STDCALL TagHandler(CPhidgetRFIDHandle RFID, void *usrptr, unsigned char *TagVal)
{
   //turn on the Onboard LED
   CPhidgetRFID_setLEDOn(RFID, 1);

   printf("Tag Read: %02x%02x%02x%02x%02x\n", TagVal[0], TagVal[1], TagVal[2], TagVal[3], TagVal[4]);
   printf("\n");
   if(rfid == rfid1)
   {
      bRFID1 = true;
      sprintf(sRfid1, "%02x%02x%02x%02x%02x", TagVal[0], TagVal[1], TagVal[2], TagVal[3], TagVal[4]);
   }
   else if(rfid == rfid2)
   {
      bRFID2 = true;
      sprintf(sRfid2, "%02x%02x%02x%02x%02x", TagVal[0], TagVal[1], TagVal[2], TagVal[3], TagVal[4]);
   }
   return 0;
}

int STDCALL TagLostHandler(CPhidgetRFIDHandle RFID, void *usrptr, unsigned char *TagVal)
{
   //turn off the Onboard LED
   CPhidgetRFID_setLEDOn(RFID, 0);
   if(rfid == rfid1)
   {
      bRFID1 = false;
         printf("RFID1 Tag Lost: %02x%02x%02x%02x%02x\n", TagVal[0], TagVal[1], TagVal[2], TagVal[3], TagVal[4]);
   }
   else if(rfid == rfid2)
   {
      bRFID2 = false;
         printf("RFID2 Tag Lost: %02x%02x%02x%02x%02x\n", TagVal[0], TagVal[1], TagVal[2], TagVal[3], TagVal[4]);
   }
   return 0;
}



It´s the correct way? Im testing the App , but Im not getting correct results: the LEDs of RFID readers are not ON.

What´s wrong?

The best ,
Carles

charli_e

Postby charli_e » Wed Dec 03, 2008 10:29 am



Return to “VB 6.0”

Who is online

Users browsing this forum: No registered users and 0 guests