Merge pull request #884 from Salandora/vp_dropConnection2
Adds !!DEBUG:drop_connection to the virtual Printer
This commit is contained in:
commit
d34b73cd7c
1 changed files with 12 additions and 0 deletions
|
|
@ -73,8 +73,11 @@ class VirtualPrinter():
|
|||
|
||||
self._dont_answer = False
|
||||
|
||||
self._debug_drop_connection = False
|
||||
|
||||
self._action_hooks = plugin_manager().get_hooks("octoprint.plugin.virtual_printer.custom_action")
|
||||
|
||||
|
||||
waitThread = threading.Thread(target=self._sendWaitAfterTimeout)
|
||||
waitThread.start()
|
||||
|
||||
|
|
@ -304,6 +307,8 @@ class VirtualPrinter():
|
|||
self._triggerResend(expected=self.lastN, actual=self.lastN+1)
|
||||
elif data == "trigger_resend_checksum":
|
||||
self._triggerResend(expected=self.lastN)
|
||||
elif data == "drop_connection":
|
||||
self._debug_drop_connection = True
|
||||
else:
|
||||
try:
|
||||
sleep_match = VirtualPrinter.sleep_regex.match(data)
|
||||
|
|
@ -638,6 +643,10 @@ class VirtualPrinter():
|
|||
self._performMove(line)
|
||||
|
||||
def write(self, data):
|
||||
if self._debug_drop_connection:
|
||||
raise SerialTimeoutException()
|
||||
return
|
||||
|
||||
with self._incoming_lock:
|
||||
if self.incoming is None or self.outgoing is None:
|
||||
return
|
||||
|
|
@ -647,6 +656,9 @@ class VirtualPrinter():
|
|||
raise SerialTimeoutException()
|
||||
|
||||
def readline(self):
|
||||
if self._debug_drop_connection:
|
||||
raise SerialTimeoutException()
|
||||
|
||||
try:
|
||||
line = self.outgoing.get(timeout=self._read_timeout)
|
||||
time.sleep(settings().getFloat(["devel", "virtualPrinter", "throttle"]))
|
||||
|
|
|
|||
Loading…
Reference in a new issue