code: protected Connection<CommPortAdapter> getCommPortConnection()
      {
          Connection<CommPortAdapter> connection=null;
          synchronized(this)
          {
              boolean connectionValid=true;
              //if no connection available
              if(this.commConnection==null)
              {
                  connectionValid=false;
              }
              else
              {
                  //get adapter
                  CommPortAdapter adapter=this.commConnection.getResource();
  
                  //if current adapter is not valid/open
                  if(!adapter.isOpen())
                  {
                      connectionValid=false;
                  }
              }
              
              if(!connectionValid)
              {
                  //release old connection
                  this.releaseCommPortConnection();
  
                  //create new connection
                  this.commConnection=this.createCommPortConnection();
              }
          }
              
          //get connection
          connection=this.commConnection;
          
          return connection;
      }
docs: Returns the COMM port connection to be used.
  
  @return  The COMM port connection