Skip to content

Commit 3f57ed7

Browse files
committed
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 arduino#3389 See arduino#3351
1 parent c08d4fd commit 3f57ed7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arduino-core/src/processing/app/Serial.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ private Serial(String iname, int irate, char iparity, int idatabits, float istop
112112
try {
113113
port = new SerialPort(iname);
114114
port.openPort();
115-
port.setParams(irate, idatabits, stopbits, parity, true, true);
115+
boolean res = port.setParams(irate, idatabits, stopbits, parity, true, true);
116+
if (!res) {
117+
System.err.println(format(_("Error while setting serial port parameters: {0} {1} {2} {3}"),
118+
irate, iparity, idatabits, istopbits));
119+
}
116120
port.addEventListener(this);
117121
} catch (SerialPortException e) {
118122
if (e.getPortName().startsWith("/dev") && SerialPortException.TYPE_PERMISSION_DENIED.equals(e.getExceptionType())) {

0 commit comments

Comments
 (0)