From 3f57ed73898566a059c2130a1ecf9b51a0af5b65 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 25 Jun 2015 13:00:27 +0200 Subject: [PATCH] Added check when setting serial port parameters This allows to detect for invalid baud rate settings in particular on Linux where the kernel do not allow non-standard baud rates on some devices. See #3389 See #3351 --- arduino-core/src/processing/app/Serial.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arduino-core/src/processing/app/Serial.java b/arduino-core/src/processing/app/Serial.java index 8a678dbce51..82ffa3d8b40 100644 --- a/arduino-core/src/processing/app/Serial.java +++ b/arduino-core/src/processing/app/Serial.java @@ -112,7 +112,11 @@ private Serial(String iname, int irate, char iparity, int idatabits, float istop try { port = new SerialPort(iname); port.openPort(); - port.setParams(irate, idatabits, stopbits, parity, true, true); + boolean res = port.setParams(irate, idatabits, stopbits, parity, true, true); + if (!res) { + System.err.println(format(_("Error while setting serial port parameters: {0} {1} {2} {3}"), + irate, iparity, idatabits, istopbits)); + } port.addEventListener(this); } catch (SerialPortException e) { if (e.getPortName().startsWith("/dev") && SerialPortException.TYPE_PERMISSION_DENIED.equals(e.getExceptionType())) {