sun.security.smartcardio.PCSCException: Unknown error 0x8010002f
Hi All
I am writing java application to talk with smart card (need to format my card)
every thing is ok till i reach to this command:
private static byte[] COMMAND2 = {(byte) 0xEF, (byte) 0xFA, (byte) 0xCE, (byte) 0x00, (byte) 0xFF};
private static CommandAPDU COMMAND2_APDU = new CommandAPDU(COMMAND2);
it is CARD RECYCLE COMMAND
i use it to make format for my card
//Code
connectWithCard();
sendAPDU1();
card.disconnect(true); //Reset must occur before
try{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("Exception for sleep : "+e.getMessage());
}
connectWithCard();
ra=ch.transmit(COMMAND2_APDU);//Exception occur here
System.out.println("Response due to COMMAND2_APDU : " + arrayToHex(ra.getBytes()));
//implementation for connectwithCard()
try {
card = c.connect("T=0");
// System.out.println("Terminal connected");
} catch (Exception e) {
// System.out.println("Terminal NOT onnected: " + e.toString());
}
System.out.println("ATR: " + arrayToHex(((ATR) card.getATR()).getBytes()));
ch = card.getBasicChannel();
Exception is:
javax.smartcardio.CardException: sun.security.smartcardio.PCSCException: Unknown error 0x8010002f
What should i do ?
Thanks in Advance
Re: sun.security.smartcardio.PCSCException: Unknown error 0x8010002f
Hi Nabil,
it looks like this not all code needed in order to reproduce your error (eg: what does connectWithCard();?). Secondly, please mention at which line the excpetion occurs.
You can find a full example for establishing a connection to your PC/SC Reader here <http://wiki.forum.nokia.com/index.php/NFC_Secure_Element_Example_External_Reader>
Please keep in mind that this requires
(a) JSDK 6.0
(b) Your contactless Reader to support PC/SC.
Cheers, Geri-m
Re: sun.security.smartcardio.PCSCException: Unknown error 0x8010002f
[QUOTE=geri-m;453163]Hi Nabil,
it looks like this not all code needed in order to reproduce your error (eg: what does connectWithCard();?). Secondly, please mention at which line the excpetion occurs.
You can find a full example for establishing a connection to your PC/SC Reader here <http://wiki.forum.nokia.com/index.php/NFC_Secure_Element_Example_External_Reader>
Please keep in mind that this requires
(a) JSDK 6.0
(b) Your contactless Reader to support PC/SC.
Cheers, Geri-m[/QUOTE]
Hi Geri-m,
I have downloaded the example mentioned above and opened it in NetBeans. I have an Omnikey Card Reader attached, which I am trying to use to connect to a smart card to retrieve a number from a smart card. I intend on using this number to run a query and retrieve information from a Database. When I run the program it seems to connect to the reader and even retrieves the number on the card but when it gets to line 80 (where the SELECT_APDU section begins), it skips down to line 111. It also displays an error of <PCSCException: Unknown error 0x1f
debug:> A card exception error but yet I have established a connection and my number has been retreived. The full debug output is below, any help on resolving this error would be greatly appreciated.
Updating property file: C:\Program Files (x86)\NetBeans 6.9.1\CardReader\ReaderApplication\build\built-jar.properties
compile:
List of PC/SC Readers connected:
Reader: OMNIKEY CardMan 5x21 0
Reader: OMNIKEY CardMan 5x21-CL 0
Terminal fetched
Terminal connected
ATR: 3b8f8001804f0ca000000306030001000000006a
Error isCardPresent()javax.smartcardio.CardException: sun.security.smartcardio.PCSCException: Unknown error 0x1f
debug:
BUILD SUCCESSFUL (total time: 2 minutes 23 seconds)
P.S. Looking at the above output i wonder is it something to do with the fact the program is showing two cards, when in fact there is only one attached.
Thanks in advance
Re: sun.security.smartcardio.PCSCException: Unknown error 0x8010002f
Hi Robwhe,
strange. The Reader detectes the Card and prints the ATR (Answer to Request). But on selecting the system fails. What kind of cards/devices are you trying to read with the OK-Reader?
best, Gerald
Re: sun.security.smartcardio.PCSCException: Unknown error 0x8010002f
Hallo,
[QUOTE=robwhe;821134]ATR: 3b8f8001804f0ca000000306030001000000006a[/QUOTE]
Translated according to PC/SC standard:
3b ... PC/SC initial
8f8001 ... T0|TD1|TD2
80
4f0c
a000000306 ... RID for storage card
03 ... ISO 14443-3 Type A
0001 ... MIFARE Classic 1K
00000000 ... RFU
6a
So the ATR you showed here suggests that you try to use a MIFARE Classic 1K card. This type of card is not APDU based but uses proprietary commands on a lower protocol layer (i.e. ISO 14443-3 Type A). Particularly it is no JavaCard.
Best regards,
Michael