Page 1 of 1

how to get the available space of chip?

Posted: Tue Oct 16, 2018 2:09 am
by AlexLiu
how to get the available space of chip?

Re: how to get the available space of chip?

Posted: Tue Oct 16, 2018 2:14 am
by DaHuFa
In JavaCardAPI, the JCSystem.getAvailableMemory() API may help you get your want.

Re: how to get the available space of chip?

Posted: Tue Oct 16, 2018 5:40 am
by AlexLiu
but why the space size obtained by API is smaller than the actual space size?

Re: how to get the available space of chip?

Posted: Wed Oct 24, 2018 12:18 am
by scplatform
do it like this:

Code: Select all

while (true) {
	try {
		bbb = JCSystem.makeTransientByteArray(memsize, JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT);
		allmemsize += memsize;
		if(memsize != 0x7fff)
			break;
	} catch (CardRuntimeException ex) {
		memsize -= 1;
		continue;
	}
}

Re: how to get the available space of chip?

Posted: Wed Oct 24, 2018 2:17 am
by DaHuFa
In 《JavaCardAPI》, one item in Notes of getAvailableMemory() is "If the number of available bytes is greater than 32767, then this method returns 32767."
So, if the return value is 32767, you should call getAvailableMeory() again to look up whether the card has more available memory.