🐛 Treat port=None as port=AUTO on autoconnect

Potential fix for #3267
This commit is contained in:
Gina Häußge committed 2019-10-31 11:09:54 +01:00
1 parent 888fb97e66
commit bee82bcde9
2 files changed
+8 -4

No files matched your search

+7 -3
View File
@@ -732,12 +732,16 @@ class Server(object):
# auto connect
if self._settings.getBoolean(["serial", "autoconnect"]):
self._logger.info("Autoconnect on startup is configured, trying to connect to the printer...")
try:
(port, baudrate) = self._settings.get(["serial", "port"]), self._settings.getInt(["serial", "baudrate"])
(port, baudrate) = self._settings.get(["serial", "port"]).strip(), self._settings.getInt(["serial", "baudrate"])
printer_profile = printerProfileManager.get_default()
connectionOptions = printer.__class__.get_connection_options()
if port in connectionOptions["ports"] or port == "AUTO":
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
if port in connectionOptions["ports"] or port == "AUTO" or port is None:
self._logger.info("Trying to connect to configured serial port {}".format(port))
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
else:
self._logger.info("Could not find configured serial port {} in the system, cannot automatically connect to a non existing printer. Is it plugged in and booted up yet?")
except:
self._logger.exception("Something went wrong while attempting to automatically connect to the printer")
+1 -1
View File
@@ -378,7 +378,7 @@ class MachineCom(object):
CAPABILITY_SUPPORT_DETECTED = "detected"
CAPABILITY_SUPPORT_DISABLED = "disabled"
def __init__(self, port = None, baudrate=None, callbackObject=None, printerProfileManager=None):
def __init__(self, port=None, baudrate=None, callbackObject=None, printerProfileManager=None):
self._logger = logging.getLogger(__name__)
self._serialLogger = logging.getLogger("SERIAL")
self._phaseLogger = logging.getLogger(__name__ + ".command_phases")