Open riedlse opened 4 years ago
just add a few invocations with additional parameters Will do a pull request and make changes
private RXTXPort serial; private String port = null; private boolean connected = false; private int baud = 115200; private int parity = SerialPort.PARITY_NONE; private int dataBits = SerialPort.DATABITS_8; private int stopBits = SerialPort.STOPBITS_1; /** * Class Constructor for a NRSerialPort with a given port and baudrate. * */ public NRSerialPort(String port) { this.port = port; } public NRSerialPort(String port, int baud) { this.port = port; this.baud = baud; } public NRSerialPort(String port, int baud, int parity) { this.port = port; this.baud = baud; this.parity = parity; } public NRSerialPort(String port, int baud, int parity, int dataBits) { this.port = port; this.baud = baud; this.parity = parity; this.dataBits = dataBits; } public NRSerialPort(String port, int baud, int parity, int dataBits, int stopBits) { this.port = port; this.baud = baud; this.parity = parity; this.dataBits = dataBits; this.stopBits = stopBits; } public boolean connect() { if (isConnected()) { System.err.println(port + " is already connected."); return true; } try { RXTXPort comm = null; CommPortIdentifier ident = null; if ((System.getProperty("os.name").toLowerCase().indexOf("linux") != -1)) { // if ( port.toLowerCase().contains("rfcomm".toLowerCase())|| // port.toLowerCase().contains("ttyUSB".toLowerCase()) || // port.toLowerCase().contains("ttyS".toLowerCase())|| // port.toLowerCase().contains("ACM".toLowerCase()) || // port.toLowerCase().contains("Neuron_Robotics".toLowerCase())|| // port.toLowerCase().contains("DyIO".toLowerCase())|| // port.toLowerCase().contains("NR".toLowerCase())|| // port.toLowerCase().contains("FTDI".toLowerCase())|| // port.toLowerCase().contains("ftdi".toLowerCase()) // ){ System.setProperty("gnu.io.rxtx.SerialPorts", port); // } } ident = CommPortIdentifier.getPortIdentifier(port); try { comm = ident.open("NRSerialPort", 2000); } catch (PortInUseException e) { System.err.println("This is a bug, passed the ownership test above: " + e.getMessage()); return false; } if (!(comm instanceof RXTXPort)) { throw new UnsupportedCommOperationException("Non-serial connections are unsupported."); }
sure, send a PR for this
just add a few invocations with additional parameters Will do a pull request and make changes