Providing a more meaningful error message when attempting to open serial monitor and linux user misses permission on device. Fixes #2100

This commit is contained in:
Federico Fissore 2015-06-17 12:26:50 +02:00
parent bc05c40aa0
commit c4e1458b1d
1 changed files with 4 additions and 1 deletions

View File

@ -123,7 +123,10 @@ public class Serial implements SerialPortEventListener {
port.openPort();
port.setParams(rate, databits, stopbits, parity, true, true);
port.addEventListener(this);
} catch (Exception e) {
} catch (SerialPortException e) {
if (e.getPortName().startsWith("/dev") && SerialPortException.TYPE_PERMISSION_DENIED.equals(e.getExceptionType())) {
throw new SerialException(I18n.format(_("Error opening serial port ''{0}''. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission"), iname));
}
throw new SerialException(I18n.format(_("Error opening serial port ''{0}''."), iname), e);
}