Hi.
I want to read serial number from smart card with help of OCF and reader.
But I can not find solution?
The next piece o code returns:
sw1 = 6d +>>>>>>>> Card does not support instruction class+
sw2 = 00
data = null
import opencard.core.event.CTListener;
import opencard.core.event.CardTerminalEvent;
import opencard.core.event.EventGenerator;
import opencard.core.service.SmartCard;
import opencard.core.terminal.CardTerminal;
import opencard.core.terminal.CommandAPDU;
import opencard.core.terminal.ResponseAPDU;
import opencard.opt.util.PassThruCardService;
public class Listener implements CTListener {
private SmartCard smartcard = null;
private CardTerminal terminal = null;
private int slotID = 0;
public void register() {
EventGenerator.getGenerator().addCTListener(this);
try {
EventGenerator.getGenerator().createEventsForPresentCards(this);
} catch (Exception e) {
e.printStackTrace(System.err);
unregister();
}
}
public void unregister()
{
EventGenerator.getGenerator().removeCTListener(this);
}
public void cardInserted(CardTerminalEvent event) {
try {
smartcard = SmartCard.getSmartCard(event);
PassThruCardService ptcs = (PassThruCardService) smartcard
.getCardService(PassThruCardService.class, true);
PassThruCardService ptcs = (PassThruCardService) smartcard
.getCardService(PassThruCardService.class, true);
CommandAPDU apdu = new CommandAPDU(0x0045);
ResponseAPDU res = ptcs.sendCommandAPDU(apdu);
System.out.print(apdu.toString() + res.toString());
System.out.printf("sw1 = %02x\n", res.sw1());
System.out.printf("sw2 = %02x\n", res.sw2());
System.out.println("data = " + res.data());
terminal = event.getCardTerminal();
slotID = event.getSlotID();
} catch (Exception e) {
e.printStackTrace();
}
}
public void cardRemoved(CardTerminalEvent event) {
}
}
Can anybody help me?
Thank in advance