✨ Add setting for parity double open workaround

Can now be set to be applied if possibly needed (OS is a Debian Linux),
always or never.

Closes #3169, enhances #3167
This commit is contained in:
Gina Häußge committed 2019-05-20 16:46:45 +02:00
1 parent 3bd9d11fc3
commit 12be637f85
5 files changed
+29 -5

No files matched your search

+5
View File
@@ -172,6 +172,7 @@ def getSettings():
"ignoreIdenticalResends": s.getBoolean(["serial", "ignoreIdenticalResends"]),
"firmwareDetection": s.getBoolean(["serial", "firmwareDetection"]),
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
"useParityWorkaround": s.get(["serial", "useParityWorkaround"]),
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
@@ -459,6 +460,10 @@ def _saveSettings(data):
if "ignoreIdenticalResends" in data["serial"]: s.setBoolean(["serial", "ignoreIdenticalResends"], data["serial"]["ignoreIdenticalResends"])
if "firmwareDetection" in data["serial"]: s.setBoolean(["serial", "firmwareDetection"], data["serial"]["firmwareDetection"])
if "blockWhileDwelling" in data["serial"]: s.setBoolean(["serial", "blockWhileDwelling"], data["serial"]["blockWhileDwelling"])
if "useParityWorkaround" in data["serial"]:
value = data["serial"]["useParityWorkaround"]
if value in ("always", "detect", "never"):
s.set(["serial", "useParityWorkaround"], value)
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
if "abortHeatupOnCancel" in data["serial"]: s.setBoolean(["serial", "abortHeatupOnCancel"], data["serial"]["abortHeatupOnCancel"])
+1
View File
@@ -144,6 +144,7 @@ default_settings = {
"supportFAsCommand": False,
"firmwareDetection": True,
"blockWhileDwelling": False,
"useParityWorkaround": "detect",
"capabilities": {
"autoreport_temp": True,
@@ -185,6 +185,7 @@ $(function() {
self.serial_ignoreIdenticalResends = ko.observable(undefined);
self.serial_firmwareDetection = ko.observable(undefined);
self.serial_blockWhileDwelling = ko.observable(undefined);
self.serial_useParityWorkaround = ko.observable(undefined);
self.serial_supportResendsWithoutOk = ko.observable(undefined);
self.serial_logPositionOnPause = ko.observable(undefined);
self.serial_logPositionOnCancel = ko.observable(undefined);
@@ -33,7 +33,7 @@
<label class="control-label" for="settings-serialAdditionalPorts">{{ _('Additional serial ports') }}</label>
<div class="controls">
<textarea rows="4" class="block" id="settings-serialAdditionalPorts" data-bind="value: serial_additionalPorts"></textarea>
<span class="help-inline">{{ _('Use this to define additional <a href="%%(glob_url)s">glob patterns</a> matching serial ports to list for connecting against, e.g. <code>/dev/ttyAMA*</code>. One entry per line.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
<span class="help-inline">{{ _('Use this to define additional <a href="%%(glob_url)s">glob patterns</a> matching serial ports to list for connecting against, e.g. <code>/dev/ttyAMA*</code>. One entry per line. Please note that ports will only be offered to connect to if they get also detected by the <em>operating system</em>. Adding a port here will not make it magically appear in OctoPrint. If the operating system doesn\'t see your printer you need to solve this first.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
</div>
</div>
<div class="control-group">
@@ -51,6 +51,22 @@
</label>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Apply parity double open workaround')}}</label>
<div class="controls">
<label class="radio">
<input type="radio" name="useParityWorkaroundGroup" value="always" data-bind="checked: serial_useParityWorkaround" id="settings-serialUseParityWorkaroundAlways"> {{ _('Always') }}
<span class="help-block">{{ _('Use this if you are running into <a href="%%(url)s" target="_blank" rel="noopener noreferer">this problem</a>.')|format(url="https://forum.arduino.cc/index.php?topic=91291.0") }}</span>
</label>
<label class="radio">
<input type="radio" name="useParityWorkaroundGroup" value="detect" data-bind="checked: serial_useParityWorkaround" id="settings-serialUseParityWorkaroundPrint"> {{ _('If detected as potentially needed') }}
</label>
<label class="radio">
<input type="radio" name="useParityWorkaroundGroup" value="never" data-bind="checked: serial_useParityWorkaround" id="settings-serialUseParityWorkaroundNever"> {{ _('Never') }}
<span class="help-block">{{ _('Use this if connecting to your printer fails with <code>(22, \'Invalid argument\')</code>.') }}</span>
</label>
</div>
</div>
</fieldset>
<fieldset id="settings_serial_general_logging">
<legend>{{ _('Serial logging') }}</legend>
+5 -4
View File
@@ -2625,14 +2625,15 @@ class MachineCom(object):
serial_obj = serial.Serial(**serial_port_args)
serial_obj.port = str(port)
# This may also not be applicable to other platforms, in which case
# this should probably get rewritten as a whitelist for the platforms
# that have issues here.
if get_os() != 'freebsd':
use_parity_workaround = settings().get(["serial", "useParityWorkaround"])
needs_parity_workaround = True #get_os() == "linux" and os.path.exists("/etc/debian_version") # See #673
if use_parity_workaround == "always" or (needs_parity_workaround and use_parity_workaround == "detect"):
serial_obj.parity = serial.PARITY_ODD
serial_obj.open()
serial_obj.close()
serial_obj.parity = serial.PARITY_NONE
serial_obj.open()
return BufferedReadlineWrapper(serial_obj)