Hi,
I'm currently developing a small software for reading and writing 256-Byte I²C-Cards.
I'm using the Smardcard Framework 2010 from here:
Smardcard Framework 2010
Now to the problem with reading from the card.
What I have tried:
That is currently my code, extracted from the sample of the framework:
Initialization:
_cardReaders = new CardNative();
_apduPlayer = new APDUPlayer(APDU_LIST_FILE, _cardReaders);
Code if Cardreader is connected:
_reader = new Reader(readerList.Single(m => Equals(m, CARDREADER_NAME_OMNIKEY)));
_reader.CardInserted += OnCardInserted;
_reader.CardRemoved += OnCardRemoved;
_reader.StartCardEvents();
Code for Reading the Card:
_cardReaders.Connect(CARDREADER_NAME_OMNIKEY, SHARE.Shared, PROTOCOL.T0orT1);
APDUParam apduParam = new APDUParam();
apduParam.P1 = byte.Parse("00", NumberStyles.AllowHexSpecifier);
apduParam.P2 = byte.Parse("00", NumberStyles.AllowHexSpecifier);
apduParam.Le = byte.Parse("0", NumberStyles.AllowHexSpecifier);
APDUResponse apduResponse = _apduPlayer.ProcessCommand("A0", "B0", apduParam);
If I execute this code, I'm getting one of the exceptions by random, thrown in CardBase:
SmardCardException: SCardTransmit error: 06
SmardCardException: SCardListReaders error: FFFFFFFF80100004
sometimes it passes the method and returns a hex code as the "data"-value of the APDUResponse. I can't figure out why it sometimes passes and sometimes not.
I haven't found any documentation about the error codes.
What I am doing wrong? Is there a better smardcard framework available?
Thanks for any help!