Added a "fake ack" button to terminal tab, as counter measure for lost "ok"s
In case an ok gets lost on the line, this allows to have the communication between OctoPrint and the printer take up again.
This commit is contained in:
parent
4ea6bcd1de
commit
fb5aaffdc1
7 changed files with 64 additions and 2 deletions
|
|
@ -75,6 +75,12 @@ Issue a connection command
|
|||
disconnect
|
||||
Instructs OctoPrint to disconnect from the printer.
|
||||
|
||||
fake_ack
|
||||
Fakes an acknowledgement message for OctoPrint in case one got lost on the serial line and the communication
|
||||
with the printer since stalled. This should only be used in "emergencies" (e.g. to save prints), the reason
|
||||
for the lost acknowledgement should always be properly investigated and removed instead of depending on this
|
||||
"symptom solver".
|
||||
|
||||
**Example Connect Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
|
@ -114,7 +120,24 @@ Issue a connection command
|
|||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``connect`` or ``disconnect``
|
||||
**Example FakeAck Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/connection HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "fake_ack"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``connect``, ``disconnect`` or ``fake_ack``.
|
||||
:json string port: ``connect`` command: The port to connect to. If left out either the existing ``portPreference``
|
||||
will be used, or if that is not available OctoPrint will attempt auto detection. Must be part
|
||||
of the available ports.
|
||||
|
|
|
|||
|
|
@ -97,6 +97,14 @@ class PrinterInterface(object):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def fake_ack(self):
|
||||
"""
|
||||
Fakes an acknowledgement for the communication layer. If the communication between OctoPrint and the printer
|
||||
gets stuck due to lost "ok" responses from the server due to communication issues, this can be used to get
|
||||
things going again.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def commands(self, commands):
|
||||
"""
|
||||
Sends the provided ``commands`` to the printer.
|
||||
|
|
|
|||
|
|
@ -212,6 +212,12 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||
return self._comm.getTransport()
|
||||
getTransport = util.deprecated("getTransport has been renamed to get_transport", since="1.2.0-dev-590", includedoc="Replaced by :func:`get_transport`")
|
||||
|
||||
def fake_ack(self):
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
self._comm.fakeOk()
|
||||
|
||||
def commands(self, commands):
|
||||
"""
|
||||
Sends one or more gcode commands to the printer.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ def connectionState():
|
|||
def connectionCommand():
|
||||
valid_commands = {
|
||||
"connect": [],
|
||||
"disconnect": []
|
||||
"disconnect": [],
|
||||
"fake_ack": []
|
||||
}
|
||||
|
||||
command, data, response = get_json_command_from_request(request, valid_commands)
|
||||
|
|
@ -68,6 +69,8 @@ def connectionCommand():
|
|||
printer.connect(port=port, baudrate=baudrate, profile=printerProfile)
|
||||
elif command == "disconnect":
|
||||
printer.disconnect()
|
||||
elif command == "fake_ack":
|
||||
printer.fake_ack()
|
||||
|
||||
return NO_CONTENT
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,16 @@ $(function() {
|
|||
}
|
||||
};
|
||||
|
||||
self.fakeAck = function() {
|
||||
$.ajax({
|
||||
url: API_BASEURL + "connection",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({"command": "fake_ack"})
|
||||
});
|
||||
};
|
||||
|
||||
self.handleKeyDown = function(event) {
|
||||
var keyCode = event.keyCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,3 +20,12 @@
|
|||
<small class="muted">{{ _('Hint: Use the arrow up/down keys to recall commands sent previously') }}</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<button class="btn btn-block" type="button" data-bind="click: fakeAck, enable: isOperational() && loginState.isUser()">{{ _("Fake Acknowledgement") }}</button>
|
||||
<small class="muted">{{ _("If acknowledgements (\"ok\"s) sent by the firmware get lost due to issues with the serial communication to your printer, OctoPrint's communication with it can become stuck. If that happens, this can help. Please be advised that such occurences hint at general communication issues with your printer which will probably negatively influence your printing results and which you should therefore try to resolve!") }}</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -412,6 +412,9 @@ class MachineCom(object):
|
|||
def setTemperatureOffset(self, offsets):
|
||||
self._tempOffsets.update(offsets)
|
||||
|
||||
def fakeOk(self):
|
||||
self._clear_to_send.set()
|
||||
|
||||
def sendCommand(self, cmd, cmd_type=None, processed=False):
|
||||
cmd = cmd.encode('ascii', 'replace')
|
||||
if not processed:
|
||||
|
|
|
|||
Loading…
Reference in a new issue