System.out.println("Baud is " + serialPort.getBaudRate()); System.out.println("Bits is " + serialPort.getDataBits()); System.out.println("Stop is " + serialPort.getStopBits());
@Override public void open() throws IOException { if (port == null) { try { CommPortIdentifier identifier = findCommPortIdentifier(comPort); if (identifier == null) { throw new RuntimeException("ComPort not found: " + comPort); } port = (SerialPort)identifier.open(SerialPortNfcDevice.class.getName() + "." + comPort, TIMEOUT_FOR_OPEN); port.setInputBufferSize(SERIAL_PORT_BUFFER_SIZE); // initSerialPortEventListener(); log.trace(port + " BaudRate: " + port.getBaudRate() + ", InputBuffer: " + port.getInputBufferSize()); tweakPort(); inputOutputToken.setInputStream(port.getInputStream()); inputOutputToken.setOutputStream(port.getOutputStream()); speedNegotiator.negotiateBaudRateOnObject(port, baudRate); log.trace("Comport opened: " + port + " BaudRate: " + port.getBaudRate() + ", InputBuffer: " + port.getInputBufferSize()); } catch (PortInUseException e) { throw new IOException(e); } } }
int b = serialPort.getBaudRate(); System.out.println(Integer.toString(b)); serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8,
@Override public void open() throws IOException { if (port == null) { try { CommPortIdentifier identifier = findCommPortIdentifier(comPort); if (identifier == null) { throw new RuntimeException("ComPort not found: " + comPort); } port = (SerialPort)identifier.open(SerialPortNfcDevice.class.getName() + "." + comPort, TIMEOUT_FOR_OPEN); port.setInputBufferSize(SERIAL_PORT_BUFFER_SIZE); // initSerialPortEventListener(); log.trace(port + " BaudRate: " + port.getBaudRate() + ", InputBuffer: " + port.getInputBufferSize()); tweakPort(); inputOutputToken.setInputStream(port.getInputStream()); inputOutputToken.setOutputStream(port.getOutputStream()); speedNegotiator.negotiateBaudRateOnObject(port, baudRate); log.trace("Comport opened: " + port + " BaudRate: " + port.getBaudRate() + ", InputBuffer: " + port.getInputBufferSize()); } catch (PortInUseException e) { throw new IOException(e); } } }