RFID Reader activation

Supporting Java SE version 7 and up
Jüdas

RFID Reader activation

Postby Jüdas » Tue May 24, 2011 11:49 am

I'm trying to get multiple RFID readers to function alongside each other. I'd like to just keep an array of each of them, sorted by serial number, activating and deactivating them as they're needed and so on. What is wrong with the following piece of code?

Code: Select all

import com.phidgets.*;

public class test
{
    public static void main(String [ ] args) throws Exception
    {
       RFIDPhidget sensor = new RFIDPhidget();
       sensor.open(162162); //The serial
       sensor.setOutputState(1, true); //this fails
       sensor.setAntennaOn(true); //and this fails
    }
}

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: RFID Reader activation

Postby erik » Tue May 24, 2011 12:08 pm

After calling open() and before setting the output, use the waitForAttachment() method, with or without a timeout. Since open() will return immediately, it does not guarantee that the Phidget is actually ready to be communicated with. waitForAttachment() waits until all the initial setup stuff is completed and then the Phidget is ready for communication.

Jüdas

Re: RFID Reader activation

Postby Jüdas » Tue May 24, 2011 12:13 pm

Ah, I see now. Thanks a lot mate:)
To get the actual code working use:

Code: Select all

import com.phidgets.*;

public class test
{
    public static void main(String [ ] args) throws Exception
    {
       RFIDPhidget sensor = new RFIDPhidget();
       sensor.open(162162); // serial for RFID Reader
       sensor.waitForAttachment();
       sensor.setOutputState(1, true);
       sensor.setAntennaOn(true);
    }
}



Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest