Click here to Skip to main content
15,896,348 members
Articles / Programming Languages / Java

SmartCard Java Serial Interface

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
12 Nov 2010CPOL2 min read 22K   335   2  
Getting SmartCard lifecycle state from Java
package skynet.smart;

public class hiloPuerto extends Thread
{
  Principal frameAux;
  EstadoSmart estadoT = new EstadoSmart();
  String literal;
  
  public hiloPuerto(Principal form) 
  {
    this.frameAux = form;
    start();
  }

  public void run(){

    try {
      // Sleeps para efecto creciente
      frameAux.setLabel("Conectando...");
      CommSerie bus = new CommSerie(); 
      frameAux.setLabel("Leyendo tarjeta...");
      for (int i=1;i<=50;i++){              	
      	sleep(2);
        frameAux.setProgressValor(i);
      }  
      bus.enviaReset();      
      sleep(100);
      for (int i=51;i<=70;i++){
        sleep(2);
        frameAux.setProgressValor(i);
      }  
      literal = estadoT.getEstado(bus.leeRespuesta());
      frameAux.setLabel(literal);
      for (int i=71;i<=100;i++){
        sleep(2);
        frameAux.setProgressValor(i);
      }
      System.out.println(literal);  
      bus.cierraPuerto();
      
    } catch(InterruptedException e){System.out.println("Interrumpido!");
    } catch(NullPointerException e) {System.out.println("Puerto ocupado!"); System.exit(-1);}  
    
    
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Spain Spain
I am a software developer grown with programming paradigm evolution. Think that C is God's Programming Language.

Comments and Discussions