From 7c19190b703677b6c2793227e1cf41e4e1fadb2b Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Thu, 13 Jul 2017 06:49:05 +0000 Subject: [PATCH] Add one kind of AUTO for GPX It'll recognize a MakerBot The Replicator or clone that reports the same usb ids and AUTO for baudrate means 115200. Anything else will fail with an error that says to choose a port and baudrate. --- GPX | 2 +- octoprint_GPX/__init__.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/GPX b/GPX index b3ce399..56e3a48 160000 --- a/GPX +++ b/GPX @@ -1 +1 @@ -Subproject commit b3ce39913b618efd0ee66f6e0747e92eef4b3b8d +Subproject commit 56e3a484e0c86b5c5dff2e6332d0322b39a4c866 diff --git a/octoprint_GPX/__init__.py b/octoprint_GPX/__init__.py index ebcf93e..aadd481 100644 --- a/octoprint_GPX/__init__.py +++ b/octoprint_GPX/__init__.py @@ -111,8 +111,19 @@ def serial_factory(self, comm, port, baudrate, timeout, *args, **kwargs): self.override_progress = True self._logger.info("Connecting through x3g.") try: + if port is None or port == 'AUTO': + try: + import glob + ports = glob.glob("/dev/serial/by-id/*MakerBot_Industries_The_Replicator*") + if ports: + port = os.path.normpath(os.path.join("/dev/serial/by-id/", os.readlink(ports[0]))) + except: + # oh well, it was worth a try + self._logger.debug("Failed to discover port via /dev/serial/by-id") + if not baudrate: + baudrate = 115200 if port is None or port == 'AUTO' or baudrate is None or baudrate == 0: - raise IOError("AUTO port and baudrate not currently supported by GPX") + raise IOError("GPX plugin not able to discover AUTO port and/or baudrate. Please choose specific values for them.") from .gpxprinter import GpxPrinter self.printer = GpxPrinter(self, port, baudrate, timeout)