Skip to content

Commit

Permalink
Add one kind of AUTO for GPX
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markwal committed Jul 13, 2017
1 parent 302463e commit 7c19190
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion GPX
13 changes: 12 additions & 1 deletion octoprint_GPX/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 7c19190

Please sign in to comment.