我有一个PhidgetRFID芯片(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());
}
}但我收到了以下错误:
Phidget21 -版本2.1.8 -建于2016年2月22日11:45:54等待射频识别附件.线程"main“PhidgetException 13中的异常(已经超出了给定的超时)。在com.phidgets.Phidget.waitForAttachment(原生方法)在RFIDExample.main(RFIDExample.java:58)
我已经试过的是增加计时器,但问题没有解决。我试着用制造商的应用程序来制作我的RFID芯片,它成功了,它正确地拆开了标签。但我需要使用源代码,而不是现成的应用程序。
任何帮助都是非常有用的!(预先多谢!)
比尔·卢卡斯
发布于 2017-04-04 15:51:01
最后,问题是我试图执行代码,同时打开现成的应用程序。
现在它正常工作了。
问题解决了。
https://stackoverflow.com/questions/43168020
复制相似问题