This discussion is archived
7 Replies Latest reply: Aug 6, 2012 12:08 PM by 952006 RSS

How to connect to the local terminal?

952006 Newbie
Currently Being Moderated
Hello
I have made a simple card applet and a host application with eclipse JCDE and JCOP. The card applet goes well by using JCOP shell command like /select and /send apdu, but the host.application can not found the local terminal "Remote|localhost:51007".

The Log of the card app:
cm> card-info
=> 80 F2 80 00 02 4F 00 00 .....O..
(1077 usec)
<= 08 A0 00 00 00 03 00 00 00 01 9E 90 00 .............
Status: No Error
=> 80 F2 40 00 02 4F 00 00 ..@..O..
(3005 usec)
cm> /terminal "tcl:10"
jcshell: Cannot init/open terminal: Cannot load DLL: C:\Users\tang\Desktop\Javacard development\eclipse\plugins\com.ibm.bluez.jcop.ecl(
- /terminal "winscard:4|FT SCR2000 0"
--Opening terminal
/terminal "winscard:4|FT SCR2000 1"
--Opening terminal
/terminal "winscard:4|FT SCR2000B 0"
--Opening terminal
/select |Test
jcshell: Not connected to a card, reset card first!
- /terminal "Remote|localhost:51007"
--Opening terminal
/card
--Waiting for card...
ATR=3B E9 00 00 81 31 FE 45 4A 43 4F 50 34 31 56 32 ;....1.EJCOP41V2
32 A7 2.
ATR: T=1, N=0, IFSC=254, BWI=4/CWI=5, Hist="JCOP41V22"
=> 00 A4 04 00 07 A0 00 00 00 03 00 00 00 .............
(1667 usec)
<= 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 o..............e
01 FF 90 00 ....
Status: No Error
cm> /term
Terminal: Remote(Socket[addr=localhost/127.0.0.1,port=51007,localport=51086]/JCOP (built: Dec 1 2005 12:35:27))
Status: Card present, 00000004
Last error:



The Log of the Offcard app:
Terminals Found: 4
PC/SC terminal FT SCR2000 0
PC/SC terminal FT SCR2000 1
PC/SC terminal FT SCR2000B 0
PC/SC terminal FT SCR2000B 1
Card Not Present

Thank you!

Edited by: 949003 on 2012-7-28 上午7:48
  • 1. Re: How to connect to the local terminal?
    Umer Journeyer
    Currently Being Moderated
    You are misunderstanding something. Your host application cannot communicate with JCOP. You need to install applet on the card by using JCOP and then write your host application to connect with your card/card reader.
  • 2. Re: How to connect to the local terminal?
    952006 Newbie
    Currently Being Moderated
    Hello Umer

    Thank you for your reply. I am a newbie about java card development, I think there are some misunderstandings. For my understanding, I can install the card applet on the local card emulator, and write the host application to connet with the card emulator.

    So, in this situation(I don't have a card or card reader), how to test my host applications?
  • 3. Re: How to connect to the local terminal?
    Umer Journeyer
    Currently Being Moderated
    In that case if you do not have any real smart card, you cannot test your host application with your emulator like with JCOP. You can just test/debug your applet only.
  • 4. Re: How to connect to the local terminal?
    safarmer Expert
    Currently Being Moderated
    Hi,

    JCOP Tools has an offcard.jar library that contains the classes you need to communicate with the emulator. The emulator uses a protocol over TCP/IP and you can find help on this under Eclipse Help (NXP JCOP Tools -> Reference). You may be able to use this to test you applets with a host application.

    Shane
  • 5. Re: How to connect to the local terminal?
    952006 Newbie
    Currently Being Moderated
    Thanks a lot.
    I can test my Host application now.
  • 6. Re: How to connect to the local terminal?
    safarmer Expert
    Currently Being Moderated
    Thanks a lot.
    I can test my Host application now.
    It might be worth giving some details as to how you solved this so others can see how later (as someone is going to see this in a Google search one day) :)

    - Shane
  • 7. Re: How to connect to the local terminal?
    952006 Newbie
    Currently Being Moderated
    Of course!

    The problem is that I want test my host application, but the APIs from smartcardio can not connet with JCOP card emulator.

    The answer may be very simple, actually the JCOP has its own offcard APIs to connect with the local port, which is stroed in /lib/offcard.

    Here some codes can be usefull to connect with the local card emulator:
              JCTerminal terminal = JCTerminal.getInstance("Remote", LocalhostPort);
              terminal.open();
              TraceJCTerminal tt = new TraceJCTerminal();
              tt.setLog(new PrintWriter(System.out));
              tt.init(terminal);
              terminal = tt;
              JCard card = new JCard(terminal, null, 1000);
              byte[] aid = AID.getBytes();
              JCApplet applet = new JCApplet(card, aid);
              applet.select();
    Overall, thanks everyone here gave me help.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points