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()); }
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()); }
sport.setSerialPortParams(57600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
protected void setSerialPortParams(int baudRate) { log.debug("Setting com port baud rate to " + baudRate); try { port.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); try { Thread.sleep(60); } catch (InterruptedException e) { } } catch (UnsupportedCommOperationException e) { throw new RuntimeException(e); } }
@Override public void setSerialPortParams(int baudrate, int dataBits, int stopBits, int parity) throws UnsupportedCommOperationException { try { sp.setSerialPortParams(baudrate, dataBits, stopBits, parity); } catch (gnu.io.UnsupportedCommOperationException ex) { throw new UnsupportedCommOperationException(); } }
@Override public void setSerialPortParams(int baudrate, int dataBits, int stopBits, int parity) throws UnsupportedCommOperationException { try { sp.setSerialPortParams(baudrate, dataBits, stopBits, parity); } catch (gnu.io.UnsupportedCommOperationException ex) { throw new UnsupportedCommOperationException(); } }
if ( commPort instanceof SerialPort ) { SerialPort serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); InputStream in = serialPort.getInputStream(); OutputStream out = serialPort.getOutputStream(); out1=out; //add this line, where out1 is a global variable// (new Thread(new SerialReader(in))).start(); (new Thread(new SerialWriter(out))).start(); }
// name comes from config and is "COM1", "COM2", ... SerialPort port=(SerialPort)CommPortIdentifier.getPortIdentifier(name).open("YourPortOwnerIdHere",5000); // owner and ms timeout port.setSerialPortParams(bau,dtb,stb,par); port.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN|SerialPort.FLOWCONTROL_RTSCTS_OUT); port.enableReceiveTimeout(1000);
// Each of these could be object members so all your class methods have access OutputStream outputStream; InputStream inputStream; SerialPort serialPort; // Open the port one time, then init your settings serialPort = (SerialPort)portId.open("SimpleWriteApp", 2000); serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); // Get the input/output streams for use in the application outputStream = serialPort.getOutputStream(); inputStream = serialPort.getInputStream(); // Finally, add your event listener serialPort.addEventListener(this);
SerialPort serialPort; InputStream inStream; OutputStream outStream; serialPort = (SerialPort) portId.open(...); serialPort.setFlowControlMode(...); serialPort.setSerialPortParams(...); inStream = serialPort.getInputStream (); outStream = serialPort.getOutputStream ();
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(); } }
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()); }
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()); }
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()); }
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()); }
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()); }
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()); }
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()); }
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()); }
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()); }