Add GPX as a serial port filter
The idea is to have GPX translate between g-codes and x3g. GPX already does a pretty good job for output gcode intended for print instructions, that is the gcode output by slicers. It has some minimal support for talking directly to the printer and receiving data back from the printer. What I'm hoping to add is translation of printer output to responses a generic Marlin printer might produce. For now, I'm focused on the I/O that OctoPrint uses.
This commit is contained in:
1 parent
4e9f9cdb16
commit
ae712d9878
3 files changed
+30
-3
No files matched your search
@@ -23,7 +23,8 @@ extensions = dict(
|
||||
),
|
||||
# extensions for printable machine code
|
||||
machinecode=dict(
|
||||
gcode=["gcode", "gco", "g"]
|
||||
gcode=["gcode", "gco", "g"],
|
||||
x3g=["x3g", "s3g"]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -291,6 +291,7 @@ class PrinterProfileManager(object):
|
||||
import yaml
|
||||
with open(path) as f:
|
||||
profile = yaml.safe_load(f)
|
||||
profile = dict_merge(self._load_default(), profile)
|
||||
profile = self._ensure_valid_profile(profile)
|
||||
if not profile:
|
||||
self._logger.warn("Invalid profile: %s" % path)
|
||||
|
||||
@@ -173,6 +173,7 @@ class MachineCom(object):
|
||||
self._gcode_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.gcode")
|
||||
self._printer_action_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.action")
|
||||
self._gcodescript_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.scripts")
|
||||
self._serial_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.serial")
|
||||
|
||||
# SD status data
|
||||
self._sdAvailable = False
|
||||
@@ -1166,8 +1167,7 @@ class MachineCom(object):
|
||||
else:
|
||||
return False
|
||||
|
||||
def _openSerial(self):
|
||||
if self._port == 'AUTO':
|
||||
def detectPort(self, close):
|
||||
self._changeState(self.STATE_DETECT_SERIAL)
|
||||
programmer = stk500v2.Stk500v2()
|
||||
self._log("Serial port list: %s" % (str(serialList())))
|
||||
@@ -1188,6 +1188,31 @@ class MachineCom(object):
|
||||
self._errorValue = 'Failed to autodetect serial port.'
|
||||
self._changeState(self.STATE_ERROR)
|
||||
eventManager().fire(Events.ERROR, {"error": self.getErrorString()})
|
||||
return None
|
||||
if (close):
|
||||
self._serial.close()
|
||||
self._serial = None
|
||||
return p
|
||||
|
||||
def _openSerial(self):
|
||||
self._logger.info("_openSerial")
|
||||
for hook in self._serial_hooks:
|
||||
_serialT = None
|
||||
try:
|
||||
serialT = self._serial_hooks[hook](self, self._port, self._baudrate, settings().getFloat(["serial", "timeout", "connection"]))
|
||||
except Exception as e:
|
||||
self._errorValue = get_exception_string()
|
||||
self._changeState(self.STATE_ERROR)
|
||||
eventManager().fire(Events.ERROR, {"error": self.getErrorString()})
|
||||
return False
|
||||
if serialT is not None:
|
||||
self._changeState(self.STATE_OPEN_SERIAL);
|
||||
self._serial = serialT
|
||||
return True
|
||||
# first hook to succeed wins, but any can pass on to the next
|
||||
|
||||
if self._port is None or self._port == 'AUTO':
|
||||
if self._detectPort(False) is None:
|
||||
return False
|
||||
elif self._port == 'VIRTUAL':
|
||||
self._changeState(self.STATE_OPEN_SERIAL)
|
||||
|
||||
Reference in new issue
Block a user