Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Stop Print" doesn't purge commands #3545

Closed
thinkyhead opened this issue Apr 18, 2016 · 10 comments
Closed

"Stop Print" doesn't purge commands #3545

thinkyhead opened this issue Apr 18, 2016 · 10 comments

Comments

@thinkyhead
Copy link
Member

When "Stop Print" is used to stop printing from SD, if the machine is waiting inside M109 or M104 apparently the next command in the command queue (or from the SD card) is executed. In my case, this sets the extruder temp to 195 (and waits) because the next command is M109 S195.

When stopping a print, anything left hanging around in the command queue should be purged and ignored, and no more commands should be read from SD.

  • Is this new behavior or an old problem?
  • Is there a preferred technique to purge the command queue for cases like this?
@jbrazio jbrazio added this to the 1.1.0 milestone May 7, 2016
@lavato
Copy link

lavato commented May 24, 2016

Not sure if this is the same problem - if I stop a print couple of times, eventually the new print offsets about 3cm towards the X0. (Y & Z are OK)

@thinkyhead
Copy link
Member Author

thinkyhead commented May 25, 2016

Hmm. It's possible for the current_position to be set with the anticipation that a move just added to the planner will definitely finish. But if moves are purged from the planner after that point, the current_position will no longer be properly synchronized to the planner position. Thus it is very important that after killing a print, if moves are purged from the planner, the current_position should be re-established from the current planner position (i.e., calculated from the current stepper-motor step counts).

@maukcc
Copy link
Contributor

maukcc commented May 31, 2016

As this code in ultralcd.ccp says:

static void lcd_sdcard_stop() {
    quickStop();
    card.sdprinting = false;
    card.closefile();
    autotempShutdown();
    cancel_heatup = true;
    lcd_setstatus(MSG_PRINT_ABORTED, true);
  }

it should stop heating and/or switch heaters off when actually printing
But it does not.
I rather like it as it lets me start a new print faster.
from a CE certification standpoint it is wrong and does not comply(hush,hush)

@Blue-Marlin
Copy link
Contributor

Blue-Marlin commented May 31, 2016

But it does not.

Indeed.

autotempShutdown(); //sets only the current exruder to 0. (#if AUTOTEMP)
cancel_heatup = true; // stops the _waiting_ for M109/M190 but does not set the target temperatures.

If we want to stop all heaters it needs a thermalManager.disable_all_heaters();

@Blue-Marlin
Copy link
Contributor

@thinkyhead

Is this new behavior or an old problem?

I don't know. But i think we never had a function/method to clean the command buffer.

Is there a preferred technique to purge the command queue for cases like this?

I'd suggest:

cmd_queue_index_r = 0;
cmd_queue_index_w = 0;
commands_in_queue = 0;

A bit less brutal, but slow:

while (commands_in_queue) {
    commands_in_queue--;
    cmd_queue_index_r = (cmd_queue_index_r + 1) % BUFSIZE;
}

Eventually it also needs to clear the serial_line_buffer[] in get_serial_commands().

@jbrazio
Copy link
Contributor

jbrazio commented May 31, 2016

If we speak about a circular buffer then the way to do it is to set head = tail.

@Blue-Marlin
Copy link
Contributor

Blue-Marlin commented May 31, 2016

@jbrazio
That's not enough here because commands_in_queue is not a function but a variable.
Setting head = tail or tail = head or head = 0; tail = 0 does not matter here, as long as they are the same afterwards.

@jbrazio
Copy link
Contributor

jbrazio commented May 31, 2016

@Blue-Marlin thanks for the heads up, then building upon your initial code we could have something like:

cmd_queue_index_r = cmd_queue_index_w;
commands_in_queue = 0;

@thinkyhead
Copy link
Member Author

thinkyhead commented Jun 1, 2016

#3939 adds clearing of the command buffer for lcd_sdprint_stop().

@jbrazio jbrazio closed this as completed Jun 11, 2016
@github-actions
Copy link

github-actions bot commented Apr 7, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants