JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html

How to save variables to EEPROM of Java Card JC30M48CR

Applets Development Guide

Moderator: product

mbsysde99
Posts: 40
Joined: Tue Oct 24, 2017 1:10 pm
Points :492
Contact:

How to save variables to EEPROM of Java Card JC30M48CR

Post by mbsysde99 » Fri Jan 28, 2022 6:08 am

I want to store a variable in memory that is not lost when the power supply is lost and I can update the contents of that memory while the program is running. In short, How to save variables to EEPROM of Java Card JC30M48CR? Thanks.

Regards,
Yudha

mbsysde99
Posts: 40
Joined: Tue Oct 24, 2017 1:10 pm
Points :492
Contact:

Re: How to save variables to EEPROM of Java Card JC30M48CR

Post by mbsysde99 » Fri Jan 28, 2022 11:42 am

Code: Select all

                
		A. PERSISTENT MEMORY 
 
 		1. // Persistent Memory (EEPROM) =  Memory still exist while lost power.
		//  Without set as transient object,  it immediately becomes a persistent object and save to EEPROM.
		byte[] SRC = new byte[]{1, 2};
               
                   OR
               
		2. // Persistent Memory (EEPROM) =  Memory still exist while lost power
		byte[] PM = JCSystem.makeTransientByteArray((short)2, JCSystem.MEMORY_TYPE_PERSISTENT);		
		JCSystem.beginTransaction();		
		Util.arrayCopyNonAtomic(SRC, (short)0, PM, (short)0, (short)2);		
		JCSystem.commitTransaction();
		

 		B. TEMPORARY MEMORY
 
		1. // Clear On Deselect Memory = Clear memory when applet is deselect.
		byte[] COD = JCSystem.makeTransientByteArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT);		
		JCSystem.beginTransaction();		
		Util.arrayCopyNonAtomic(SRC, (short)0, COD, (short)0, (short)2);		
		JCSystem.commitTransaction();

		2. // Clear On Reset Memory = Clear memory when card pull up / lost power.
		byte[] COR = JCSystem.makeTransientByteArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);		
		JCSystem.beginTransaction();		
		Util.arrayCopyNonAtomic(SRC, (short)0, COR, (short)0, (short)2);		
		JCSystem.commitTransaction();

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 1 guest

JavaCard OS : Disclaimer