From e273ef5b6e08ed2c429f34a374bee66cdcfa55aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Inostroza?= Date: Wed, 7 Dec 2016 21:40:56 -0300 Subject: [PATCH] Add overloaded function to enable the use of different baud rates. --- src/de/fischl/usbtin/USBtin.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/de/fischl/usbtin/USBtin.java b/src/de/fischl/usbtin/USBtin.java index 6073f05..e7ff3bf 100644 --- a/src/de/fischl/usbtin/USBtin.java +++ b/src/de/fischl/usbtin/USBtin.java @@ -111,6 +111,19 @@ public String getSerialNumber() { * @throws USBtinException Error while connecting to USBtin */ public void connect(String portName) throws USBtinException { + connect(portName, 115200); + } + + /** + * Connect to USBtin on given port. + * Opens the serial port, clears pending characters and send close command + * to make sure that we are in configuration mode. + * + * @param portName Name of virtual serial port + * @param baudRate + * @throws USBtinException Error while connecting to USBtin + */ + public void connect(String portName, int baudRate ) throws USBtinException { try { @@ -119,7 +132,7 @@ public void connect(String portName) throws USBtinException { // open serial port and initialize it serialPort.openPort(); - serialPort.setParams(115200, 8, 1, 0); + serialPort.setParams(baudRate, 8, 1, 0); // clear port and make sure we are in configuration mode (close cmd) serialPort.writeBytes("\rC\r".getBytes());