Click here to Skip to main content
15,914,417 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
_cardReaders = new CardNative();
_apduPlayer = new APDUPlayer(APDU_LIST_FILE, _cardReaders);



Code if Cardreader is connected:
C#
_reader = new Reader(readerList.Single(m => Equals(m, CARDREADER_NAME_OMNIKEY)));

_reader.CardInserted += OnCardInserted;
_reader.CardRemoved += OnCardRemoved;

_reader.StartCardEvents();



Code for Reading the Card:
C#
_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!
Posted

1 solution

Ask your question in the forum at the bottom of the article you linked to. The best person to ask about this is the person who wrote the code you're asking about. Article authors support their articles.
 
Share this answer
 
Comments
Member 8024025 10-Feb-16 16:21pm    
Ok I posted the question there.
But I will leave the question here, if anyone know another smardcard framework as an alternative.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900