Question

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?

Was it helpful?

Solution

event.getData(), is returning to you exactly what the id12 chip is saying on the serial port. The data is a 10 character string representation of a hexadecimal number, followed by a 2 character checksum.

The behavior is specified in the id12 datasheet, which can be quickly found on google, or here: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/ID/ID-2LA,%20ID-12LA,%20ID-20LA(2013-4-10).pdf . In the linked PDF, it is page 4.

If you would like some help parsing this data in java, please supply some actual read data, and the corresponding expected values belonging to that read data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top