1

I am trying to connect to my smart card using serial port using below code:

String port = "COM1"; // serial port
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(port);

String appname = "CadClient";
int timeout = 30000;

CommPort commPort = portId.open(appname, timeout);              
InputStream is = commPort.getInputStream(); 
OutputStream os = commPort.getOutputStream();

cad = CadDevice.getCadClientInstance(CadDevice.PROTOCOL_T1, is, os);

//...hangs here for unlimited time
cad.powerUp();

Any help why it stuck at powerUp(). Thanks

naeemgik
  • 2,232
  • 4
  • 25
  • 47

2 Answers2

2

Go to your device properties and check the "Do not open APDU console" checkbox.

This should be something like this :

enter image description here

enter image description here

enter image description here

simplify
  • 109
  • 11
0

The most common reason for it to hang is that the card is not answering to reset i.e. ATR is not received from the card. This is done on powerUP().

This could be due to non-open port or port being used by some other APDU client.

hsg
  • 656
  • 4
  • 10
  • I assume the port is opened by cadClient only once, however how to make sure for this? – naeemgik May 21 '18 at 05:43
  • I believe that PORT is open (for service) by some cad device or running simulator. Your code here is a client to connect to that port and thereby, sending the APDU's to the running service. – hsg May 21 '18 at 12:33
  • so what you suggest please? – naeemgik May 24 '18 at 04:15