Question

I am working on a RFID based attendance monitoring system. I used Mifare 1k Classic as my RFID and ACR122u as my reader. I learned that you can store value to the card using the STORE VALUE BLOCK APDU command and can also be read by using READ BLOCK APDU command. Both commands returns 0x90 SW1 which means it transmitted successfully. My problem is how to get/retrieve the value stored to the VALUE BLOCK after reading it. E.g I Stored a value "15" from block 0x05. Now I try to get the value "15" from block 0x05. I tried this codes here:

CommandAPDU comm1 = new CommandAPDU(new byte[] {(byte) 0xFF,(byte) 0xB1,(byte) 0x00,(byte) 0x05,(byte) 0x04});
ResponseAPDU read1 = channel.transmit(comm1);

It successfully reads the block but it doesn't display the value. i tried using:

System.out.println(read1.getBytes());
System.out.println(read1.getData());

But both display some random outputs like: [B@140fee

Can anyone help me with this? And what is the output means?

Was it helpful?

Solution

The output [B@140fee is generated by the object's toString() method (which is implicitly called when printing an arbitrary object with the println() method. The [ means that the object is an array type object. B means that the element type of the array is Byte. The hexadecimal digits following the @ sign are the hexadecimal representation of the object's hash code (whatever number is returned by the object's hashCode() method.

So in order to see the bytes you received, you would need to convert the byte array to a readable string representation (e.g. concatenated hexadecimal representation of each byte value).

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