/** 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(); }
/* * 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; } }
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(); } }