Page 1 of 1

How to send INT and Byte together

Posted: Mon Sep 28, 2020 12:32 pm
by sam786
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!!!

Re: How to send INT and Byte together

Posted: Wed Sep 30, 2020 5:22 pm
by kuafu

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]

Re: How to send INT and Byte together

Posted: Fri Nov 27, 2020 3:47 pm
by sam786
Thanks kuafu,

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

:D :D :D :D