voici le code que j utilise pour analiser et visualiser les infos de la carte:
public void AnalyzeCard(CardTerminalSlot aCardSlot)
{
// Acquire any processor card (T=0 or T=1) that may be present in the given card
// terminal slot
string readerName = aCardSlot.CardTerminalName;
CardActivationResult nActivationResult;
DisplayText("Reader Name: " + readerName);
// Note: not all reader drivers return a Reader ID.
DisplayText("Reader ID: " + aCardSlot.CardTerminal.ProductAdditionalInfo);
CardHandle aCard = aCardSlot.AcquireCard((CardTypes.T0 | CardTypes.T1), out nActivationResult);
if (nActivationResult != CardActivationResult.Success)
{
Debug.Assert(aCard == null);
switch (nActivationResult)
{
case CardActivationResult.NoCard:
m_aPromptLabel.Text = readerName + ": Please insert card ...";
break;
case CardActivationResult.UnresponsiveCard:
m_aPromptLabel.Text = readerName + ": Unresponsive card.";
break;
case CardActivationResult.InUse:
m_aPromptLabel.Text = readerName + ": Card in use";
break;
default:
m_aPromptLabel.Text = readerName + ": Can't power up card!";
break;
}
return;
}
// we now have a card in the reader that is powered up
m_aPromptLabel.Text = readerName + ": Found card";
DisplayText("Found card in reader " + aCardSlot.CardTerminalName);
try
{
// =========================== ATR DETECTION ======================================
// Every card accessed through PC/SC must return an Answer To Reset (ATR).
// So let's see what we've got here.
byte[] atr = aCard.GetATR();
if (atr.Length == 0) throw new Exception("Invalid ATR");
DisplayText("ATR: " + CardHex.FromByteArray(atr, 0, atr.Length));
// ================================================================================
// Go a little deeper: is this a contact or contactless card system we are dealing with?
Program cardHelper = new Program(aCard);
if (cardHelper.isContactless)
{
DisplayText(cardHelper.cardInfo);
// =========================== APDU EXCHANGE ==================================
byte CL_CLA = 0xFF;
byte CL_INS_GET_UID = 0xCA;
byte P1 = 0;
byte P2 = 0;
CardCommandAPDU aCmdAPDU = new CardCommandAPDU(CL_CLA, CL_INS_GET_UID, P1, P2, 256);
CardResponseAPDU aRespAPDU;
aRespAPDU = aCard.SendCommand(aCmdAPDU);
if (!aRespAPDU.IsSuccessful)
{
DisplayText("WARNING: can't get a UID - this might be a contact card");
}
else
{
byte[] uidWithSw12 = aRespAPDU.GenerateBytes();
if (uidWithSw12.Length < 2) throw new Exception("Invalid UID");
DisplayText("UID: " +
CardHex.FromByteArray(uidWithSw12, 0, uidWithSw12.Length - 2));
}
//writeData(aRespAPDU, 1);
DisplaytextTest("Salut tout le monde");
}
//============================= Write data in smart card ========================================
Program HIDcard = new Program(aCard);
byte[] atr1 = {0x01, 0x00, 0x7D, 0x00, 0x00, 0x78 };
DisplaytextTest("la = " + HIDcard.setData(10, 20));
}
catch (Exception x)
{
Trace.WriteLine(x.ToString());
DisplayText(x.ToString());
m_aPromptLabel.Text = "Card access error";
}
finally
{
aCard.Dispose(); // release card handle
}
}
si quelqu un a une idee