Sending command from klipper to Repetier-server
Good evening!
Klipper can send commands to Repetier-server via the Respond-function. From the klipper-docs:
[respond]¶
The following standard G-Code commands are available when the respond config section is enabled:
M118 <message>
: echo the message prepended with the configured default prefix (orecho:
if no prefix is configured).The following additional commands are also available.
RESPOND¶
RESPOND MSG="<message>"
: echo the message prepended with the configured default prefix (orecho:
if no prefix is configured).RESPOND TYPE=echo MSG="<message>"
: echo the message prepended withecho:
.RESPOND TYPE=echo_no_space MSG="<message>"
: echo the message prepended withecho:
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
).RESPOND TYPE=error MSG="<message>"
: echo the message prepended with!!
.RESPOND PREFIX=<prefix> MSG="<message>"
: echo the message prepended with<prefix>
. (ThePREFIX
parameter will take priority over theTYPE
parameter)
If I use this the sended command appears in the repetier servers command log, but it is not executed. I think I have some syntax errors but could not figure out how to do it right.
Example:
RESPOND PREFIX=@ MSG="reportTimer"
leads to:
Recv:22:35:43.189: @ reportTimer
There is a space between the @ and the command.
How can I send commands from klipper to repetier-server?
Regards
Comments
That would start a named script.
An other solution is to add in Printer Settings->G-Codes->Response to Event to add a regular expression that detects your trigger and in g-code the code you want to execute. This can be a complete script or just a single command just as you need.
save printer config, deactivate and activate printer to run the script. Now you can run in klipper somthing like this:
RESPOND MSG="// action: send:@echo Test message from firmware"
Note there is NO space after send: will not wotk with space as it is designed here. After send: you can use any command, it just gets resend by serve to klipper or in case of a server command executed on server side.
The reason why simple RESPOND does not work is that firmware can not send commands, just answers. This solution just adds a watcher for answers that uses part of it for detection to send the remaining part back.