首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >射频识别ReaderTrack环路

射频识别ReaderTrack环路
EN

Stack Overflow用户
提问于 2016-11-08 17:12:52
回答 1查看 164关注 0票数 0

嘿,伙计们,我想做一个叫"RFID管理系统“的项目

我从一些网站上找到了一些示例代码,并在其中添加了一些代码。

我的RFID现在可以从mifare卡中读取数字,但我已经面临一个问题:如何为我的RFID机器创建一个循环,以便在不按下Eclipse中的"RUN“按钮的情况下一次又一次地读取卡

代码语言:javascript
复制
import java.util.List;
import javax.smartcardio.*;
import javax.xml.bind.DatatypeConverter;

public class Blog {
 public static void main(String[] args) {
  try {
   // Display the list of terminals
   TerminalFactory factory = TerminalFactory.getDefault();
   List<CardTerminal> terminals = factory.terminals().list();
   System.out.println("Terminals: " + terminals);

   // Use the first terminal
   CardTerminal terminal = terminals.get(0);

   // Connect wit hthe card

   Card card = terminal.connect("*");
   System.out.println("card: " + card);
   CardChannel channel = card.getBasicChannel();


   // Send Select Applet command
   ResponseAPDU answer = channel.transmit(new CommandAPDU(new byte[] { (byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x00 } ));

   // Send test command
   answer = channel.transmit(new CommandAPDU(new byte[] { (byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x00 } ));
   byte r[] = answer.getData();
   String hex = DatatypeConverter.printHexBinary(answer.getBytes());
   System.out.println("Response: " + hex);

   // Disconnect the card
   card.disconnect(false);
  } catch(Exception e) {
   System.out.println("Ouch: " + e.toString());
  }
 }
}
EN

回答 1

Stack Overflow用户

发布于 2016-11-08 17:22:23

你可能知道arduino编程,对吧?,我们有一个循环函数(),所以我们在里面写的任何代码都会永远循环。这就是这些东西(如rfid、指纹扫描仪、温度传感器、运动检测器等)的逻辑。所以在这里使用相同的技术。将您的代码放在

代码语言:javascript
复制
while(1){

 } 

循环。这将永远迭代您的代码。因此,你将获得所需的o/p。你可以随心所欲地多次刷新你的卡。确保读取和处理数据的代码应该只出现在循环中。否则,它将占用大量内存,并可能导致代码崩溃。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40482958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档