Virtual printer: select_sd command
This commit is contained in:
1 parent
b7a8c29fb4
commit
e2f626d421
2 files changed
+69
-47
No files matched your search
@@ -57,60 +57,71 @@ You can simulate certain conditions and communications through the terminal tab
|
||||
|
||||
All commands start with ``!!DEBUG:`` and are followed by the command you want to execute. For instance, sending
|
||||
``!!DEBUG:action_disconnect`` will disconnect the printer. Sending ``!!DEBUG`` without command will show a help
|
||||
message with all the available commands.
|
||||
message with all the available commands:
|
||||
|
||||
Action Triggers
|
||||
...............
|
||||
.. code-block:: none
|
||||
|
||||
``action_pause``
|
||||
Sends a "// action:pause" action trigger to the host.
|
||||
OctoPrint Virtual Printer debug commands
|
||||
|
||||
``action_resume``
|
||||
Sends a "// action:resume" action trigger to the host.
|
||||
help
|
||||
?
|
||||
| This help.
|
||||
|
||||
``action_disconnect``
|
||||
Sends a "// action:disconnect" action trigger to the host.
|
||||
# Action Triggers
|
||||
|
||||
``action_custom <action>[ <parameters>]``
|
||||
Sends a custom "// action:<action> <parameters>" action trigger to the host.
|
||||
action_pause
|
||||
| Sends a "// action:pause" action trigger to the host.
|
||||
action_resume
|
||||
| Sends a "// action:resume" action trigger to the host.
|
||||
action_disconnect
|
||||
| Sends a "// action:disconnect" action trigger to the
|
||||
| host.
|
||||
action_custom <action>[ <parameters>]
|
||||
| Sends a custom "// action:<action> <parameters>"
|
||||
| action trigger to the host.
|
||||
|
||||
Communication Errors
|
||||
....................
|
||||
# Communication Errors
|
||||
|
||||
``dont_answer``
|
||||
Will not acknowledge the next command.
|
||||
dont_answer
|
||||
| Will not acknowledge the next command.
|
||||
go_awol
|
||||
| Will completely stop replying
|
||||
trigger_resend_lineno
|
||||
| Triggers a resend error with a line number mismatch
|
||||
trigger_resend_checksum
|
||||
| Triggers a resend error with a checksum mismatch
|
||||
trigger_missing_checksum
|
||||
| Triggers a resend error with a missing checksum
|
||||
trigger_missing_lineno
|
||||
| Triggers a "no line number with checksum" error w/o resend request
|
||||
drop_connection
|
||||
| Drops the serial connection
|
||||
prepare_ok <broken ok>
|
||||
| Will cause <broken ok> to be enqueued for use,
|
||||
| will be used instead of actual "ok"
|
||||
|
||||
``go_awol``
|
||||
Will completely stop replying.
|
||||
# Reply Timing / Sleeping
|
||||
|
||||
``trigger_resend_lineno``
|
||||
Triggers a resend error with a line number mismatch
|
||||
sleep <int:seconds>
|
||||
| Sleep <seconds> s
|
||||
sleep_after <str:command> <int:seconds>
|
||||
| Sleeps <seconds> s after each execution of <command>
|
||||
sleep_after_next <str:command> <int:seconds>
|
||||
| Sleeps <seconds> s after execution of next <command>
|
||||
|
||||
``trigger_resend_checksum``
|
||||
Triggers a resend error with a checksum mismatch
|
||||
# SD printing
|
||||
|
||||
``drop_connection``
|
||||
Drops the serial connection
|
||||
start_sd <str:file>
|
||||
| Select and start printing file <file> from SD
|
||||
select_sd <str:file>
|
||||
| Select file <file> from SD, don't start printing it yet. Use
|
||||
| start_sd to start the print
|
||||
cancel_sd
|
||||
| Cancels an ongoing SD print
|
||||
|
||||
``prepare_ok <broken ok>``
|
||||
Will cause <broken ok> to be enqueued for use, will be used instead of actual "ok"
|
||||
# Misc
|
||||
|
||||
Reply Timing / Sleeping
|
||||
.......................
|
||||
``sleep <int:seconds>``
|
||||
Sleep <seconds> s
|
||||
|
||||
``sleep_after <str:command> <int:seconds>``
|
||||
Sleeps <seconds> s after each execution of <command>
|
||||
|
||||
``sleep_after_next <str:command> <int:seconds>``
|
||||
Sleeps <seconds> s after execution of next <command>
|
||||
|
||||
Misc
|
||||
....
|
||||
|
||||
``help``
|
||||
Show the available commands.
|
||||
|
||||
``send <str:message>``
|
||||
Sends back <message>
|
||||
send <str:message>
|
||||
| Sends back <message>
|
||||
reset
|
||||
| Simulates a reset. Internal state will be lost.
|
||||
@@ -30,6 +30,7 @@ class VirtualPrinter(object):
|
||||
send_regex = re.compile("send (.*)")
|
||||
set_ambient_regex = re.compile("set_ambient ([-+]?[0-9]*\.?[0-9]+)")
|
||||
start_sd_regex = re.compile("start_sd (.*)")
|
||||
select_sd_regex = re.compile("select_sd (.*)")
|
||||
|
||||
def __init__(self, seriallog_handler=None, read_timeout=5.0, write_timeout=10.0):
|
||||
import logging
|
||||
@@ -736,7 +737,10 @@ class VirtualPrinter(object):
|
||||
# SD printing
|
||||
|
||||
start_sd <str:file>
|
||||
| Start printing file <file> from SD
|
||||
| Select and start printing file <file> from SD
|
||||
select_sd <str:file>
|
||||
| Select file <file> from SD, don't start printing it yet. Use
|
||||
| start_sd to start the print
|
||||
cancel_sd
|
||||
| Cancels an ongoing SD print
|
||||
|
||||
@@ -793,6 +797,7 @@ class VirtualPrinter(object):
|
||||
send_match = VirtualPrinter.send_regex.match(data)
|
||||
set_ambient_match = VirtualPrinter.set_ambient_regex.match(data)
|
||||
start_sd_match = VirtualPrinter.start_sd_regex.match(data)
|
||||
select_sd_match = VirtualPrinter.select_sd_regex.match(data)
|
||||
|
||||
if sleep_match is not None:
|
||||
interval = int(sleep_match.group(1))
|
||||
@@ -822,8 +827,10 @@ class VirtualPrinter(object):
|
||||
self._ambient_temperature = float(set_ambient_match.group(1))
|
||||
self._send("// set ambient temperature to {}".format(self._ambient_temperature))
|
||||
elif start_sd_match is not None:
|
||||
self._selectSdFile(start_sd_match.group(1))
|
||||
self._selectSdFile(start_sd_match.group(1), check_already_open=True)
|
||||
self._startSdPrint()
|
||||
elif select_sd_match is not None:
|
||||
self._selectSdFile(select_sd_match.group(1))
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -843,10 +850,14 @@ class VirtualPrinter(object):
|
||||
self._send(item)
|
||||
self._send("End file list")
|
||||
|
||||
def _selectSdFile(self, filename):
|
||||
def _selectSdFile(self, filename, check_already_open=False):
|
||||
if filename.startswith("/"):
|
||||
filename = filename[1:]
|
||||
|
||||
file = os.path.join(self._virtualSd, filename.lower())
|
||||
if self._selectedSdFile == file and check_already_open:
|
||||
return
|
||||
|
||||
if not os.path.exists(file) or not os.path.isfile(file):
|
||||
self._send("open failed, File: %s." % filename)
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user