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 (or echo: 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 (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).
  • RESPOND TYPE=error MSG="<message>": echo the message prepended with !!.
  • RESPOND PREFIX=<prefix> MSG="<message>": echo the message prepended with <prefix>. (The PREFIX parameter will take priority over the TYPE 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

  • Prefix is added with space separated, so use empty prefix and send complete command in MSG instead. But problem is still that responses do not get resend and thus executed even if it looks like a command. There is one exception
    //run_script:NameOfScript
    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.
  • Sorry, but I did not get that!
    If I type in the console terminal 
    the result is
    Exec:12:05:21.802: @startCodeProcessed
    Recv:12:06:41.480: ok (80)
    means the command is executed. 
    If I send the message from the printer:
    I see in the console output
    Recv:12:00:53.832: @startCodeProcessed
    Recv:12:01:15.567: ok (22)
    The Message is received, documented in the log but not executed. Do I have to add something? I read from octoprint where it should be //action: to be added. But I don´t have octoprint to test.

    Can you give me an example what I have to write in the printer-config-file that RepetierServer understands as a command and executes?
     
    What matters are specific commands of the server, not printer G-Codes. Especially I want to send @pause and spomething like @shutdown to shutdown the server.
    Regards
     

  • Ok to make it easier here a full solution. In G-Codes->Event dependent->Run on Activation add this

    @func sendFWCommand cmd
      {{local.cmd}}
      @deleteMonitorCall RunForFirmware
      @monitorCall RunForFirmware "// action: send:(.*)" 0 sendFWCommand ""
    @deleteMonitorCall RunForFirmware
    @monitorCall RunForFirmware "// action: send:(.*)" 0 sendFWCommand ""

    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.
  • Thanks repetier!
    The example works:
    Exec:14:46:17.329: @call sendFWCommand "@echo Test message from firmware"
    Mesg:14:46:17.329: Test message from firmware
    and this too:

    RESPOND MSG="// action: send:@info 'Message from the Printer'"
    Recv:14:50:51.279: // action: send:@info 'Message from the Printer'
    Exec:14:50:51.279: @call sendFWCommand "@info 'Message from the Printer'"
    and the Message appears as info-Box in the UI.

    VERY GOOD!


Sign In or Register to comment.