add getSettingsDict and applySettingsDict
diff --git a/pyserial/documentation/pyserial_api.rst b/pyserial/documentation/pyserial_api.rst
index fbe0e9d..8f413f7 100644
--- a/pyserial/documentation/pyserial_api.rst
+++ b/pyserial/documentation/pyserial_api.rst
@@ -392,6 +392,30 @@
 
         .. versionadded:: 2.5
 
+     .. method:: getSettingsDict()
+
+        :return: a dictionary with current port settings.
+
+        Get a dictionary with port settings. This is useful to backup the
+        current settings so that a later point in time they can be restored
+        using :meth:`applySettingsDict`.
+
+        Note that control lines (RTS/DTR) are part of the settings.
+
+        .. versionadded:: 2.5
+
+     .. method:: applySettingsDict(d)
+
+        :param d: a dictionary with port settings.
+
+        Applies a dictionary that was created by :meth:`getSettingsDict`. Only
+        changes are applied and when a key is missing it means that the setting
+        stays unchanged.
+
+        Note that control lines (RTS/DTR) are not changed.
+
+        .. versionadded:: 2.5
+
 
 .. note::
 
diff --git a/pyserial/serial/serialutil.py b/pyserial/serial/serialutil.py
index 2a3253c..db8f645 100644
--- a/pyserial/serial/serialutil.py
+++ b/pyserial/serial/serialutil.py
@@ -399,6 +399,23 @@
 
     interCharTimeout = property(getInterCharTimeout, setInterCharTimeout, doc="Inter-character timeout setting for read()")
 
+    #  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+
+    _SETTINGS = ('baudrate', 'bytesize', 'parity', 'stopbits', 'xonxoff',
+            'dsrdtr', 'rtscts', 'timeout', 'writeTimeout', 'interCharTimeout')
+
+    def getSettingsDict(self):
+        """Get current port settings as a dictionary. For use with
+        applySettingsDict"""
+        return dict([(key, getattr(self, '_'+key)) for key in self._SETTINGS])
+
+    def applySettingsDict(self, d):
+        """apply stored settings from a dictionary returned from
+        getSettingsDict. it's allowed to delete keys from the dictionary. these
+        values will simply left unchanged."""
+        for key in self._SETTINGS:
+            if d[key] != getattr(self, '_'+key):   # check against internal "_" value
+                setattr(self, key, d[key])          # set non "_" value to use properties write function
 
     #  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -