Reply To: DESFireEV1 getFreeMemory() returns more available memory than getTotalMemory()

Forum MIFARE SDK DESFireEV1 getFreeMemory() returns more available memory than getTotalMemory() Reply To: DESFireEV1 getFreeMemory() returns more available memory than getTotalMemory()

Re: DESFireEV1 getFreeMemory() returns more available memory than getTotalMemory()

13. February 2017 at 14:04
Hello,

Unfrotunately if getFreeMemory() doesn't act as it's supposed to act, that would create problems for certain use cases. For example, if I have a DESFire EV 4K which has 1 application on it (e.g. application with id 1) which consumes 128 bytes of the available user memory. If I wanted to write the remaining 3968 bytes in another application (e.g. application with id 2), how would I know how much space to reserve on the createFile method of IDESFireEV1 since in this case getFreeMemory() returns more than 4096 and clearly there aren't 4096 free bytes?

I see two problems with the check that you mention in (2):

1. That logic should be embedded in the library because it's responsibility of the library to deal with properties of the tags, and the free available user memory is a property of a tag.

2. That 'if' would be still throw an exception if the space consumed is sufficiently small as in the example presented earlier. It would be impossible to know how much memory is there remaining since getTotalMemory() would still return the same value and getFreeMemory() would return a smaller value but still greater than the one returned by getTotalMemory()


In reality there could be 3 distinct methods:

getTotalMemory(): Returns the total available memory of a card including controller. For example in an DESFire EV 1 4K should return 4864
getFreeUserMemory(): Returns the available remaining memory usable by the user (i.e. file system). For example in an DESFire EV 1 4K with a file that consumes 128 bytes it should return 3968
getTotalUserMemory(): Returns the total available memory usable by the user (i.e file system). For example in an DESFire EV 1 4K should return 4096



Is there any way to calculate the available user memory?


Regards
+ 0  |  - 0