简体   繁体   English

监听RFID扫描仪并打印数据

[英]listen for RFID scanner and print data

I have an RFID reader/scanner that I bought from this site E-Gizmo and they have a manual here: Low Cost RFID Reader Manual . 我有从该网站E-Gizmo购买的RFID阅读器/扫描器,并且在这里有手册: 低成本RFID阅读器手册 I've been trying to get it to work with java and so far, I have almost zero idea how to do this. 我一直在尝试使其与Java一起使用,到目前为止,我几乎不了解如何执行此操作。

what I want to do is to have a class running on the background(threading+Listener? not sure.) that waits for the RFID and store the content of the tag into a variable(String). 我想做的是让一个类在后台运行(不确定线程​​+侦听器?),该类等待RFID并将标签内容存储到变量(字符串)中。

so far, I got my class to read the physical port of the device. 到目前为止,我上课了以读取设备的物理端口。 Here is my code. 这是我的代码。

package Data;

import com.fazecast.jSerialComm.*;
import java.util.Scanner;

public class ComControl{
    public static void main (String argsp[]){

        SerialPort ports[] = SerialPort.getCommPorts();

        for(SerialPort port: ports){
            System.out.println(port.getDescriptivePortName());
        }

        Scanner i = new Scanner(System.in);
        int x = i.nextInt();

        SerialPort port = ports[x-1];

        if(port.openPort()){
            System.out.println("Port is open");
        }else{
            System.out.println("Port is not available");
            return;
        }

        port.setComPortParameters(9600, 8, 0, 0);
        port.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 0, 0);
        Scanner data = new Scanner(port.getInputStream());

//I just had to give it a try or guess..
        do{
            System.out.print(data.nextLine());
        }while(x<99);

    }
}

Ive been browsing around and so far, I havnt found any newbie friendly guides on how to get my device to work with java. 我一直在浏览,到目前为止,我没有找到关于如何使我的设备与Java一起使用的任何新手友好指南。

what I currently have in my tools are jSerialComm-1.3.10.jar and comm-2.0.jar 我目前在工具中jSerialComm-1.3.10.jarjSerialComm-1.3.10.jarcomm-2.0.jar

any hints, guides, or probably code that might help? 任何提示,指南或可能有用的代码?

I have used JSSC with great success before, it is imo the best serial library for java, I have always had trouble with rxtx: 我以前使用JSSC取得了巨大的成功,它是imo最好的Java串行库,我一直在使用rxtx遇到麻烦:

Linked is an example of how to use the lib for your comms with the scanner 链接是如何使用lib进行扫描程序通信的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM