Since M310 cannot change the heaters, allowing M310 S0 (and changing
parameters) allows to recover a usb-controlled printer which has been
locked-out due to bad model settings.
Fix regression introduced in fc10ca3146.
Accept incoming serial commands without line numbers (assumed to be
injected by the host), but do not reset the last line count when doing
so.
cmdqueue will run commands when EOF is reached without returning to the
main loop, which is already incorrect.
However, since it needs to ensure the queue is empty, an st_synchronize
call can result in a re-entrant call to get_command, which will
reprocess EOF again. Even if we removed st_synchronize, another command
could be picked by an unsuspecting manage_inactivity() somewhere else.
Short-circuit EOF processing by closing the file early and checking for
the file state early in get_command.
This should fix#3549
Do not inhibit motion when Stopped is set.
We actually do need to move to move away the extruder from the bed, and
setting Stopped breaks it without adding any sort of security (M*
commands, such as M600 could still perform moves and still pass
through, while M104 would still set heaters).
During a hard error the internal queue is cleared (and sd file closed,
if any), so no new "unforeseen" command can be read.
Handle "Stopped" instead as a flag to inhibit serial processing and
automatically switch to "paused for user" state. While in this state
simply drop any input without incrementing the processed gcode line
number, behaving as-if the last command was still being processed.
This allows "Stopped" to correctly handle a printer-initiated paused
state and recover as expected by requesting a resend when resuming.
PR #2967 altered the way ``sdpos_atomic`` was set, causing issues in the
crashdetect/powerpanic recovery offset if the instruction being
recovered happens to contain a comment.
Previously ``sdpos`` was assumed to be a single byte prior to the last
read character. sdpos+1 would thus position the index to the next
instruction. With gcode-filtering in place, sdpos is left just before
the comment, while the actual read position is at the newline. This
causes to parser to resume in the middle of the comment.
Change the value returned by cardreader::get_sdpos() to always return
the last read position, as everybody expects (!!).
This avoids the +1, and correctly sets the resume position to the next
valid instruction without overhead.
This is an extension/optimization of PR #2956.
It uses the cached 512B block buffer to avoid heavy-weight read() in SdBaseFile.
Even though this principle allowed the AVR to skip ~600KB of data within ~5 seconds,
the impact on code base is huge, especially into well proven and long-term stable
parts like reading a file from the SD card.
The sole purpose of this PR is to show/verify the possibility of the AVR CPU
in relation to adding thumbnails into MK3 G-codes.
Moreover, this PR shall not be merged unless the missing/commented features
are restored - especially file seeking and M84 search.
PFW-1175
If there are large blocks of comments in the G-code,
the printer may get shot down by its own watchdog.
Watchdog is generally set to 4s and updated only
in manage_heaters (and some other spots in some specific cases).
So far, the code reading the file and feeding it into Marlin
cycles indefinitely until it finds valid G-code lines and fills up the
command queue.
If the block is large enough, the printer cannot read it completely
within those 4s.
A simple workaround - bail out after some consecutive empty/comment
lines to enable other parts of code do their job (especially
manage_heaters).
Tested on MK404, previous FW fails with 600KB of comment lines at the
beginning, this patch survives. The printer even draws some update
on its status screen before starting a real print.
Ensure card.printingHasFinished sees all the planned moves before
clearing sdprinting. To do that, we need to ensure all SD commands
exited the command queue.
Timing functions (millis, micros and delay) replaced in whole source, defined in Marlin.h.
This commit enables original implementation (SYSTEM_TIMER_2 undefined)
Verified with passed complete wizard process.
sketch/cmdqueue.cpp: In function 'bool cmdqueue_pop_front()':
sketch/cmdqueue.cpp:67:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (++ bufindr; bufindr < sizeof(cmdbuffer) && cmdbuffer[bufindr] == 0; ++ bufindr) ;
^
sketch/cmdqueue.cpp: In function 'bool cmdqueue_could_enqueue_back(int, bool)':
sketch/cmdqueue.cpp:170:63: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
endw + CMDBUFFER_RESERVE_FRONT <= sizeof(cmdbuffer) ||
^
sketch/cmdqueue.cpp:172:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
(endw <= sizeof(cmdbuffer) && CMDBUFFER_RESERVE_FRONT <= bufindr))
^
sketch/cmdqueue.cpp:196:63: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
endw + CMDBUFFER_RESERVE_FRONT <= sizeof(cmdbuffer) ||
^
sketch/cmdqueue.cpp:198:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
(endw <= sizeof(cmdbuffer) && CMDBUFFER_RESERVE_FRONT <= bufindr))
^
sketch/cmdqueue.cpp: In function 'void get_command()':
sketch/cmdqueue.cpp:380:10: warning: variable 'rx_buffer_full' set but not used [-Wunused-but-set-variable]
bool rx_buffer_full = false; //flag that serial rx buffer is full
^
sketch/cmdqueue.cpp: In function 'uint16_t cmdqueue_calc_sd_length()':
sketch/cmdqueue.cpp:697:54: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (++ _bufindr; _bufindr < sizeof(cmdbuffer) && cmdbuffer[_bufindr] == 0; ++ _bufindr) ;
^