Phidg​​etRFID 芯片:如何检测标签

PhidgetRFID chip: How to detect tags

我有一个 Phidg​​etRFID 芯片(P/N:1023,版本 205)。我正在尝试制作一个简单的程序来检测标签并显示其唯一的 ID 号。我从其制造商网站上找到了以下源代码

import com.phidgets.*;
import com.phidgets.event.*;

public class RFIDExample
{
    public static final void main(String args[]) throws Exception {
        RFIDPhidget rfid;

        System.out.println(Phidget.getLibraryVersion());

        rfid = new RFIDPhidget();
        rfid.addAttachListener(new AttachListener() {
            public void attached(AttachEvent ae)
            {
                try
                {
                    ((RFIDPhidget)ae.getSource()).setAntennaOn(true);
                    ((RFIDPhidget)ae.getSource()).setLEDOn(true);
                }
                catch (PhidgetException ex) { }
                System.out.println("attachment of " + ae);
            }
        });
        rfid.addDetachListener(new DetachListener() {
            public void detached(DetachEvent ae) {
                System.out.println("detachment of " + ae);
            }
        });
        rfid.addErrorListener(new ErrorListener() {
            public void error(ErrorEvent ee) {
                System.out.println("error event for " + ee);
            }
        });
        rfid.addTagGainListener(new TagGainListener()
        {
            public void tagGained(TagGainEvent oe)
            {
                System.out.println("Tag Gained: " +oe.getValue() + " (Proto:"+ oe.getProtocol()+")");
            }
        });
        rfid.addTagLossListener(new TagLossListener()
        {
            public void tagLost(TagLossEvent oe)
            {
                System.out.println(oe);
            }
        });
        rfid.addOutputChangeListener(new OutputChangeListener()
        {
            public void outputChanged(OutputChangeEvent oe)
            {
                System.out.println(oe);
            }
        });

        rfid.openAny();
        System.out.println("waiting for RFID attachment...");
        rfid.waitForAttachment(30000);

        System.out.println("Serial: " + rfid.getSerialNumber());
        System.out.println("Outputs: " + rfid.getOutputCount());

        }
    }

但我收到以下错误:

Phidg​​et21 - 版本 2.1.8 - 2016 年 2 月 22 日构建 11:45:54 等待 RFID 附件... 线程中的异常 "main" Phidg​​etException 13(已超过给定超时。) 在 com.phidgets.Phidget.waitForAttachment(本机方法) 在 RFIDExample.main(RFIDExample.java:58)

我已经尝试过,增加计时器但问题没有解决。 我尝试将制造商的应用程序用于我的 RFID 芯片并且它有效,它正确地检测到标签。但我需要使用源代码而不是现成的应用程序。

任何帮助都会非常有用! 先感谢您! :)

BR, 卢卡斯

最后,问题是我在尝试执行代码时同时打开了准备好的应用程序。

现在可以正常使用了。

问题已解决。