Dear Gurus,
I am a newcomer in the Java Card World.
I have written only a few test applets to run on the card, similar to the
examples provided by the Sun Microsystems.
Moving forward, I have found, that in the Java Card 2.1.1 Application
Programming Interface they recommend to use slightly different technique to
send and receive APDU, than in the examples.
How would you explain the following part of the javacard.framework.APDU
class documentation:
"The incoming APDU data size may be bigger than the APDU buffer size and may
therefore need to be read in portions by the applet."
What is the correct way of APDU buffer usage:
First variant:
/***** Step1: receive all incoming APDU data *****/
short readCount = apdu.setIncomingAndReceive();
short bytesLeft = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
while ( bytesLeft > 0){
bytesLeft -= readCount;
readCount = apdu.receiveBytes ( ISO7816.OFFSET_CDATA );
/***** Step2: acces any part of the TOTAL resulting APDU buffer to process
data ***** /
processAllBuffer();
}
Second variant:
/***** Step1: receive the portion of the incoming APDU data (of the
readCount length) *****/
short readCount = apdu.setIncomingAndReceive();
short bytesLeft = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
while ( bytesLeft > 0){
/***** Step2: access only this particular portion of the APDU data to
process *****/
processPortionOfBuffer();
bytesLeft -= readCount;
readCount = apdu.receiveBytes ( ISO7816.OFFSET_CDATA );
}
Thanks!
With every good wish to all of you,
Sergio.
______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup
---
> Visit the OpenCard web site at http://www.opencard.org/ for more
> information on OpenCard---binaries, source code, documents.
> This list is being archived at http://www.opencard.org/archive/opencard/
! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email
! to
! [EMAIL PROTECTED]
! containing the word
! unsubscribe
! in the body.