1

I'm using the (id12 innovations) RFID read with a Raspberry Pi. Using the PI4J java library and it's serial example, I'm able to read some data like (5002CF13C6) i'm not sure what this data is! it suppose to get this number (0002948115).

here's is my code:

// create an instance of the serial communications class
final Serial serial = SerialFactory.createInstance();

// create and register the serial data listener
serial.addListener(new SerialDataListener() {
@Override
public void dataReceived(SerialDataEvent event) {
    //-----------
    System.out.print("\n" + event.getData());
    //-----------
}

});

try {
    // open the default serial port provided on the GPIO header
    serial.open("/dev/ttyAMA0", 9600);

    // continuous loop to keep the program running until the user terminates the program
    for (;;) {
        try {

        } catch (IllegalStateException ex) {
            ex.printStackTrace();
        }
        try {
            // wait 1 second before continuing
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(Rfid.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

} catch (SerialPortException ex) {
    System.out.println("e: RFID setup failed : " + ex.getMessage());
}

what should i do to event.getData() in order to be able to read the real data?

4

1 回答 1

1

event.getData(),返回给您的正是 id12 芯片在串行端口上所说的内容。数据是十六进制数的 10 个字符的字符串表示形式,后跟 2 个字符的校验和。

该行为在 id12 数据表中指定,可以在 google 或此处快速找到:http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/ID/ID-2LA,%20ID-12LA,%20ID-20LA ( 2013-4-10).pdf . 在链接的 PDF 中,它是第 4 页。

如果您需要在 java 中解析此数据的帮助,请提供一些实际读取的数据,以及属于该读取数据的相应预期值。

于 2013-07-18T14:32:01.680 回答