From f8b1ca4c867f9efc03ff4cde4fdf0ca78719b0e4 Mon Sep 17 00:00:00 2001 From: "Tommi S.E. Laukkanen" Date: Mon, 30 May 2016 23:28:06 +0300 Subject: [PATCH] Removed dependency to old serial port implementation and cloudbees repository. --- pom.xml | 16 -- zigbee-serial-javase/pom.xml | 6 - .../network/port/ZigBeeSerialPortImpl.java | 144 ------------------ .../zigbee/ZigBeeSerialNetworkTest.java | 4 +- 4 files changed, 2 insertions(+), 168 deletions(-) delete mode 100644 zigbee-serial-javase/src/main/java/org/bubblecloud/zigbee/network/port/ZigBeeSerialPortImpl.java diff --git a/pom.xml b/pom.xml index d9e25ed9f..d7f7b3bb7 100644 --- a/pom.xml +++ b/pom.xml @@ -20,11 +20,6 @@ - - bubblecloud-cloudbees-release - bubblecloud-cloudbees-release - http://repository-bubblecloud.forge.cloudbees.com/release/ - false @@ -117,17 +112,6 @@ org.apache.maven.plugins maven-site-plugin 3.3 - - - - org.apache.maven.plugins - maven-javadoc-plugin - - false - - - - org.eluder.coveralls diff --git a/zigbee-serial-javase/pom.xml b/zigbee-serial-javase/pom.xml index cf4a5e857..645f508a3 100644 --- a/zigbee-serial-javase/pom.xml +++ b/zigbee-serial-javase/pom.xml @@ -32,12 +32,6 @@ test-jar - - serial-comm - serial-comm - 0.9 - - org.scream3r jssc diff --git a/zigbee-serial-javase/src/main/java/org/bubblecloud/zigbee/network/port/ZigBeeSerialPortImpl.java b/zigbee-serial-javase/src/main/java/org/bubblecloud/zigbee/network/port/ZigBeeSerialPortImpl.java deleted file mode 100644 index f4dd9ba57..000000000 --- a/zigbee-serial-javase/src/main/java/org/bubblecloud/zigbee/network/port/ZigBeeSerialPortImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.bubblecloud.zigbee.network.port; - -import j.extensions.comm.SerialComm; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; - -/** - * The system serial-port implementation of ZigBeePort. - * - * @author Tommi S.E. Laukkanen - * @author Chris Hatton - */ -public class ZigBeeSerialPortImpl implements ZigBeePort -{ - /** - * The logger. - */ - private final static Logger logger = LoggerFactory.getLogger(ZigBeeSerialPortImpl.class); - /** - * The portIdentifier portIdentifier. - */ - private SerialComm serialPort; - /** - * The portIdentifier portIdentifier input stream. - */ - private InputStream inputStream; - /** - * The portIdentifier portIdentifier output stream. - */ - private OutputStream outputStream; - - private final String portIdentifier; - private final int baudRate; - - public ZigBeeSerialPortImpl(final String portIdentifier, final int baudRate) { - this.portIdentifier = portIdentifier; - this.baudRate = baudRate; - } - - @Override - public boolean open() { - try { - openSerialPort(portIdentifier, 0, baudRate, 8, SerialComm.ONE_STOP_BIT, - SerialComm.NO_PARITY, SerialComm.FLOW_CONTROL_DISABLED); - - return true; - } catch (Exception e) { - logger.warn("Unable to open serial port: " + e.getMessage()); - return false; - } - } - - /** - * Opens portIdentifier portIdentifier. - * - * @param port the portIdentifier - * @param timeoutMillis the timeout in milliseconds - * @param baudRate the baud rate - * @param dataBits the data bits count - * @param stopBits the stop bits count - * @param parity the parity - * @param flowControl the flow control mode - */ - private void openSerialPort(String port, int timeoutMillis, int baudRate, int dataBits, int stopBits, int parity, int flowControl) { - if (serialPort != null) { - throw new RuntimeException("Serial portIdentifier '" + serialPort.getSystemPortName() - + "' is already startup for this portIdentifier comm instance."); - } - - final SerialComm[] ports = SerialComm.getCommPorts(); - logger.trace("Serial ports:"); - - final Map portMap = new HashMap(); - for (int i = 0; i < ports.length; ++i) { - logger.trace(i + ") '" + ports[i].getSystemPortName() + "': " + ports[i].getDescriptivePortName()); - - - portMap.put(ports[i].getSystemPortName(), ports[i]); - } - - if (!portMap.containsKey(port)) { - throw new RuntimeException("Serial portIdentifier '" + port + "' not found."); - } - - serialPort = portMap.get(port); - logger.debug("Opening portIdentifier '" + serialPort.getSystemPortName() + "'."); - if (!serialPort.openPort()) { - throw new RuntimeException("Serial portIdentifier '" + port + "' startup failed."); - } - - serialPort.setComPortTimeouts(SerialComm.TIMEOUT_READ_BLOCKING, timeoutMillis, 0); - serialPort.setBaudRate(baudRate); - serialPort.setNumDataBits(dataBits); - serialPort.setNumStopBits(stopBits); - serialPort.setParity(parity); - serialPort.setFlowControl(flowControl); - - inputStream = serialPort.getInputStream(); - outputStream = serialPort.getOutputStream(); - } - - @Override - public void close() { - try { - if (serialPort != null) { - try { - while (inputStream.available() > 0) { - try { - Thread.sleep(100); - } catch (final InterruptedException e) { - logger.warn("Interrupted while waiting input stream to flush."); - } - } - } catch (Exception e) { - } - inputStream.close(); - outputStream.flush(); - outputStream.close(); - serialPort.closePort(); - logger.debug("Serial portIdentifier '" + serialPort.getSystemPortName() + "' closed."); - serialPort = null; - inputStream = null; - outputStream = null; - } - } catch (Exception e) { - logger.warn("Error closing portIdentifier portIdentifier: '" + serialPort.getSystemPortName() + "'", e); - } - } - - @Override - public OutputStream getOutputStream() { - return outputStream; - } - - @Override - public InputStream getInputStream() { - return inputStream; - } -} diff --git a/zigbee-serial-javase/src/test/java/org/bubblecloud/zigbee/ZigBeeSerialNetworkTest.java b/zigbee-serial-javase/src/test/java/org/bubblecloud/zigbee/ZigBeeSerialNetworkTest.java index 1fe861913..9f4250fed 100644 --- a/zigbee-serial-javase/src/test/java/org/bubblecloud/zigbee/ZigBeeSerialNetworkTest.java +++ b/zigbee-serial-javase/src/test/java/org/bubblecloud/zigbee/ZigBeeSerialNetworkTest.java @@ -1,6 +1,6 @@ package org.bubblecloud.zigbee; -import org.bubblecloud.zigbee.network.port.ZigBeeSerialPortImpl; +import org.bubblecloud.zigbee.network.port.ZigBeeSerialPortJsscImpl; /** * Created by Chris on 25/02/15. @@ -12,6 +12,6 @@ public final class ZigBeeSerialNetworkTest extends ZigBeeNetworkTest public ZigBeeSerialNetworkTest() { - super(new ZigBeeSerialPortImpl(SerialPortIdentifier, BaudRate)); + super(new ZigBeeSerialPortJsscImpl(SerialPortIdentifier, BaudRate)); } }