From ec7cc8c5cf6cc766b28f554729bbd98e00188d98 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 7cfc327aa..904e8b9a8 100644 --- a/arduino-core/src/processing/app/Serial.java +++ b/arduino-core/src/processing/app/Serial.java @@ -112,7 +112,11 @@ public class Serial implements SerialPortEventListener { 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())) {