Merge branch 'maintenance' of github.com:OctoPrint/OctoPrint into maintenance
This commit is contained in:
commit
74ada33fa2
2 files changed
+28
No files matched your search
@@ -74,6 +74,8 @@ class VirtualPrinterPlugin(
|
||||
"enable_eeprom": True,
|
||||
"support_M503": True,
|
||||
"resend_ratio": 0,
|
||||
"locked": False,
|
||||
"passcode": "1234",
|
||||
}
|
||||
|
||||
def get_settings_version(self):
|
||||
|
||||
@@ -186,6 +186,8 @@ class VirtualPrinter(object):
|
||||
|
||||
self._capabilities = self._settings.get(["capabilities"], merged=True)
|
||||
|
||||
self._locked = self._settings.get_boolean(["locked"])
|
||||
|
||||
self._temperature_reporter = None
|
||||
self._sdstatus_reporter = None
|
||||
self._pos_reporter = None
|
||||
@@ -317,6 +319,8 @@ class VirtualPrinter(object):
|
||||
for item in self._settings.get(["resetLines"]):
|
||||
self._send(item + "\n")
|
||||
|
||||
self._locked = self._settings.get_boolean(["locked"])
|
||||
|
||||
@property
|
||||
def timeout(self):
|
||||
return self._read_timeout
|
||||
@@ -514,11 +518,17 @@ class VirtualPrinter(object):
|
||||
if command_match is not None:
|
||||
if self._broken_klipper_connection:
|
||||
self._send("!! Lost communication with MCU 'mcu'")
|
||||
self._sendOk()
|
||||
continue
|
||||
|
||||
command = command_match.group(0)
|
||||
letter = command_match.group(1)
|
||||
|
||||
if self._locked and command != "M511":
|
||||
self._send("echo:Printer locked! (Unlock with M511 or LCD)")
|
||||
self._sendOk()
|
||||
continue
|
||||
|
||||
try:
|
||||
# if we have a method _gcode_G, _gcode_M or _gcode_T, execute that first
|
||||
letter_handler = "_gcode_{}".format(letter)
|
||||
@@ -900,6 +910,22 @@ class VirtualPrinter(object):
|
||||
else:
|
||||
time.sleep(timeout)
|
||||
|
||||
# Passcode Feature - lock with M510, unlock with M511 P<passcode>.
|
||||
# https://marlinfw.org/docs/gcode/M510.html / https://marlinfw.org/docs/gcode/M511.html
|
||||
|
||||
def _gcode_M510(self, data):
|
||||
self._locked = True
|
||||
|
||||
def _gcode_M511(self, data):
|
||||
if self._locked:
|
||||
matchP = re.search(r"P([0-9]+)", data)
|
||||
if matchP:
|
||||
passcode = matchP.group(1)
|
||||
if passcode == self._settings.get(["passcode"]):
|
||||
self._locked = False
|
||||
else:
|
||||
self._send("Incorrect passcode")
|
||||
|
||||
# EEPROM management commands
|
||||
|
||||
def _gcode_M500(self, data):
|
||||
|
||||
Reference in new issue
Block a user