Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

How to read and write value into smart card

JavaCard Applet Development Related Questions and Answers.
ordane
Posts: 11
Joined: Thu Dec 17, 2015 11:02 pm
Points :57
Contact:

How to read and write value into smart card

Post by ordane » Wed Dec 23, 2015 5:06 am

I bought IFD R502 smart card reader which came with two A40CR cards. And I am trying to write my own applet and load it into my cards. But I have some questions.

As you see below, add method adds 5 units to a declared variable. I would like to save the variable value into the card after making an operation. Does anyone know how can i write that value into the card? And if possible, how can i read it?

Code: Select all

    byte[] buffer = apdu.getBuffer();
    byte CLA = (byte) (buffer[ISO7816.OFFSET_CLA] & 0xFF);
    byte INS = (byte) (buffer[ISO7816.OFFSET_INS] & 0xFF);

    if (CLA != DE_CLA){
        ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
    }       
    switch (INS) {
        case DE_INS_ADD:               
            add(apdu);
            break;
        default:
            ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
    }

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: How to read and write value into smart card

Post by mabel » Wed Dec 30, 2015 11:00 pm

Any state in EEPROM fields will be kept until the Applet instance is deleted. The same goes for state within non-transient array elements.
You need to retain a persistent reference to the array for your goal.

Basically all object instances live in persistent memory, this means any object instance created with new. This is also the case for any object created by the platform where the API does not explicitly specify that the result is transient.

If you want to store something, you need to know about the Java Card transaction mechanism, especially if your operations are not atomic.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 28 guests

JavaCard OS : Disclaimer