mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Added default fallback values to serial parameters used in Serial constructor. Fixes #3381
This commit is contained in:
parent
380b147dae
commit
a49f1b264a
@ -195,6 +195,18 @@ public class PreferencesData {
|
||||
set(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
static public float getFloat(String attribute, float defaultValue) {
|
||||
if (has(attribute)) {
|
||||
return getFloat(attribute);
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static public float getFloat(String attribute) {
|
||||
return Float.parseFloat(get(attribute));
|
||||
}
|
||||
|
||||
// get a copy of the Preferences
|
||||
static public PreferencesMap getMap() {
|
||||
return new PreferencesMap(prefs);
|
||||
|
@ -49,30 +49,30 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
public Serial() throws SerialException {
|
||||
this(PreferencesData.get("serial.port"),
|
||||
PreferencesData.getInteger("serial.debug_rate"),
|
||||
PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
Float.parseFloat(PreferencesData.get("serial.stopbits")));
|
||||
PreferencesData.getInteger("serial.debug_rate", 9600),
|
||||
PreferencesData.get("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits", 8),
|
||||
PreferencesData.getFloat("serial.stopbits", 1));
|
||||
}
|
||||
|
||||
public Serial(int irate) throws SerialException {
|
||||
this(PreferencesData.get("serial.port"), irate,
|
||||
PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
Float.parseFloat(PreferencesData.get("serial.stopbits")));
|
||||
PreferencesData.get("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits", 8),
|
||||
PreferencesData.getFloat("serial.stopbits", 1));
|
||||
}
|
||||
|
||||
public Serial(String iname, int irate) throws SerialException {
|
||||
this(iname, irate, PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
Float.parseFloat(PreferencesData.get("serial.stopbits")));
|
||||
this(iname, irate, PreferencesData.get("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits", 8),
|
||||
PreferencesData.getFloat("serial.stopbits", 1));
|
||||
}
|
||||
|
||||
public Serial(String iname) throws SerialException {
|
||||
this(iname, PreferencesData.getInteger("serial.debug_rate"),
|
||||
PreferencesData.get("serial.parity").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits"),
|
||||
Float.parseFloat(PreferencesData.get("serial.stopbits")));
|
||||
this(iname, PreferencesData.getInteger("serial.debug_rate", 9600),
|
||||
PreferencesData.get("serial.parity", "N").charAt(0),
|
||||
PreferencesData.getInteger("serial.databits", 8),
|
||||
PreferencesData.getFloat("serial.stopbits", 1));
|
||||
}
|
||||
|
||||
public static boolean touchForCDCReset(String iname) throws SerialException {
|
||||
|
Loading…
Reference in New Issue
Block a user