From 1ae881caee70f1f47a4712a8592783f9ab7afb3a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 15 Dec 2017 16:03:58 +0100 Subject: [PATCH] USB device is first added and then trying to connect. This is to ensure that USB printers work without autodetect --- plugins/USBPrinting/USBPrinterOutputDevice.py | 2 +- plugins/USBPrinting/USBPrinterOutputDeviceManager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 8b4961c19c..867233561e 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -127,10 +127,10 @@ class USBPrinterOutputDevice(PrinterOutputDevice): try: self._serial = Serial(str(self._serial_port), self._baud_rate, timeout=self._timeout, writeTimeout=self._timeout) except SerialException: + Logger.log("w", "An exception occured while trying to create serial connection") return container_stack = Application.getInstance().getGlobalContainerStack() num_extruders = container_stack.getProperty("machine_extruder_count", "value") - # Ensure that a printer is created. self._printers = [PrinterOutputModel(output_controller=USBPrinterOuptutController(self), number_of_extruders=num_extruders)] self.setConnectionState(ConnectionState.connected) diff --git a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py index 0f98c11ddf..e13d8cef39 100644 --- a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py +++ b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py @@ -157,8 +157,8 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension): def addOutputDevice(self, serial_port): device = USBPrinterOutputDevice.USBPrinterOutputDevice(serial_port) device.connectionStateChanged.connect(self._onConnectionStateChanged) - device.connect() self._usb_output_devices[serial_port] = device + device.connect() ## Create a list of serial ports on the system. # \param only_list_usb If true, only usb ports are listed