Hi all,
Currently I'm making myself familiar with NFC. For that reason I
started with a simple program which simply reads a tag's serial number
(see code below). The program is working fine in a Windows
environment. However, running the same program under OSX Lion does not
work. To be more specific: The program causes a segmentation fault in
libj2pcsc.dylib which I assume is javax.smartcard's JNI wrapper to
PC/SC. The behavior suggests that there might be some kind of race
condition. Moving code from inside a loop to the outside changes the
behavior (regarding the seg fault) and also simply introducing delays
sometimes changes it. I also tried sample code provided by Springcard
and got the same results. I do not thing that this problem is related
to the Springcard terminal. Doing the same with a smartcard terminal
and a smartcard causes the same problem.
I have a Springcard NFC'Roll and a Reiner-SCT cyberjack ecom terminal
connected to the machine. In order to make the NFC'Roll working I
replaced the CCID driver shipped with OSX with a recompiled version
(1.4.9) in which I added the terminal's vendor and product IDs.
Here is what I tried to get rid of the problem. First of all I updated
my Java6 to the latest version assuming that a new version of the JNI
wrapper would be shipped. Now the version is 1.6.0_37. Unfortunately
that did not solve the problem. Next step was installing Java7 but
that did not eliminate the problem either. Here is the output I get:
Invalid memory access of location 0x0 rip=0x109e6f66e
java(621,0x1014ae000) malloc: *** mmap(size=140527034961920) failed
(error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
I also have the log files generated by the JVM.
Any suggestion what can be done to get rid of that problem. Any help
is much appreciated.
Best
Wolfgang
=======================
try {
while (true) {
// show the list of available terminals
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Terminals: " + terminals);
// get the first terminal
CardTerminal terminal = terminals.get(1);
if (terminal.isCardPresent()) {
// establish a connection with the card
Card card = terminal.connect("*");
System.out.println("card: " + card);
// print card's ATR
ATR atr = card.getATR();
System.out.println("atr: " + atr.toString());
System.out.println("ATR bytes");
HexDump.dump(atr.getBytes(), 0, System.out, 0);
System.out.println("Historical bytes");
HexDump.dump(atr.getHistoricalBytes(), 0, System.out, 0);
// Retrieve serial number
byte[] c1 = {(byte) 0xff, (byte) 0xca, (byte) 0x00,
(byte) 0x00, (byte) 0x00};
CardChannel channel = card.getBasicChannel();
ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
System.out.println("Card S/N");
HexDump.dump(r.getData(), 0, System.out, 0);
System.out.println();
// disconnect
try {
Thread.sleep(2000);
}
catch (InterruptedException ie) {
}
card.disconnect(false);
}
}
}
catch (Exception exc) {
exc.printStackTrace();
}
_______________________________________________
Muscle mailing list
[email protected]
http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com