mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-13 10:29:35 +01:00
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
This commit is contained in:
parent
0b59fc91b0
commit
ec7cc8c5cf
@ -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())) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user