@Override protected void doClose() throws Exception { open = false; try { super.doClose(); } finally { if (serialPort != null) { serialPort.removeEventListener(); serialPort.close(); serialPort = null; } } }
@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; }
protected void doInit() throws Exception { serialPort.setSerialPortParams( config().getOption(BAUD_RATE), config().getOption(DATA_BITS).value(), config().getOption(STOP_BITS).value(), config().getOption(PARITY_BIT).value() ); serialPort.setDTR(config().getOption(DTR)); serialPort.setRTS(config().getOption(RTS)); activate(serialPort.getInputStream(), serialPort.getOutputStream()); }
System.out.println("Baud is " + serialPort.getBaudRate()); System.out.println("Bits is " + serialPort.getDataBits()); System.out.println("Stop is " + serialPort.getStopBits()); System.out.println("Par is " + serialPort.getParity()); serialPort.close(); sport.setSerialPortParams(57600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); InputStream in = sport.getInputStream(); OutputStream out = sport.getOutputStream(); sport.addEventListener(new SerialReader(in)); sport.notifyOnDataAvailable(true);
public synchronized void setSerialPortParams(int b, int d, int s, int p) throws UnsupportedCommOperationException { if (debug) z.reportln("RXTXPort:setSerialPortParams(" + b + " " + d + " " + s + " " + p + ") called"); if (nativeSetSerialPortParams(b, d, s, p)) throw new UnsupportedCommOperationException("Invalid Parameter"); speed = b; if (s == STOPBITS_1_5) dataBits = DATABITS_5; else dataBits = d; stopBits = s; parity = p; z.reportln("RXTXPort:setSerialPortParams(" + b + " " + d + " " + s + " " + p + ") returning"); }
@Override public void dataAvailable() { if (notifyOnDataAvailable && listener != null) { listener.serialEvent(new SerialPortEvent(this, SerialPortEvent.DATA_AVAILABLE, false, true)); } } }
public void close() { setDTR(false); setDSR(false); nativeClose(); super.close(); fd = 0; }
public void close() { setDTR(false); setDSR(false); nativeClose(); super.close(); fd = 0; }
public void close() { setDTR(false); setDSR(false); nativeClose(); super.close(); ciAddress = 0; }
public int setMode(int mode) throws UnsupportedCommOperationException { try { setLPRMode(mode); } catch(UnsupportedCommOperationException e) { e.printStackTrace(); return -1; } lprmode = mode; return(0); } public void restart()
protected void doInit() throws Exception { serialPort.setSerialPortParams( config().getOption(BAUD_RATE), config().getOption(DATA_BITS).value(), config().getOption(STOP_BITS).value(), config().getOption(PARITY_BIT).value() ); serialPort.setDTR(config().getOption(DTR)); serialPort.setRTS(config().getOption(RTS)); activate(serialPort.getInputStream(), serialPort.getOutputStream()); }
@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 doClose() throws Exception { open = false; try { super.doClose(); } finally { if (serialPort != null) { serialPort.removeEventListener(); serialPort.close(); serialPort = null; } } }
public void close() { setDTR(false); setDSR(false); nativeClose(); super.close(); fd = 0; }
public void close() { setDTR(false); setDSR(false); nativeClose(); super.close(); fd = 0; }
public void close() { setDTR(false); setDSR(false); nativeClose(); super.close(); ciAddress = 0; }
public int setMode(int mode) throws UnsupportedCommOperationException { try { setLPRMode(mode); } catch (UnsupportedCommOperationException e) { e.printStackTrace(); return -1; } lprmode = mode; return (0); }