Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

How to send the arguments of install() method to smart card reader

JavaCard Applet Development Related Questions and Answers.
User avatar
conliaOdk
Posts: 20
Joined: Fri Aug 14, 2015 4:56 am
Points :9
Contact:

How to send the arguments of install() method to smart card reader

Post by conliaOdk » Tue Dec 01, 2015 2:15 am

I have just finished an applet. In applet, I want to send the arguments of install() method to smart card reader.

Code: Select all

package bArraytest;

import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
import javacard.framework.Util;

public class bArrayreturn extends Applet {
    // define two static variables
    public static byte[] theArray;
    public static short arrayLength;

    private bArrayreturn() {
    }

    public static void install(byte bArray[], short bOffset, byte bLength)
            throws ISOException {

        new bArrayreturn().register();
        bArrayreturn.arrayLength=(short)bArray.length;
        Util.arrayCopyNonAtomic(bArray, (short)0,bArrayreturn.theArray , (short) 0, bArrayreturn.arrayLength);   


    }

    public void process(APDU apdu) throws ISOException {
        byte[] buffer=apdu.getBuffer();
        Util.arrayCopyNonAtomic(bArrayreturn.theArray, (short)0,buffer , (short) 0, bArrayreturn.arrayLength);
        apdu.setOutgoingAndSend((short)0, (short)255);
    }


I defined two static variables named theArray and arrayLength in my applet. I tried to return variables to card reader in the process method. But in the response of SELECT command, the card returns 6F00.
Am I doing something wrong in my applet? How can I modify my code to make my applet work well? tnx

User avatar
horse dream
Posts: 76
Joined: Thu May 21, 2015 11:48 pm
Points :138
Contact:

Re: How to send the arguments of install() method to smart card reader

Post by horse dream » Wed Dec 02, 2015 8:43 am

It seems that you want to write to an uninitialized array(theArray == null). For this, you can initialize with theArray = new byte[length]
And you also made the wrong parameters for Util.arrayCopyNonAtomic.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 41 guests

JavaCard OS : Disclaimer