title: read from a serial port using even listener in a loop
body: <p>I have a method that write the content of a file to a serial port and then awaits the acknowledgement message. i am trying to use an even listener however no message are printed back to the console. 
  however, when i read the message with out the event listener, manually in a slow pace, the messages comes back just fine.
  here is my code:</p>
  
  <pre><code>public class portConnector {
  private static SerialPort SP;
  
  
  public portConnector(String pName){
      SP = new SerialPort(pName);
  }
  
  public static byte[] read(String name) throws IOException{
      File file = new File(name);     
      byte[] bytes = new byte[(int) file.length()];
      FileInputStream inputStream = new FileInputStream(file);
      inputStream.read(bytes);
      inputStream.close();
      return bytes;
  }
  
  public void push2rec (File[] LOF){
      try {
          SP.openPort();
          SP.setParams(SerialPort.BAUDRATE_9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
          int mask = SerialPort.MASK_RXCHAR;
          SP.setEventsMask(mask); 
          SP.addEventListener(new PortReader(), SerialPort.MASK_RXCHAR);
          for (File f : LOF){
              byte[] rd = read(f.getName());
              SP.writeBytes(rd);
          }
          SP.closePort();
      }
      catch (SerialPortException ex) {System.out.println(ex);} 
      catch (IOException ex) {System.out.println(ex);}
  }
  
  private static class PortReader implements SerialPortEventListener {
  
  @Override
  public void serialEvent(SerialPortEvent event) {
      if(event.isRXCHAR() &amp;&amp; event.getEventValue() == 10) {
          try {
              byte[] buffer = SP.readBytes(10);
              for (byte b : buffer){
                  System.out.format("%02X ", b);
              }
              System.out.println("");
          }
          catch (SerialPortException ex) {
              System.out.println("Error in receiving string from COM-port: " + ex);
          }
      }
  }}}
  </code></pre>
  
  <p>is the "addEventListener" located in the right place?
  can anyone help me with this problem.
  any help would be appreciated. thank you. </p>