get the ram and eeprom using applet

JavaCard Applet Development Related Questions and Answers.
morva14
Posts: 11
Joined: Thu Feb 25, 2016 5:16 pm
Points :188
Contact:

get the ram and eeprom using applet

Post by morva14 » Wed Jun 08, 2016 5:11 am

i write applet to get amount of eeprom but i am not sure whether or not it is right

i multiplicate counter and 1024 to get amount of eeprom , when exception throw

1.sample of EEPROM:

package memoryPack;

import javacard.framework.*;
import java.lang.Exception;

public class memoryApp extends Applet
{

public static void install(byte[] bArray, short bOffset, byte bLength)
{
new memoryApp().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}

public void process(APDU apdu)
{
short counter = (short) 0x0000;
if (selectingApplet())
{
return;
}

byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x00:
try{
while(true){
byte[] temp = new byte[1024];
counter++;
}
}catch(Exception e){
ISOException.throwIt(counter);
}
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}

}

rena2019
Posts: 68
Joined: Thu Aug 20, 2015 4:16 pm
Points :1774
Contact:

Re: get the ram and eeprom using applet

Post by rena2019 » Wed Jun 08, 2016 5:04 pm

Why you do not use javacard.framework.JCSystem.getAvailableMemory?
http://www.win.tue.nl/pinpasjc/docs/api ... ystem.html

Harten
Posts: 12
Joined: Tue Nov 17, 2015 7:41 am
Points :96
Contact:

Re: get the ram and eeprom using applet

Post by Harten » Sun Jun 12, 2016 1:18 am

You can use the following code to get the size of EEPROM.

Code: Select all

    short memSize_persistent = 0;
    short memSize = 0;
    try{
         while(true){
                        byte[] temp = new byte[1024];
                        memSize += (short)1024;
                    }
         }catch(Exception e)
         {
                memSize_persistent = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT);   
         }

         memSize += memSize_persistent;
         Util.setShort(buf, (short)0, memSize);

morva14
Posts: 11
Joined: Thu Feb 25, 2016 5:16 pm
Points :188
Contact:

Re: get the ram and eeprom using applet

Post by morva14 » Sun Jun 12, 2016 12:53 pm

thanks

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: Bing [Bot] and 11 guests

JavaCard OS : Disclaimer