Support busy protocol
We now official support Klipper since repetier-server version 0.90.0 and it works great with latest patch. However there is a problem with timeouts. Hosts normally have a timeout so they can reset failed communication e.g. a lost "ok". Also klipper with the server internal connection is unlikely to have that issue is still handled by the serial connect method, so it has a timeout to reset communication. See this log for example:
20:05:59.322: #bed_tilt_calibrate
20:06:12.139: // probe at 52.000,103.000 is z=1.795000
20:06:16.619: // probe at -25.000,25.000 is z=1.917500
20:06:20.427: // probe at 52.000,25.000 is z=1.867500
20:06:24.266: // probe at 130.000,25.000 is z=1.780000
20:06:28.122: // probe at 130.000,103.000 is z=1.732500
20:06:31.864: // probe at 130.000,175.000 is z=1.677500
20:06:35.738: // probe at 52.000,175.000 is z=1.717500
20:06:39.320: Warning: Communication timeout - resetting communication buffer.
20:06:39.320: Connection status: Buffered:123, Manual Commands: 1, Job Commands: 0
20:06:39.320: Buffer used:123 Enforced free byte:13 lines stored:9
20:06:39.586: // probe at -25.000,175.000 is z=1.652500
20:06:43.348: // probe at -25.000,103.000 is z=1.790000
20:06:43.735: // stepper_z position_endstop: 1.557416 (when Z homing at 52.000,103.000)
20:06:43.735: // x_adjust: -0.000367 y_adjust: -0.001149
20:06:43.735: // The above parameters have been applied to the current
20:06:43.735: // session. Update the printer config file with the above to
20:06:43.735: // use these settings in future sessions.
One solution is that users set timeout very high, but even if I write it somehwere they are likely to not read it. There is a official solution already supported by Repetier-Firmware and Marlin und hence understood by several hosts. It is sending
busy: reason
or Marlin like as
echo: busy: reason
every x seconds, normally every 2 seconds if firmware is blocking for longer then 2 seconds. This resets the timeout timer in host. So as long as this gets send every 2 seconds for slow commands hosts will not assume it is communication problem. The nice thing is that it works for all gcodes even if host do not know that a command is slow (especially here, where it is no gcode at all). Every "ok" on your side can reset your internal timer. If no commands are present you do not send busy of course. reason can be any string. Typical things are heating or processing. Important is to have no exceptions. If you support busy the timeout of 3 seconds on server side should not cause a timeout that way.
The # before the command tells the server to send the command 1:1 and not interpret it as gcode.
What do you think? I think this is the only solution mor ehosts support it. Otherwise I would need a special Klipper handling disabling timeout for that firmware. Would then be a server only solution that others would need to copy/implement as well. How sure is it that there will be no com errors between klipper and server? Not that I have seen one so far.
On Mon, Jul 09, 2018 at 12:27:18AM -0700, repetier wrote:
We now official support Klipper since repetier-server version 0.90.0 and it works great with latest patch.
Great!
However there is a problem with timeouts. Hosts normally have a timeout so they can reset failed communication e.g. a lost "ok". Also klipper with the server internal connection is unlikely to have that issue is still handled by the serial connect method, so it has a timeout to reset communication. See this log for example:
20:05:59.322: #bed_tilt_calibrate 20:06:12.139: // probe at 52.000,103.000 is z=1.795000 20:06:16.619: // probe at -25.000,25.000 is z=1.917500 20:06:20.427: // probe at 52.000,25.000 is z=1.867500
Why not reset the timeout on any valid input that is received from the printer? This is what (it appears) OctoPrint does.
How sure is it that there will be no com errors between klipper and server? Not that I have seen one so far.
A pseudo-tty won't drop or corrupt data.
-Kevin
Why not reset the timeout on any valid input that is received from the printer? This is what (it appears) OctoPrint does.
Bad idea in general. Marlin/Repetier for example support autoreport temperature. So we get a response every second, but that does not say anything about the commands being executed or waiting for next command. Only a "ok" says that command buffer is free for next and with com errors it is possible to miss one and that is what the timeout is for.
So since you say you will not drop any line and always repspond with a proper ok I will just disable timeout for Klipper in the next update and hope it causes no problem we currently do not see.
I have actually made a simple keepalive module for Klipper.
I'm using it with Repetier-Server.
It's still in my local repo but you can specify the interval in seconds
and when Klipper is printing and busy processing gcode then it
will output busy: processing after an interval.
Is this issue related to the fact that Klipper stops reporting temperature to Octoprint during BED_TILT_CALIBRATE? I'm experiencing that, but don't want to rush for the new issue button.
The classic way to get temperatures is sending M105 from time to time. During a long command hosts can not send new commands and will not get new temperatures unless firmware does this on it's own, e.g. because it has autoreport temperature feature so no M105 is required or it reports temperatures on it's own like done normally during M109. I have no klipper printer so can not say what klipper supports here, but I guess it requires the M105 method so it will pause updating temperatures during these commands.
It appears that a work around has been found for this and it appears it is not necessary for Klipper to support the "gcode busy protocol". As such, I'm going to close this issue.
Thanks, -Kevin
Where can I find this workaround?
Upgrade Repetier-Server and select Klipper firmware. Timeout is there disabled to solve it.
I found this issue specifically because I am struggling with Octoprint killing a long-running command because there's no busy signal. Is is possible to reconsider this issue @KevinOConnor?