settings: Automatically add klipper serial port
This commit is contained in:
parent
0195cbf2ba
commit
aabd536566
|
@ -14,7 +14,6 @@ This plugin assists in managing and monitoring the [Klipper](https://github.com/
|
||||||
Usable
|
Usable
|
||||||
|
|
||||||
### ToDo
|
### ToDo
|
||||||
- On first install automatically check/add virtual serialport as descriped [here](https://github.com/KevinOConnor/klipper/blob/master/docs/Installation.md#configuring-octoprint-to-use-klipper) in the klipper docs. You need to do this manually for now if you haven't already.
|
|
||||||
- Add a continously updated status display in octoprints navbar.
|
- Add a continously updated status display in octoprints navbar.
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
|
@ -11,10 +11,20 @@ class KlipperPlugin(
|
||||||
octoprint.plugin.SettingsPlugin,
|
octoprint.plugin.SettingsPlugin,
|
||||||
octoprint.plugin.AssetPlugin):
|
octoprint.plugin.AssetPlugin):
|
||||||
|
|
||||||
|
_parsingReturn = False
|
||||||
|
_message = ""
|
||||||
|
|
||||||
#-- Startupt Plugin
|
#-- Startupt Plugin
|
||||||
|
|
||||||
def on_after_startup(self):
|
def on_after_startup(self):
|
||||||
pass
|
klipperPort = self._settings.get(["serialport"])
|
||||||
|
additionalPorts = self._settings.global_get(["serial", "additionalPorts"])
|
||||||
|
|
||||||
|
if klipperPort not in additionalPorts:
|
||||||
|
additionalPorts.append(klipperPort)
|
||||||
|
self._settings.global_set(["serial", "additionalPorts"], additionalPorts)
|
||||||
|
self._settings.save()
|
||||||
|
self._logger.info("Added klipper serial port (%s) to list of additional ports." % klipperPort)
|
||||||
|
|
||||||
#-- Settings Plugin
|
#-- Settings Plugin
|
||||||
|
|
||||||
|
@ -59,13 +69,13 @@ class KlipperPlugin(
|
||||||
|
|
||||||
def on_parse_gcode(self, comm, line, *args, **kwargs):
|
def on_parse_gcode(self, comm, line, *args, **kwargs):
|
||||||
if "//" in line:
|
if "//" in line:
|
||||||
self.parsingReturn = True
|
self._parsingReturn = True
|
||||||
self.message = self.message + line.strip('/')
|
self._message = self._message + line.strip('/')
|
||||||
else:
|
else:
|
||||||
if self.parsingReturn:
|
if self._parsingReturn:
|
||||||
self.parsingReturn = False
|
self._parsingReturn = False
|
||||||
self.logInfo(self.message)
|
self.logInfo(self.message)
|
||||||
self.message = ""
|
self._message = ""
|
||||||
if "!!" in line:
|
if "!!" in line:
|
||||||
self.logError(line.strip('!'))
|
self.logError(line.strip('!'))
|
||||||
return line
|
return line
|
||||||
|
@ -73,8 +83,6 @@ class KlipperPlugin(
|
||||||
|
|
||||||
#-- Helpers
|
#-- Helpers
|
||||||
|
|
||||||
parsingReturn = False
|
|
||||||
message = ""
|
|
||||||
|
|
||||||
def logInfo(self, message):
|
def logInfo(self, message):
|
||||||
self._plugin_manager.send_plugin_message(
|
self._plugin_manager.send_plugin_message(
|
||||||
|
|
Loading…
Reference in New Issue