args[0]).open(TwoPortSerialTest.class.getName(), 0);
SerialPort port = (SerialPort) portId.open("Example1", 1000); OutputStream outStream = port.getOutputStream(); InputStream inStream = port.getInputStream();
args[0]).open(TwoPortSerialTest.class.getName(), 0);
SerialPort result = ( SerialPort )portId.open( "Serial console tool", 1000 );
static protected void openPort() throws Exception { try { CommPortIdentifier portid = CommPortIdentifier.getPortIdentifier(m_TestPortName); m_Port = (SerialPort) portid.open(APPLICATION_NAME, 1000); m_Out = m_Port.getOutputStream(); m_In = m_Port.getInputStream(); drain(m_In); } catch (NoSuchPortException e) { fail("could no open port '%s'\n", m_TestPortName); } }
static protected void openPort() throws Exception { try { CommPortIdentifier portid = CommPortIdentifier.getPortIdentifier(m_TestPortName); m_Port = (SerialPort) portid.open("PureJavaCommTestSuite", 1000); m_Out = m_Port.getOutputStream(); m_In = m_Port.getInputStream(); drain(m_In); } catch (NoSuchPortException e) { fail("could no open port '%s'\n", m_TestPortName); } }
/** * Returns the serial port instance. * * @param aOptions * the serial port options, cannot be <code>null</code>. * @return the serial port instance, never <code>null</code>. * @throws NoSuchPortException * in case the desired port does not exist; * @throws PortInUseException * in case the desired port is already in use; * @throws IOException * in case of other I/O problems. */ private SerialPort getSerialPort( final CommPortOptions aOptions ) throws NoSuchPortException, PortInUseException, IOException { final CommPortIdentifier commPortId = CommPortIdentifier.getPortIdentifier( aOptions.getPortName() ); if ( commPortId.isCurrentlyOwned() && ( commPortId.getCurrentOwner() != CONNECT_ID ) ) { throw new PortInUseException(); } final CommPort commPort = commPortId.open( CONNECT_ID, 2000 ); if ( !( commPort instanceof SerialPort ) ) { throw new IOException( "Not a serial port?!" ); } return ( SerialPort )commPort; }
SerialPort port = (SerialPort) portid.open("PureJavaCommDemo", 1000); port.notifyOnDataAvailable(true); port.notifyOnOutputEmpty(true);