@Test public void testCreateNonExistingConnectionMacOS( final BundleContext aContext ) throws IOException { assumeTrue( HostUtils.getHostInfo().isMacOS() ); try { getConnectionFactory( aContext ).createConnection( "comm:/dev/tty.usbserial", 0, false ); fail( "I/O exception expected!" ); } catch ( Exception exception ) { assertThat( exception, instanceOf( IOException.class ) ); } }
@Override public Connection createConnection( final String aName, final int aMode, final boolean aTimeouts ) throws IOException { try { final CommPortOptions options = new CommPortOptions( aName ); final SerialPort port = obtainSerialPort( options ); port.setSerialPortParams( options.getBaudrate(), options.getDatabits(), options.getStopbits(), options.getParityMode() ); port.setFlowControlMode( options.getFlowControl() ); if ( aTimeouts ) { port.enableReceiveTimeout( options.getReceiveTimeout() ); } port.setRTS( true ); port.setDTR( options.isDTR() ); final CommConnectionImpl connection = new CommConnectionImpl( port ); final int openDelay = options.getOpenDelay(); if ( openDelay > 0 ) { Thread.sleep( openDelay ); } return connection; } catch ( IllegalArgumentException exception ) { throw new IOException( "Invalid URI!", exception ); } catch ( UnsupportedCommOperationException exception ) { throw new IOException( "Unsupported operation!", exception ); } catch ( NoSuchPortException exception ) { throw new IOException( "No such port!" ); } catch ( InterruptedException exception ) { throw new IOException( "Interrupted while opening port!" ); } }
CommConnectionFactory implements ConnectionFactory { @Override public Connection createConnection( final String aName, final int aMode, final boolean aTimeouts ) throws IOException { try { final CommPortOptions options = new CommPortOptions( aName ); final SerialPort port = obtainSerialPort( options ); port.setSerialPortParams( options.getBaudrate(), options.getDatabits(), options.getStopbits(), options.getParityMode() ); port.setFlowControlMode( options.getFlowControl() ); if ( aTimeouts ) { port.enableReceiveTimeout( options.getReceiveTimeout() ); } port.setRTS( true ); port.setDTR( options.isDTR() ); final CommConnectionImpl connection = new CommConnectionImpl( port ); final int openDelay = options.getOpenDelay(); if ( openDelay > 0 ) { Thread.sleep( openDelay ); } return connection; } catch ( IllegalArgumentException exception ) { throw new IOException( "Invalid URI!", exception ); } catch ( UnsupportedCommOperationException exception ) { throw new IOException( "Unsupported operation!", exception ); } catch ( NoSuchPortException exception ) { throw new IOException( "No such port!" ); } catch ( InterruptedException exception ) { throw new IOException( "Interrupted while opening port!" ); } } }
CommConnectionFactory implements ConnectionFactory { @Override public Connection createConnection( final String aName, final int aMode, final boolean aTimeouts ) throws IOException { try { final CommPortOptions options = new CommPortOptions( aName ); final SerialPort port = obtainSerialPort( options ); port.setSerialPortParams( options.getBaudrate(), options.getDatabits(), options.getStopbits(), options.getParityMode() ); port.setFlowControlMode( options.getFlowControl() ); if ( aTimeouts ) { port.enableReceiveTimeout( options.getReceiveTimeout() ); } port.setRTS( true ); port.setDTR( options.isDTR() ); final CommConnectionImpl connection = new CommConnectionImpl( port ); final int openDelay = options.getOpenDelay(); if ( openDelay > 0 ) { Thread.sleep( openDelay ); } return connection; } catch ( IllegalArgumentException exception ) { throw new IOException( "Invalid URI!", exception ); } catch ( UnsupportedCommOperationException exception ) { throw new IOException( "Unsupported operation!", exception ); } catch ( NoSuchPortException exception ) { throw new IOException( "No such port!" ); } catch ( InterruptedException exception ) { throw new IOException( "Interrupted while opening port!" ); } }  }
CommConnectionFactory implements ConnectionFactory { @Override public Connection createConnection( final String aName, final int aMode, final boolean aTimeouts ) throws IOException { try { final CommPortOptions options = new CommPortOptions( aName ); final SerialPort port = obtainSerialPort( options ); port.setSerialPortParams( options.getBaudrate(), options.getDatabits(), options.getStopbits(), options.getParityMode() ); port.setFlowControlMode( options.getFlowControl() ); if ( aTimeouts ) { port.enableReceiveTimeout( options.getReceiveTimeout() ); } port.setRTS( true ); port.setDTR( options.isDTR() ); final CommConnectionImpl connection = new CommConnectionImpl( port ); final int openDelay = options.getOpenDelay(); if ( openDelay > 0 ) { Thread.sleep( openDelay ); } return connection; } catch ( IllegalArgumentException exception ) { throw new IOException( "Invalid URI!", exception ); } catch ( UnsupportedCommOperationException exception ) { throw new IOException( "Unsupported operation!", exception ); } catch ( NoSuchPortException exception ) { throw new IOException( "No such port!" ); } catch ( InterruptedException exception ) { throw new IOException( "Interrupted while opening port!" ); } }  @Override Connection createConnection( final String aName, final int aMode, final boolean aTimeouts ); }
CommConnectionFactory implements ConnectionFactory { @Override public Connection createConnection( final String aName, final int aMode, final boolean aTimeouts ) throws IOException { try { final CommPortOptions options = new CommPortOptions( aName ); final SerialPort port = obtainSerialPort( options ); port.setSerialPortParams( options.getBaudrate(), options.getDatabits(), options.getStopbits(), options.getParityMode() ); port.setFlowControlMode( options.getFlowControl() ); if ( aTimeouts ) { port.enableReceiveTimeout( options.getReceiveTimeout() ); } port.setRTS( true ); port.setDTR( options.isDTR() ); final CommConnectionImpl connection = new CommConnectionImpl( port ); final int openDelay = options.getOpenDelay(); if ( openDelay > 0 ) { Thread.sleep( openDelay ); } return connection; } catch ( IllegalArgumentException exception ) { throw new IOException( "Invalid URI!", exception ); } catch ( UnsupportedCommOperationException exception ) { throw new IOException( "Unsupported operation!", exception ); } catch ( NoSuchPortException exception ) { throw new IOException( "No such port!" ); } catch ( InterruptedException exception ) { throw new IOException( "Interrupted while opening port!" ); } }  @Override Connection createConnection( final String aName, final int aMode, final boolean aTimeouts ); static final String SCHEME; }