Ejemplo n.º 1
0
  /** Close the serial port. */
  public void delete() {
    // Close the serial port
    try {
      if (inputStream != null) inputStream.close();
      outputStream.close();
    } catch (IOException e) {

    }
    mbedSerialPort.removeEventListener();
    mbedSerialPort.close();
    mbedPort.close();
  }
Ejemplo n.º 2
0
 // disconnect the serial port
 // pre: an open serial port
 // post: clsoed serial port
 public void disconnect() {
   // close the serial port
   try {
     //            writeData(0, 0);
     serialPort.removeEventListener();
     serialPort.close();
     input.close();
     output.close();
     setConnected(false);
     logText = "Disconnected.";
     System.out.println(logText + "\n");
   } catch (Exception e) {
     logText = "Failed to close " + serialPort.getName() + "(" + e.toString() + ")";
     System.out.println(logText + "\n");
   }
 }
Ejemplo n.º 3
0
 /*
  * Code cribbed from RXTX example
  */
 public static void closePort(SerialPort serialPort) {
   if (serialPort != null) {
     serialPort.notifyOnDataAvailable(false);
     serialPort.removeEventListener();
     if (inputStream != null) {
       try {
         inputStream.close();
         inputStream = null;
       } catch (IOException e) {
       }
     }
     if (outputStream != null) {
       try {
         outputStream.close();
         outputStream = null;
       } catch (IOException e) {
       }
     }
     serialPort.close();
     serialPort = null;
   }
 }
Ejemplo n.º 4
0
  public void ClosePort() {
    if (portOpened) {
      if (serialPort != null) {
        try {
          // Close the I/O streams.
          out.close();
          in.close();
          // Close the port.
          serialPort.removeEventListener();
          serialPort.close();
        } catch (IOException e) {
          // Don't care
        }
      }

      ClearLog();
      portOpened = false;
      portConfirmed = false;
      previewPane.setConnected(false);
      UpdateMenuBar();
    }
  }
 /**
  * This should be called when you stop using the port. This will prevent port locking on platforms
  * like Linux.
  */
 public synchronized void closeSerial() {
   if (serialPort != null) {
     serialPort.removeEventListener();
     serialPort.close();
   }
 }