0

com 端口上有大量 RFID 教程,但 USB 上没有。有关于 C# 的描述与键盘楔,但不适用于 java。

我有一个键盘楔,“认为那是 ac# 术语”它基本上将 id 作为击键。我需要验证键盘输入是否来自 rfid 标签。

我从 ebay 得到了阅读器,没有配置工具,也没有 sdk 或 api。但自动工作,就好像它从键盘打字一样。

我在 ac# 答案中找到的一个建议是

目前,我正在通过附加到 KeyPress 事件并寻找一系列包含刷卡标记字符的非常快速的按键来处理此问题。

看起来很有希望,但不知道该怎么做

4

1 回答 1

0

I have done similar work in JavaScript to read magnet card swipes. You will need to measure the time between key press events. If the time is under a THRESHOLD (you might need to determine this experimentally), then its the wedge reader, so append the pressed key to your input string. Otherwise, its a human, so reset the state.

This is a rough example of how you might accomplish this:

private String input = "";
private long lastPress = 0;

public void onKeyPress(Event event) {
   if(lastPress - System.currentTimeInMillis() < THRESHOLD) {
     lastPress = System.currentTimeInMillis();
     input += event.getKey();
   } else {
     lastPress = 0;
     input = "";
   }
}

This is just a starting point. Your particular application may require additional conditions like checking for sentinels and what not to help determine if you are in a wedge read or not.

于 2012-06-15T17:17:12.563 回答