@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/tty1"); CommPort commPort = portIdentifier.open("owner-name", 2000); SerialPort serialport; if (commPort instanceof SerialPort) { serialPort = (SerialPort)commPort; serialPort.setSerialPortParams(rate, databits, stopbits, parity); } InputStream in = serialPort.getInputStream(); OutputStream out = serialPort.getOutputStream();
CommPortIdentifier portIdentifier; try { portIdentifier = CommPortIdentifier.getPortIdentifier(name); } catch (NoSuchPortException nspe) { // handle? } if (portIdentifier.isCurrentlyOwned()) { // handle? } port = portIdentifier.open(owner, 1000); if (!(port instanceof SerialPort)) { // handle? }
public void connect(CommPortIdentifier portId) throws Failure { if (portId == null) throw new Failure("No port set"); try { port = (SerialPort) portId.open(getClass().getName(), 10000); } catch (PortInUseException e) { throw new Failure("Port in use by " + e.currentOwner,e); } try { port.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); port.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN | SerialPort.FLOWCONTROL_RTSCTS_OUT); } catch (UnsupportedCommOperationException e) { throw new Failure(e); } port.setRTS(true); // More setup }
@Override public SerialPort open(String owner, int timeout) throws PortInUseException { try { final CommPort cp = id.open(owner, timeout); if (cp instanceof gnu.io.SerialPort) { return new RxTxSerialPort((gnu.io.SerialPort) cp); } else { throw new IllegalStateException( String.format("We expect an serial port instead of '%s'", cp.getClass())); } } catch (gnu.io.PortInUseException e) { throw new PortInUseException(); } }
@Override public SerialPort open(String owner, int timeout) throws PortInUseException { try { final CommPort cp = id.open(owner, timeout); if (cp instanceof gnu.io.SerialPort) { return new RxTxSerialPort((gnu.io.SerialPort) cp); } else { throw new IllegalStateException( String.format("We expect an serial port instead of '%s'", cp.getClass())); } } catch (gnu.io.PortInUseException e) { throw new PortInUseException(); } }
@Override public void connect() throws SwegonVentilationException { try { CommPortIdentifier portIdentifier = CommPortIdentifier .getPortIdentifier(portName); CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000); serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(BAUDRATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); in = serialPort.getInputStream(); logger.debug("Swegon ventilation Serial Port message listener started"); } catch (Exception e) { throw new SwegonVentilationException(e); } }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress; final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value()); final CommPort commPort = cpi.open(getClass().getName(), 1000); commPort.enableReceiveTimeout(config().getOption(READ_TIMEOUT)); deviceAddress = remote; serialPort = (SerialPort) commPort; }
@Override public void connect(String device) throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException, IOException { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(device); CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000); serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.enableReceiveThreshold(1); serialPort.disableReceiveTimeout(); in = serialPort.getInputStream(); out = serialPort.getOutputStream(); out.flush(); if (in.markSupported()) { in.reset(); } readerThread = new SerialReader(in); readerThread.start(); }
public void serialinit() throws Exception { CommPortIdentifier portIdentifier; portIdentifier = CommPortIdentifier.getPortIdentifier(portName); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { serialPort = (SerialPort) portIdentifier.open("Serial", 2000); serialPort.setSerialPortParams(speed, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } }
@Override public void init() throws Exception { CommPortIdentifier portIdentifier; portIdentifier = CommPortIdentifier.getPortIdentifier(portName); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { serialPort = (SerialPort) portIdentifier.open("Serial", 2000); serialPort.setSerialPortParams(speed, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); } }