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

How to send INT and Byte together

JavaCard Applet Development Related Questions and Answers.
sam786
Posts: 5
Joined: Mon Sep 28, 2020 10:25 am
Points :112
Contact:

How to send INT and Byte together

Post by sam786 » Mon Sep 28, 2020 12:32 pm

Hi am new to javacardos and was hoping that someone could help me out?
I am trying to send APDU’s with the values: 31 84 A5
Here is a sample of my code below:

Code: Select all

private void SendData(APDU apdu) 
   {
      byte [] buffer = apdu.getBuffer();
      byte sendBytes[] = {0x31, 0x84, 0xA5};
      short len = (short) sendBytes.length;
      Util.arrayCopyNonAtomic(sendBytes, (short)0, buffer, (short)0, (short)len);
      apdu.setOutgoing();
      apdu.setOutgoingLength(len);
     apdu.sendBytes((short) 0, (short)len);
   }	

}
When I compile this code I get the following error:
found : int
required: byte
byte sendBytes[] = {0x31, 0x84, 0xA5};
^
2 errors

I know that the bytes ‘84’ and ‘A5’ are Int variables
How do I send Int variables and bytes together?
The output data I am looking for is: 31 84 A5

A sample of the script would be greatly appreciated as well as an explanation.

Thanks in advance!!!

kuafu
Posts: 317
Joined: Thu Jun 25, 2015 2:09 am
Points :4563
Contact:

Re: How to send INT and Byte together

Post by kuafu » Wed Sep 30, 2020 5:22 pm

Code: Select all

[code]private void SendData(APDU apdu) 
   {
      byte [] buffer = apdu.getBuffer();
      byte sendBytes[] = {0x31, (byte)0x84, (byte)0xA5};
      short len = (short) sendBytes.length;
      Util.arrayCopyNonAtomic(sendBytes, (short)0, buffer, (short)0, (short)len);
      apdu.setOutgoing();
      apdu.setOutgoingLength(len);
     apdu.sendBytes((short) 0, (short)len);
   }	
[/code]
well

sam786
Posts: 5
Joined: Mon Sep 28, 2020 10:25 am
Points :112
Contact:

Re: How to send INT and Byte together

Post by sam786 » Fri Nov 27, 2020 3:47 pm

Thanks kuafu,

really appreciate your help!!!!!!!!!!

:D :D :D :D

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 22 guests

JavaCard OS : Disclaimer