aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/gcode.py
Commit message (Collapse)AuthorAgeFilesLines
* gcode: Don't wait for moves to finish if both debug input and outputKevin O'Connor2017-07-231-1/+2
| | | | | | Don't wait for moves to finish if the output is going to a debug file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Improve end-of-file handling when input is a debug fileKevin O'Connor2017-07-211-7/+10
| | | | | | | | | Wait for any pending moves to be fully handled before exiting. Make sure the wait is done inside the "self.is_processing_data" check to avoid infinite recursion. Don't keep reading from the file while waiting to exit. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Log g-code error responsesKevin O'Connor2017-07-171-2/+3
| | | | | | Be sure to log g-code errors even if debug logging is not enabled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Fix regression causing lost asynchronous commandsKevin O'Connor2017-06-111-1/+2
| | | | | | | | Commit d0932009 introduced an error that could cause lost input in cases where the sender did not wait for an "ok" message before sending the next command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Remove some obscure python2 dependenciesKevin O'Connor2017-06-101-1/+1
| | | | | | | Don't modify dictionaries while iterating them and be careful to use // when doing an integer divide. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Use newer "except XYZError as e" python syntaxKevin O'Connor2017-06-101-7/+7
| | | | | | Use the newer syntax for python exceptions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Support running arbitrary gcode on extruder changeKevin O'Connor2017-06-091-9/+14
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Support for querying and setting multiple extruder heatersKevin O'Connor2017-06-091-24/+33
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Add initial support for multi-extrudersKevin O'Connor2017-06-091-4/+28
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Prefer python dictionary comprehension to dict() callKevin O'Connor2017-06-061-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Check for invalid speedsKevin O'Connor2017-05-021-1/+4
| | | | | | Raise an error if the move speed is set to a zero or negative value. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Don't report an error if turning off an unknown fan or heaterKevin O'Connor2017-05-011-3/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Sort the order of commands in HELPKevin O'Connor2017-04-261-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Limit build_handlers() method to just building available commandsKevin O'Connor2017-04-261-34/+40
| | | | | | | | | | The set_printer_ready() can be called from a background thread on a shutdown event, so don't try to lookup the printer components in that case. Simplify build_handlers() so that it no longer tests for components being available - test for component availability in the command handlers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Ignore M21 commandKevin O'Connor2017-04-201-10/+8
| | | | | | | No need to recommend users disable "SD card support" in octoprint - instead, just ignore the M21 command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Remove CLEAR_SHUTDOWN commandKevin O'Connor2017-04-131-9/+1
| | | | | | | | Advice users to issue a FIRMWARE_RESTART command on a printer shutdown event, and remove support for CLEAR_SHUTDOWN. A full mcu reset is preferable and it simplifies the interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Catch common gcode parameter errorsKevin O'Connor2017-03-161-28/+58
| | | | | | | | Don't force a firmware shutdown on a simple gcode parse error. Instead, report the error back to the user and otherwise ignore the command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Eliminate build_config() methodKevin O'Connor2017-03-131-3/+4
| | | | | | Lookup the printer components during the set_printer_ready() callback. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Support FIRMWARE_RESTART commandKevin O'Connor2017-03-081-9/+16
| | | | | | | | Add initial support for micro-controller resets via the Arduino reset mechanism. Also, automatically attempt a firmware restart if the printer CRC does not match. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* heater: Enforce min/max_temp in heater.set_temp()Kevin O'Connor2017-02-211-1/+5
| | | | | | | Raise an error if the user requests a temperate outside the configured min/max_temp range. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Attempt to shutdown heaters and fans prior to a RESTARTKevin O'Connor2017-02-121-5/+14
| | | | | | | | | If the user requests a restart and the machine appears to be otherwise functioning normally, then attempt to stop the heaters and fans prior to restarting the host. This prevents the firmware from going into a shutdown state when the heater is on and the host restarts. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Separate motor off timer from main flush timerKevin O'Connor2017-02-121-1/+1
| | | | | | | Move the motor off time checking to its own code. This simplifies the main flush handler. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* reactor: Use the system monotonic clock instead of the normal system clockKevin O'Connor2017-02-061-2/+2
| | | | | | | | | | | | | The normal system clock can have sudden jumps if the system clock is changed. Use the system monotonic clock to avoid these sudden changes in time. It appears the Raspbian OS (which is used by OctoPi) is setup to update the system clock upon network connectivity. This could cause sudden system clock changes which could lead to Klippy processing errors. Using the monotonic clock eliminates these issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Exit on an unhandled exception when reading from a fileKevin O'Connor2017-02-061-0/+3
| | | | | | | When testing via a gcode input file, it's easier to debug problems if the program exits upon the first exception. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add support for M115 commandKevin O'Connor2016-12-281-1/+7
| | | | | | Support querying the firmware type and version. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add support for M400 commandKevin O'Connor2016-12-281-1/+5
| | | | | | Add ability to fully stall the input until all moves are complete. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add a "STATUS" commandKevin O'Connor2016-12-211-6/+21
| | | | | | Add a status command that will report the current printer status. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Increase initial speedKevin O'Connor2016-12-091-1/+1
| | | | | | | | | If a speed is never specified then default to 25mm/s (up from 1 mm/s). If a user accidentally issues a move without setting the speed, the default speed shouldn't be so slow that it takes minutes to finish the move. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Handle M112 emergency stop commandKevin O'Connor2016-12-091-11/+16
| | | | | | Also try to support the command if it is sent out of order. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rework toolhead stalling to use greenletsKevin O'Connor2016-12-091-27/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rework homing to use greenletsKevin O'Connor2016-12-091-8/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rework endstop query to use greenletsKevin O'Connor2016-12-091-4/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Convert wait for temp to use greenletsKevin O'Connor2016-12-081-12/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Convert busy handler from timer to greenletKevin O'Connor2016-12-081-25/+22
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add support for CLEAR_SHUTDOWN commandKevin O'Connor2016-12-011-1/+9
| | | | | | Add ability to clear the MCU shutdown flag from the console. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Add ability to restart the host softwareKevin O'Connor2016-11-301-7/+9
| | | | | | | Add a "restart" gcode command that will cause the host "klippy" software to reload its config and restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Support parsing of "extended" gcode commandsKevin O'Connor2016-11-301-24/+38
| | | | | | | | | | Support human readable commands (eg, "help"). Add a "help" command to list these extended commands. Also, add support for declaring command aliases, command help, and command availability next to the handlers themselves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Detect if the communication channel to the firmware is lostKevin O'Connor2016-11-301-0/+7
| | | | | | Detect a comms loss and report it to the user. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Don't dump the message log directly from set_printer_ready()Kevin O'Connor2016-11-301-6/+5
| | | | | | | | The set_printer_ready() method can be called from a background thread. Have the main Printer class call a new dump_debug() method in the main thread on a shutdown event. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Improve error reporting during connectKevin O'Connor2016-11-301-6/+11
| | | | | | | Catch exceptions during the connect phase and report them via the gcode interface to the user. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Support reading from gcode input before mcu is readyKevin O'Connor2016-11-301-19/+30
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Create the /tmp/printer pseudo tty before opening config fileKevin O'Connor2016-11-301-8/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Run the MCU connect code within the reactorKevin O'Connor2016-11-291-1/+0
| | | | | | | | Setup the reactor and run the MCU connection code as a timer within the reactor. The connection code will make use of reactor greenlets so that it can wait for events during the connection phase. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Handle adc initialization entirely in mcu codeKevin O'Connor2016-11-291-4/+0
| | | | | | | | Don't expose the ADC initialization to the gcode and heater code - instead, register a callback within the MCU_adc class and call it directly from the MCU class after configuration completes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Check homing distance to verify endstop trigger after retractKevin O'Connor2016-11-281-0/+2
| | | | | | | | | Instead of checking the endstop trigger directly after a retract move, verify some distance is traveled during the following homing operation. This reduces the amount of synchronization between mcu and host during homing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Check for timeout during homing operationKevin O'Connor2016-11-181-0/+3
| | | | | | | | Should a homing move complete without hitting the endstop, then disable motors, disable the endstop checking, and report the error to the user. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Create Homing class from gcodeKevin O'Connor2016-11-181-5/+6
| | | | | | | | Create the Homing class in the gcode handler instead of in the kinematic classes. This will make it easier to pass error messages back to the user. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Create QueryEndstops class from gcodeKevin O'Connor2016-11-181-10/+4
| | | | | | | | | | | Create the QueryEndstops in the gcode handler instead of in the kinematic classes. This simplifies the gcode handler as it can directly register its response callback. Also, store the stepper name in the stepper class. Also, propagate the print_time of the query request to the mcu_endstop class. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Reset current position after an endstop errorKevin O'Connor2016-10-111-0/+1
| | | | | | | If the printer is commanded to an invalid location, reset the current position to the last successfully commanded position. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* cartesian: Enforce endstop min and max boundariesKevin O'Connor2016-09-301-1/+5
| | | | | | | Verify that each move command is within range of the configured minimum and maximum for each axis. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>