Send APDU just one time

My application (in delphi) send Name(string), Family(string), And children (array of string)...
then These data will convert into Hex format and will be sent to CAD via APDU...
My question is how can I send all of these data at once via on APDU command, should I send Name and Family one by one and also send every index in my array one by one ??
I wrote an applet which has a SetName, Set Family and SetChildren Methods and once call SetName and send Name via one APDU, then call SetFamily and send Family via other APDU, and the big problem is in array that I'm sending each index data of array via one APDU...
I'm sure it's a foolish way and there's a better way to send these data :)
would u please help me and guid me what can I do, this is so much urgent
Kind Regards
Hana

Zip_Smart_Girl wrote:
first a question about your last reply:
I add this code in my applet process method, so what can i send from JCOP, can I now send Lc in 2 bytes ??The card you have is Java Card 2.2.1 which does not support extended length APDU's. As such your only choice is to implement chaining. This is also the reason why your code does not compile in Eclipse. You are building against the JC2.2.1 libraries.
Here is some code that may help you get started. This code is not tested (apart from the fact it compiles) as I am not at work at the moment. This code comes with all the standard disclaimers and may not be fit for purpose... so use at your own risk :) There is still more validation that could go in (such as checking that the GET-RESPONSE command has the same CLA byte etc). Hopefully this code works and gets you started with command and response chaining. This may also help anyone else that needs to do something similar. If this can help just one person I will be happy.
Cheers,
Shane
package chaining;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.JCSystem;
import javacard.framework.Util;
* Very simple applet for chaining data to and from a card.
* @author shane
public class ChainingApplet extends Applet {
    private final static byte INS_GET_RESPONSE = (byte) 0xC0;
    private final static byte INS_PUT_DATA = 0x00;
    private final static byte INS_GET_DATA = 0x01;
    private final static byte OFFSET_SENT = 0x00;
    private final static byte OFFSET_RECV = 0x01;
    private static short[] offset;
    private static byte[] fileBuffer;
    private static short fileSize = 0;
    private final static short FILE_SIZE = 2048; // 2KB file
    private final static short MAX_APDU = 255;
     * Default constructor that initialises all memory to be used by the applet.
    public ChainingApplet() {
        offset = JCSystem.makeTransientShortArray((short) 2, JCSystem.CLEAR_ON_RESET);
        fileBuffer = new byte[FILE_SIZE];
     * {@inheritDoc}
    public static void install(byte[] bArray, short bOffset, byte bLength) {
        // GP-compliant JavaCard applet registration
        new ChainingApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
     * {@inheritDoc}
    public void process(APDU apdu) {
        // Good practice: Return 9000 on SELECT
        if (selectingApplet()) {
            return;
        short len = apdu.setIncomingAndReceive(); // This is the amount of data read from the OS.
        byte[] buf = apdu.getBuffer();
        byte cla = buf[ISO7816.OFFSET_CLA];
        byte ins = buf[ISO7816.OFFSET_INS];
        short lc = (short) (buf[ISO7816.OFFSET_LC] & 0x00ff); // this is the LC from the APDU.
        // get all bytes from the buffer
        while (len < lc) {
            len += apdu.receiveBytes(len);
        // validate the INS byte (basic check that tests for valid GET-RESPONSE or GET-DATA)
        if (offset[OFFSET_SENT] > 0 && ins != INS_GET_RESPONSE) {
            ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
        } else if (ins == INS_GET_RESPONSE && offset[OFFSET_SENT] == 0) {
            ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
        switch (buf[ISO7816.OFFSET_INS]) {
            case INS_PUT_DATA:
                saveData(buf, ISO7816.OFFSET_CDATA, offset[OFFSET_RECV], len);
                if ((cla & 0x10) != 0x00) {
                    offset[OFFSET_RECV] += len;
                } else {
                    // last command in the chain
                    fileSize = (short) (offset[OFFSET_RECV] + len);
                    offset[OFFSET_RECV] = 0;
                break;
            case INS_GET_DATA:
            case INS_GET_RESPONSE:
                sendData(apdu);
                break;
            default:
                // good practice: If you don't know the INStruction, say so:
                ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
     * Simple method to save the data somewhere. Add real implementation here.
     * @param source
     *            buffer containing data to copy
     * @param sourceOff
     *            offset into source buffer to the data
     * @param destOff
     *            offset into the destination buffer
     * @param len
     *            length of the data to copy.
    private static void saveData(byte[] source, short sourceOff, short destOff, short len) {
        // prevent buffer overflow
        if ((short) (destOff + len) > FILE_SIZE) {
            ISOException.throwIt(ISO7816.SW_FILE_FULL);
        Util.arrayCopy(source, sourceOff, fileBuffer, destOff, len);
     * Simple method to send chainined data to the client application (if required).
     * @param apdu
     *            current APDU
    private void sendData(APDU apdu) {
        // work out how many bytes to send this time and how many will be left
        short remain = (short) (fileSize - offset[OFFSET_SENT]);
        boolean chain = remain > MAX_APDU;
        short sendLen = chain ? MAX_APDU : remain;
        // Get ready to send
        apdu.setOutgoing();
        apdu.setOutgoingLength(sendLen);
        apdu.sendBytesLong(fileBuffer, offset[OFFSET_SENT], sendLen);
        // Check to see if there are more APDU's to send
        if (chain) {
            offset[OFFSET_SENT] += sendLen; // count the bytes sent
            ISOException.throwIt(ISO7816.SW_BYTES_REMAINING_00); // indicate there are more bytes to come
        } else {
            offset[OFFSET_SENT] = 0; // no more bytes to send
}

Similar Messages

  • Doing loop just one time

    hi max
    i have loop for tmp_emp_day and i wont to do the loop target_hours_exp just one time (fill cnt_days just one time) in all the big loop (tmp_emp_day) how i do that?
    LOOP AT tmp_emp_day ASSIGNING <fs_emp>.
    CALL FUNCTION 'Z_EMP_CAP'
    EXPORTING
    pernr = <fs_emp>-pernr
    begda = fir_day
    endda = last_day
    IMPORTING
    target_hrs = target_hrs
    TABLES
    target_hours_exp = target_hours_exp
    work_hours = work_hours.
    <b>LOOP AT target_hours_exp ASSIGNING <target_hours_exp> WHERE stdaz = '0.5' .
    ADD 1 TO cnt_days.
    ENDLOOP.</b>
    <fs_emp>-miss_days = <fs_emp>-miss_days - cnt_days.
    APPEND <fs_emp> TO emp_miss_days.
    ENDLOOP.
    Regards

    try
    LOOP AT tmp_emp_day ASSIGNING <fs_emp>.
    CALL FUNCTION 'Z_EMP_CAP'
    EXPORTING
    pernr = <fs_emp>-pernr
    begda = fir_day
    endda = last_day
    IMPORTING
    target_hrs = target_hrs
    TABLES
    target_hours_exp = target_hours_exp
    work_hours = work_hours.
    if sy-tabix = 1.
    LOOP AT target_hours_exp ASSIGNING <target_hours_exp> WHERE stdaz = '0.5' .
    ADD 1 TO cnt_days.
    ENDLOOP.
    endif.
    plz reward points if it helps

  • Excecute a planning sequence when open Web Template (JUST ONE TIME)

    Hello experts,
    I want to excecute a planning sequence everytime when a webtemplate is opened.
    I use the "Action before first display" for this. The problem is, that the planning sequence is excecuted multiple times when I open the web template. The web template contains several queries. Could it be that the planning sequence is started for every query?
    If yes is there a way to suppress this? I want to run the planning sequence just one time for the whole web template
    Thanks
    Johannes

    Yes I tried in action before rendering it is the same behaviour with the difference that the sequence is also executed after clicking on a button with another planning sequence. Action before first display is excactly what I need but I want to run the sequence just one time when the web template is loaded and not for every query. We don't use tabs at all.
    Thanks
    Johannes

  • Is there an upper limit to the number of emails "Send With Document" will send to at one time?

    I am using LiveCycle ES3 10.0.2 SP1 and Worbench/ADEP 10.0.0.0.20110711.1.291006.
    I have selected “Send With Document” for my Service Operation from the Service Name “EmailService” from the Category “Foundation”.
    It works correctly to send to a few emails in the email string, but stalls on the full list of almost 700 emails. My string length is unlimited.  Is there a threshold for the number of emails that it can send to at one time?

    Please use the correct version of the WorkBench which is compatible with your LiveCycle ES3 server.There should not be any limit as long as the email service is up. You should refer to the server log file to check exactly what error is being encountered.
    Thanks,
    Wasil

  • Just one time use?

    Can I convert a Word Document into PDF without buying the yearly package.  I just want to do it one time?

    Hi dianna50,
    If you did decide to purchase a subscription to PDF Pack and give it a go, you are able to cancel within 30 days and get your money back. Adobe also offers a free 30-day trial to Acrobat, which not only lets you create PDF files, but edit them as well.
    If you decide to give it a try and need help with anything, please let us know.
    Best,
    Sara

  • E63: Webaccess via WLAN just one time until restar...

    Hi all,
    I've some troubles with a brand new E63. I can connect to the SE515-WLAN-Router-ADSL-Modem, i can surfing, receiving e-mails so on. WLANsetting is on demand. Now I finish all activities. Two minutes later I want to surf again. This time the E63 says: System Error or No Gateway reply. If I reboot the Router, I can surf one time again.
    I have also an E51 and it works fine with the same router.
    Guess, it's a router issue, but how to solve it?

    Look man
    From your speech , I could get that your old phone isn't Nokia 
    or it may be nokia S40 (like : 5200 , 5300 , 6300 ......) 
     Now the problem is that your old phone system isn't the same as nokia E63 system.The folders of the old system may cause conflict with the new one (resulting in (GSE : General System Error ) that you get)
    So the first thing you should have done is copying all thing from your old Micro-SD   to PC then format the memory on PC (My computer ---> format ). Then after format , insert the memory into Your E63 , this will create some folders (video, sounds, documents , ....) 
    When you solve this problem the following problems will be solved .
    Another thing you don't probably know is that 99.9999999 % of Nokia users don't copy images or any other thing from messages by clicking "save" as you have done, instead, they use Xplore.
    Xplore makes mobile the same as PC
    get it from here:
    Note : I am not telling u to buy Xplore, use the free version , it's the as full one but for the 3 seconds banner when you run it.
    Use Xplore to go to message inbox b : open xplore ----- > Menu --- > tools -----> options
    Ayman Ahmed

  • With the paid version - How many people can I send to at one time? Are there any download limitations (bandwidth or number of downloads limitation)?

    I've grown to hate Hightail and was attempting to find out how Adobe Send compared - but the documentation is pitiful. I do webinars which means I may have a 200-400 people who will be downloading the file. Does the paid version allow this? What's the maximum size and the maximum number of downloads? 

    As you can see from other postings on this forum, we're currently experiencing upload problems for very large files, especially over slower internet connections. I suggest that you try to upload these files to your account at https://cloud.acrobat.com and then create Public links from there. You can then distribute the Public links for your users to access the files.

  • How to create one time pop-up window?

    I'd like to have a pop-up window called "how to use this app" show up just one time; the first time a user opens the folio to read it for instruction but then not appear again after it is closed. How could I do this? Thanks.

    I have not tried the "alert-box technique" yet.
    I have found code that will only display for first time visitors. How would I add an image to the below code with a link to a website?
    newwin=open("yourpage.htm", "dispwin",
    "width=350,height=350,scrollbars=no,menubar=no");

  • InputStream and playback more than one time

    Hi,
    I'm trying to playback multiple times the sound I captured with microphone.
    But the method playAudio() manage to listen to the sound just one time. Which way can I use to listen many times the sound ??
    I don't want to use Clip !!!!!
    Here is my code :
    public void captureAudio() {
        try {
            final AudioFormat format = getFormat();
          DataLine.Info info = new DataLine.Info(
            TargetDataLine.class, format);
          final TargetDataLine line = (TargetDataLine)
            AudioSystem.getLine(info);
          line.open(format);
          line.start();
          Runnable runner = new Runnable() {
            int bufferSize = (int)format.getSampleRate()
              * format.getFrameSize();
            byte buffer[] = new byte[bufferSize];
            public void run() {
              out = new ByteArrayOutputStream();
              running = true;
              try {
                while (running) {
                  int count =
                    line.read(buffer, 0, buffer.length);
                  if (count > 0) {
                        out.write(buffer, 0, count);
                out.close();
              } catch (IOException e) {
                System.err.println("I/O problems: " + e);
                System.exit(-1);
          captureThread = new Thread(runner);
          captureThread.start();
        } catch (LineUnavailableException e) {
          System.err.println("Line unavailable: " + e);
          System.exit(-2);
        if(!running){running = true;};
      public void playAudio() {
        try {
          byte audio[] = out.toByteArray();
          InputStream input =
            new ByteArrayInputStream(audio);
          final AudioFormat format = getFormat();
          final AudioInputStream ais =
            new AudioInputStream(input, format,
            audio.length / format.getFrameSize());
          DataLine.Info info = new DataLine.Info(
            SourceDataLine.class, format);
          final SourceDataLine line = (SourceDataLine)
            AudioSystem.getLine(info);
          line.open(format);
          line.start();
          Runnable runner = new Runnable() {
            int bufferSize = (int) format.getSampleRate()
              * format.getFrameSize();
            byte buffer[] = new byte[bufferSize];
            public void run() {
              try {
                int count;
                while ((count = ais.read(
                    buffer, 0, buffer.length)) != -1 && !running) {
                 if (count > 0) {
                            line.write(buffer, 0, count);
                line.drain();
                line.close();
              } catch (IOException e) {
                System.err.println("I/O problems: " + e);
                System.exit(-3);
          playThread = new Thread(runner);
          playThread.start();
        } catch (LineUnavailableException e) {
          System.err.println("Line unavailable: " + e);
          System.exit(-4);
      }Thanks

    I play it back the first time correctly. But if I stop it before the end or let it playing until the end, I'm unable to start it again when I click on the play button.
    Here is a piece of the whole code (more than 7500 characters):
    class Lecture extends JFrame
         private AudioInputStream lecteurAudio;
         private AudioFileFormat formatFichier;
         private AudioFormat format;
         private SourceDataLine line;
         public boolean running;
         private Thread captureThread;
         private volatile boolean exitRequested;
        private volatile boolean isPaused;
        private volatile boolean isCancelled;     
         public Lecture()
              running=true;
         public void AudioFromFile(File fichier) throws UnsupportedAudioFileException, IOException, LineUnavailableException
          this.lecteurAudio = AudioSystem.getAudioInputStream(fichier);
               this.formatFichier = AudioSystem.getAudioFileFormat(fichier);
               this.format = lecteurAudio.getFormat();
               if((this.format.getEncoding() == AudioFormat.Encoding.ULAW) ||
                  (this.format.getEncoding() == AudioFormat.Encoding.ALAW))
                 //convertion du format
                 AudioFormat tmp = new AudioFormat(
                     AudioFormat.Encoding.PCM_SIGNED,
                     this.format.getSampleRate(),
                     this.format.getSampleSizeInBits() * 2,
                     this.format.getChannels(),
                     this.format.getFrameSize() * 2,
                     this.format.getFrameRate(),
                     true);
                 this.lecteurAudio = AudioSystem.getAudioInputStream(tmp, this.lecteurAudio);
                 this.format = tmp;
               DataLine.Info info = new DataLine.Info(
                   SourceDataLine.class,
                   this.lecteurAudio.getFormat(),
                   ((int)this.lecteurAudio.getFrameLength() *
                    this.format.getFrameSize()));
               line = (SourceDataLine)AudioSystem.getLine(info);
               line.open(format);
               line.start();
               if (line != null) {
                  try {
                      line.close();
                  } catch (Exception e) {
         public void Piste()
              DataLine.Info info = new DataLine.Info(SourceDataLine.class, this.lecteurAudio.getFormat());
               try {
                     if (line == null) {
                         boolean bIsSupportedDirectly = AudioSystem.isLineSupported(info);
                         if (!bIsSupportedDirectly) {
                             AudioFormat sourceFormat = lecteurAudio.getFormat();
                             AudioFormat targetFormat = new AudioFormat(
                                     AudioFormat.Encoding.PCM_SIGNED,
                                     sourceFormat.getSampleRate(),
                                     sourceFormat.getSampleSizeInBits(),
                                     sourceFormat.getChannels(),
                                     sourceFormat.getChannels() * (sourceFormat.getSampleSizeInBits() / 8),
                                     sourceFormat.getSampleRate(),
                                     sourceFormat.isBigEndian());
                             lecteurAudio = AudioSystem.getAudioInputStream(targetFormat, lecteurAudio);
                             format = lecteurAudio.getFormat();
                         line = getSourceDataLine(format);
                     line.open(format);
                 } catch (Exception e) {
                     e.printStackTrace();
                     return;
           Runnable runner = new Runnable(){
            int nRead = 0;
            byte[] abData = new byte[(int)format.getSampleRate()* format.getFrameSize()];
            boolean startResume;
            public void run(){
            do {
                startResume = false;
                line.start();
                while (nRead != -1 && !exitRequested) {
                    try {
                        nRead = lecteurAudio.read(abData, 0, abData.length);
                    } catch (IOException e) {
                        e.printStackTrace();
                    if (nRead >= 0) {
                             line.write(abData, 0, nRead);
                if (exitRequested && !isPaused) {
                    //cancel
                    line.stop();
                    line.flush();
                } else if (isPaused) {
                    line.stop();
                    line.drain();
                    try {
                        while (isPaused) {
                            Thread.sleep(20);
                        startResume = true;
                    } catch (InterruptedException ex) {
                        //if interrupted...
                        cancel();
           } while (startResume);
        captureThread = new Thread(runner);
        captureThread.start();
         private SourceDataLine getSourceDataLine(AudioFormat format) {
            Exception audioException = null;
            try {
                DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
                Mixer.Info [] arr = AudioSystem.getMixerInfo();
                Arrays.sort(arr, new Comparator() {
                    public int compare(Object o1, Object o2) {
                        Mixer.Info m1 = (Info) o1;
                        Mixer.Info m2 = (Info) o2;
                        if("Java Sound Audio Engine".equals(m1.getName()))
                            return -1;
                        if("Java Sound Audio Engine".equals(m2.getName()))
                            return 1;
                        return 0;
                for (Mixer.Info mi : arr) {
                    SourceDataLine dataline = null;
                    try {
                        Mixer mixer = AudioSystem.getMixer(mi);
                        dataline = (SourceDataLine) mixer.getLine(info);
                        dataline.open(format);
                        dataline.start();
                         System.out.println(mi.getName());
                        return dataline;
                    } catch (Exception e) {
                        audioException = e;
                    if (dataline != null) {
                        try {
                            dataline.close();
                        } catch (Exception e) {
            } catch (Exception e) {
                throw new IllegalStateException("Error trying to aquire dataline.", e);
            if (audioException == null) {
                throw new IllegalStateException("Couldn't aquire a dataline, this computer doesn't seem to have audio output?");
            } else {
                throw new IllegalStateException("Couldn't aquire a dataline, probably because all are in use. Last exception:", audioException);
          public boolean isPaused() {
                 return isPaused;
         public void setPaused(boolean pause) {
                 if (line != null) {
                     if (pause) {
                         isPaused = true;
                         exitRequested = true;
                     } else {
                         isPaused = false;
                         exitRequested = false;
         public void cancel() {
                 isPaused = false;
                 exitRequested = true;
                 isCancelled = true;
        public boolean isCancelled() {
                 return isCancelled;
        public void close() {
                 if (line != null) {
                     line.close();
    }Edited by: bascyr on 8 mai 2010 16:29

  • One time Discount Coupon to be used during the Sales Order Creation

    I need help to configure a one time coupon to be used during a Sales Order creation. During 2009 our customers that have purchased more than certain amount we are going to give them a discount Coupon with a code that they can use just one time during his next purchase. I need help to configure this request.
    Thanks

    Hi Gilberto
    Go VK11.
    After maintaining the material & price, please go to -->Additional data.
    You will be displayed with Validity, Assignments, Assignments for retail promotion, Limits for Pricing, Payments.
    In the 'Limits for Pricing' you have three options - Max. condition value, Max number of orders & Max condition base value.
    In the Max number of Orders - enter 1 to avail this special price only for first order.
    Importent Note: to activate the ' Limit of Pricing' -- you need to tick 'Condition update' for the particular contion type, in condition type customising.
    FOr eg. condition type - ZR00 - you need to have special price for this condition type & want to limit only for first order order.
    In the customising for ZR00 - 'condition update' need to be ticked, then only you can get the above option.
    i hope it is clear to you
    thank you
    Anirudh

  • Just one filter for queries on workbook

    Hi all,
    In a workbook i have three queries with a common free characteristic. What can i do to have just one filter on the workbook for the three queries ?.
    thanks a lot

    And how to create a common variable for 3 query??
    Is the same variable will be understand by all query if we have just one insetion (the user inter the variable just one time) because it is common?
    very interesting
    thank tc

  • I need write code executable at one time defined

    I need write a code what a one time defined trigger a pl/sql, i know that command exist but in this moments not remember this command please help me.
    Thanks

    I am not sure if this is what you are looking for, but you can add a section at the end of a package body that will be executed one time only, when the package is first invoked within the user session. Although it must be placed at the end of the package body, it will be executed just one time before anything else in the package is executed. Here is an example:
    SQL> CREATE OR REPLACE PACKAGE test_one_time_only
      2  AS
      3    PROCEDURE every_time;
      4  END test_one_time_only;
      5  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY test_one_time_only
      2  AS
      3    -- this will execute every time:
      4    PROCEDURE every_time
      5    IS
      6    BEGIN
      7      DBMS_OUTPUT.PUT_LINE ('every time');
      8    END every_time;
      9 
    10  -- this will execute one time only:
    11  BEGIN
    12    DBMS_OUTPUT.PUT_LINE ('one time only');
    13 
    14  END test_one_time_only;
    15  /
    Package body created.
    SQL> SET SERVEROUTPUT ON
    SQL> EXEC test_one_time_only.every_time
    one time only
    every time
    PL/SQL procedure successfully completed.
    SQL> EXEC test_one_time_only.every_time
    every time
    PL/SQL procedure successfully completed.
    SQL> EXEC test_one_time_only.every_time
    every time
    PL/SQL procedure successfully completed.

  • App that can send more than one attachment at a time....

    Does anyone know of a app that I can send more than one attachment at a time like resumes + cover letters. Not having any luck with gmail or pages for the Ipad.
    Please help

    The MPEG Streamclip app can batch process videos. It can even convert up to  4 videos at the same time.
    http://www.squared5.com/
    It's free...
    Just drop as many videos as you like into the batch window.

  • Sending more than one photo at a time

    OK, fine, no MMS. We have to e-mail our pics to our friends.
    But is there any way on an iPhone 3G to send more than one photo attachment at a time? Sometimes I'd like to send two or three pixs to my friends of an event and that means two or three separate e-mails that have to be addressed.
    Can't I just tag or mark more tan a single photo and send the bunch?

    unfortunately, its 1 picture only

  • I'm using an iPhone 4. I used to be able to send more than one picture at a time to another iPhone. Now I get messages that it cannot be delivered.  What's going on?

    While on vacation in Canada in July I started having trouble sending more than one pix at a time to other users. I don't recall having this problem before. Is there a limit on the number of pictures you can send via text? I wonder if I messed up some settings while I was in Canada. I had things set so that I could not receive phone calls so I wouldn't get charged.  Could I have messed up text / multimedia settings as well?

        We want your phone working just as well now as it did before your trip, sngbrd9. Are you trying to send the pictures to other Apple users using iMessage or are they being sent through MMS/picture messaging? Are you able to send pictures one at a time to those same contacts without an error? Did you change any settings in your camera to have HDR now instead of a slightly lower resolution with a smaller file size? 
    JenniferH_VZW
    Follow us on Twitter www.twitter.com/vzwsupport

Maybe you are looking for