Skip to content

Commit ec7cc8c

Browse files
cmaglieFederico Fissore
authored and
Federico Fissore
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 #3389 See #3351
1 parent 0b59fc9 commit ec7cc8c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: 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)