Hi Max, Max Kliche schrieb:
HelloThis example is for exclusive use with the OpenCard DEMOCARD. Do you actually use that card?
I'm trying to get my Towitoko Serial chipcard reader to work with
OCF.
For this, I installed the Open Chipcard Framework, and the PC/SC Lite
sources, the OCF To PC/SC Shim, and the driver for my reader.
the PC/SC tools work just fine. I start the pcscd and all tests
passed.
But if I try to communicate from within Java/OCF, I can't connect to
my reader.
I tried a lot of opencard.properties but without success.
The Java Testprogramm is the first example out of the Programming
Guide.
My opencard.proporties looks like:
OpenCard.terminals=\
com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactory|my|GCR410|SHARED
OpenCard.trace = opencard:5
Looks like Gemplus' pcsc-wrapper-2.0. The original IBM CardTerminal implementation does not support the extra parameters. To be on the safe side, remove them. Especially the 'SHARED' is a very sensitive param, that might not work in every environment.
My readers.conf # Towitoko Chipdrive Micro (COM1) FRIENDLYNAME "Towitoko Chipdrive Micro" DEVICENAME TOWITOKO_CHIPDRIVE_MICRO LIBPATH /opt/chipkarte/lib/libtowitoko.so.2.0.0 CHANNELID 0x000001
Looks good.
The programm compiles fine ( http://www.kliche.org/max/tmp/OpenCardMain.java ) but if I start it, I got this errors: opencard.core.terminal.CardTerminalException: Pcsc10CardTerminalFactory: PCSC Ex ception in method SCardListReaders: error getting length of reader list return code = 80100003 This error comes, if the pcscd isn't running.
What else do you expect?
You should write your _own_ card service and factory for your _own_ card, if your card isn't supported by an OCF reference service, like the FileAccessService. For some ISO-cards it should work with opencard.opt.util.PassThruCardServiceFactory.If I start the deamon, the programm give the following Output, but no return: [ max@pluto ] $ java OpenCardMain Reading smartcard file... Uses ISOTPDU Did I make a big misstake and which part of the documentation I have to read twice? Max
Background: The opencard.properties-configured card service factories determine the service to load by looking at the ATR.
If the ATR of your card isn't suported by the factories, you will see not much ;)
You see more, if you set various debug levels to 8:
OpenCard.trace = opencard:8 com.ibm:8 \ opencard.core.service.CardServiceRegistry:8
Try this code to test just the terminal functionality:
----------------------------------
import java.util.Enumeration;
import opencard.core.service.SmartCard;
import opencard.core.terminal.CardTerminal;
import opencard.core.terminal.CardTerminalException;
import opencard.core.terminal.CardTerminalRegistry;
import opencard.core.util.HexString;
/**
* This demo shows how to start OCF framework, how to obtain information
* about card readers installed on a computer and smartcard inserted in
* this readers.
*/
public class TerminalSample
{
public static void main(String[] args)
{
try {
// Starting the OCF framework. The information in opencard.properties
// file is parsed and cardreaders specified there are registered in
// OCF
SmartCard.start ();
// Get the CardTerminalRegistry. With this class you can register
// and unregister card readers dynamically. You can also obtain
// information about readers registered in OCF
CardTerminalRegistry ctr = CardTerminalRegistry.getRegistry ();
// Get a list of all readers registered in OCF
Enumeration terminals = ctr.getCardTerminals ();
while (terminals.hasMoreElements () ) {
// Get an object representing a particular reader
CardTerminal terminal = (CardTerminal) terminals.nextElement ();
// Print information about this reader
printTerminalInfos (terminal);
}
// Finally OCF framework has to be closed
SmartCard.shutdown ();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void printTerminalInfos (CardTerminal terminal)
{
// First of all print all information stored about this reader
System.out.println (
"Address: " + terminal.getAddress () + "\n" +
"Name: " + terminal.getName () + "\n" +
"Type: " + terminal.getType () + "\n" +
"Slots: " + terminal.getSlots() + "\n");
int slots = terminal.getSlots();
for (int j = 0; j < slots; j++)
{
// Now print information about every card slot in this reader
printSlotInfos (terminal,j);
}
}
public static void printSlotInfos (CardTerminal terminal, int aSlotID)
{
try {
// First print the ID of the slot
System.out.println ("Info for slot ID: " + aSlotID );
if (terminal.isCardPresent(aSlotID))
{
System.out.println ("card present: yes");
// If there is a card in the slot print the ATR the OCF got form this card
System.out.println ("ATR: " +
HexString.hexify(terminal.getCardID(aSlotID).getATR()));
// As we do not have a driver for this card we cannot interpret this ATR
} else
System.out.println ("card present: no");
}
catch(CardTerminalException e)
{
e.printStackTrace();
}
}
}
----------
HTH
Martin
_______________________________________________
Muscle mailing list
[EMAIL PROTECTED]
http://lists.musclecard.com/mailman/listinfo/muscle
