@Override public boolean isCurrentlyOwned() { return id.isCurrentlyOwned(); }
@Override public boolean isCurrentlyOwned() { return id.isCurrentlyOwned(); }
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? }
// change to right port CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/ttyS0"); if (portIdentifier.isCurrentlyOwned()) { throw new RfidReaderUnavailableException(); } else { CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000); if (commPort instanceof SerialPort) { SerialPort serialPort = (SerialPort) commPort; // This details have to match your device configuration or it won't work serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN | SerialPort.FLOWCONTROL_RTSCTS_OUT); in = serialPort.getInputStream(); out = serialPort.getOutputStream(); <-- Here you write the commands on out and read the responses from in --> } else { System.out.println("Error: Only serial ports are handled by this."); } }
if (portIdentifier.isCurrentlyOwned()) { System.err.println("Error: Port " + portName + " is currently in use");
if (portIdentifier.isCurrentlyOwned()) { System.err.println("Error: Port " + portName + " is currently in use");
CommPortIdentifier portIdentifier = CommPortIdentifier .getPortIdentifier( portName ); if( portIdentifier.isCurrentlyOwned() ) { System.out.println( "Error: Port is currently in use" ); } else {
if (portIdentifier.isCurrentlyOwned()) { System.err.println("Error: Port " + portName + " is currently in use");
if ( portIdentifier.isCurrentlyOwned() )
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(); } }
throw new Exception("Serial port '" + portName + "' not found."); if (portIdentifier.isCurrentlyOwned()) { throw new Exception("Serial port '" + portName + "' is in use.");
if ( portIdentifier.isCurrentlyOwned() )
try { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("COM71"); if (portIdentifier.isCurrentlyOwned()) { System.out.println("Port in use!"); } else {
void connect(String portName, SerialConfiguration conf) { registerPort(portName); try { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); if (portIdentifier.isCurrentlyOwned()) { System.err.println("Error: Port " + portName + " is currently in use"); } else { CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000); if (commPort instanceof SerialPort) { serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); in = serialPort.getInputStream(); out = serialPort.getOutputStream(); serialPort.addEventListener(new SerialReader()); serialPort.notifyOnDataAvailable(true); } else { System.err.println("Error: Port " + portName + " is not a valid serial port."); } } } catch (Exception e) { e.printStackTrace(); } }
if ( portIdentifier.isCurrentlyOwned() )
System.out.println("Use ? : "+portid.isCurrentlyOwned()); System.out.println("Port type : "+portid.getPortType());
if ( portId.isCurrentlyOwned( ) ) { logger.error( "port owned by someone else" ); return false;