if (null == cardId) {
try {
cardId = SCardConnect(contextId, name, sharingMode, connectProtocol);
byte[] status = new byte[2];
byte[] atrBytes = SCardStatus(cardId, status);
atr = new AnswerToReset(atrBytes);
if (ACTIVATION_ANY == activation) {
logAtr(atr);
}
this.protocol = NimpPcScTerminalManager.win32Protocol2GenericTerminalProtocol(status[1]);
//basicChannel = new ChannelImpl(this, 0);
state = State.CARD_PRESENT;
} catch (PcScException e) {
if (e.code == NimpPcScTerminalManager.SCARD_W_REMOVED_CARD) {
throw new CardNotPresentException("No card present", e);
} else {
throw new ScardException("connect() failed", e);
}
}
}
if ((null == atr) || (ACTIVATION_ANY != activation)) {
try {
SCardReconnect(cardId, sharingMode, connectProtocol, activationPolicy);
byte[] status = new byte[2];
byte[] atrBytes = SCardStatus(cardId, status);
atr = new AnswerToReset(atrBytes);
logAtr(atr);
this.protocol = NimpPcScTerminalManager.win32Protocol2GenericTerminalProtocol(status[1]);
//basicChannel = new ChannelImpl(this, 0);
state = State.CARD_PRESENT;
} catch (PcScException e) {