Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Klipper3d/klipper.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchestwood96 <adi.joachim12@gmail.com>2022-06-30 20:56:35 +0300
committerGitHub <noreply@github.com>2022-06-30 20:56:35 +0300
commit167736ad1c127735806ba06858bc74c8ce6d49df (patch)
treee97c304b1f374c15107bc6b19c04e259936e2b0e
parenta8f08b08ca0b1c47312338438fe81809531e4cdb (diff)
respond: No forced spaces (#5152)
Signed-off-by: Adrian Joachim <adi.joachim12@gmail.com>
-rw-r--r--docs/G-Codes.md2
-rw-r--r--klippy/extras/respond.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/docs/G-Codes.md b/docs/G-Codes.md
index 789499802..afa808c89 100644
--- a/docs/G-Codes.md
+++ b/docs/G-Codes.md
@@ -1010,6 +1010,8 @@ The following additional commands are also available.
configured default prefix (or `echo: ` if no prefix is configured).
- `RESPOND TYPE=echo MSG="<message>"`: echo the message prepended with
`echo: `.
+- `RESPOND TYPE=echo_no_space MSG="<message>"`: echo the message prepended with
+ `echo:` without a space between prefix and message, helpful for compatibility with some octoprint plugins that expect very specific formatting.
- `RESPOND TYPE=command MSG="<message>"`: echo the message prepended
with `// `. OctoPrint can be configured to respond to these messages
(e.g. `RESPOND TYPE=command MSG=action:pause`).
diff --git a/klippy/extras/respond.py b/klippy/extras/respond.py
index fb6eb1946..047abb773 100644
--- a/klippy/extras/respond.py
+++ b/klippy/extras/respond.py
@@ -10,6 +10,10 @@ respond_types = {
'error' : '!!',
}
+respond_types_no_space = {
+ 'echo_no_space': 'echo:',
+}
+
class HostResponder:
def __init__(self, config):
self.printer = config.get_printer()
@@ -26,19 +30,26 @@ class HostResponder:
gcmd.respond_raw("%s %s" % (self.default_prefix, msg))
cmd_RESPOND_help = ("Echo the message prepended with a prefix")
def cmd_RESPOND(self, gcmd):
+ no_space = False
respond_type = gcmd.get('TYPE', None)
prefix = self.default_prefix
if(respond_type != None):
respond_type = respond_type.lower()
if(respond_type in respond_types):
prefix = respond_types[respond_type]
+ elif(respond_type in respond_types_no_space):
+ prefix = respond_types_no_space[respond_type]
+ no_space = True
else:
raise gcmd.error(
"RESPOND TYPE '%s' is invalid. Must be one"
" of 'echo', 'command', or 'error'" % (respond_type,))
prefix = gcmd.get('PREFIX', prefix)
msg = gcmd.get('MSG', '')
- gcmd.respond_raw("%s %s" % (prefix, msg))
+ if(no_space):
+ gcmd.respond_raw("%s%s" % (prefix, msg))
+ else:
+ gcmd.respond_raw("%s %s" % (prefix, msg))
def load_config(config):
return HostResponder(config)