You are all welcome to join our new Facebook page: https://www.b4x.com/android/forum/threads/new-facebook-group.167607
code here...
code here...
code here...
This is TakCore's tutorial on how to send bytes, and it works in a Windows environment :
Select Applet
As previously mentioned, the Smart Card has two applets installed. This command selects the Secure Element
Applet and routes subsequent APDU commands to it.
IsoCase: Case4Short
Class: 0x00
Instruction: 0xa4
P1-P2: 0x0400
Command Length (Lc): 0x10
Command Data: 0xA000000748464A492D546178436F7265
Expected Length (Le): 0x00
Example:
Request: 00A4040010A000000748464A492D546178436F726500
If i look user manual for IccCommand:
public int IccCommand(byte slot, byte[] apduSend, byte[] apduResp)
Parameter description
Slotcassette No.:
0x00-IC Card Channel;
0x01-PSAM1 Card Channel;
0x02-PSAM2 Card Channel;
ApduSend:
sent to the card’s apdu
ApduResp:
Receive the card's apdu of returned
Return
int
Function description
Read and Write IC Card
If both LC and LE exist, you should set "LC = X; LE = 0x01"
Example
byte cmd[] = new byte[4];
cmd[0] = 0x00; //0-3 cmd
cmd[1] = (byte) 0x84;
cmd[2] = 0x00;
cmd[3] = 0x00;
short lc = 0x00;
short le = 0x04;
String sendmsg = "";
byte [] dataIn = sendmsg.getBytes();
APDU_SEND ApduSend = new APDU_SEND(cmd, lc, dataIn, le);
APDU_RESP ApduResp = null;
byte[] resp = new byte[516];
ret = posApiHelper.IccCommand(slot, ApduSend.getBytes(), resp);
I see to Lc and Le must change place.
After that i get this message:
Open slot PDAM2
error = successfully
ATR = 133BF99600008031FE454A546178436F7265560F000000000000000000000000000000000000000000
00
APDU 00A40400A000000748464A492D546178436F72651000
Fatal signal 11 (SIGSEGV), code 1, fault addr 0xffa79000 in tid 6017 (om.ciontek.ePos)
byte cmd[] = new byte[4];
cmd[0] = 0x00; //0-3 cmd
cmd[1] = (byte) 0x84;
cmd[2] = 0x00;
cmd[3] = 0x00;
short lc = 0x00;
short le = 0x04;
String sendmsg = "";
byte [] dataIn = sendmsg.getBytes();
APDU_SEND ApduSend = new APDU_SEND(cmd, lc, dataIn, le);
APDU_RESP ApduResp = null;
byte[] resp = new byte[516];
ret = posApiHelper.IccCommand(slot, ApduSend.getBytes(), resp);
package vpos.apipackage;
public class APDU_SEND {
public byte[] Command = null;
public short Lc;
public byte[] DataIn = null;
public short Le;
public APDU_SEND(byte[] Command, short Lc, byte[] DataIn, short Le) {
this.Command = new byte[Command.length];
this.DataIn = new byte[DataIn.length];
this.Command = Command;
this.Lc = Lc;
this.DataIn = DataIn;
this.Le = Le;
}
public byte[] getBytes() {
byte[] buf = new byte[520];
System.arraycopy(this.Command, 0, buf, 0, this.Command.length);
buf[4] = (byte)(this.Lc / 256);
buf[5] = (byte)(this.Lc % 256);
System.arraycopy(this.DataIn, 0, buf, 6, this.DataIn.length);
buf[518] = (byte)(this.Le / 256);
buf[519] = (byte)(this.Le % 256);
return buf;
}
}
short lc = 0x00;
short le = 0x04;
According to their instructions Lc and Le is on end of line.