JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html
https://ftsafe.en.alibaba.com/index.html
get the ram and eeprom using applet
get the ram and eeprom using applet
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);
}
}
}
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);
}
}
}
Re: get the ram and eeprom using applet
Why you do not use javacard.framework.JCSystem.getAvailableMemory?
http://www.win.tue.nl/pinpasjc/docs/api ... ystem.html
http://www.win.tue.nl/pinpasjc/docs/api ... ystem.html
Re: get the ram and eeprom using applet
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);
Who is online
Users browsing this forum: No registered users and 38 guests