aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/klippy.py
Commit message (Collapse)AuthorAgeFilesLines
* mcu: Delay reset signaling for usb to canbus bridge nodesKevin O'Connor2022-07-291-2/+1
| | | | | | | | An mcu device acting as an "mcu bridge" should only be reset after other normal devices are reset - otherwise the bridge wont be able to pass along the reset message to the downstream mcus. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: properly set log level when logging to stderrKamil Trzciński2022-06-271-1/+1
| | | | | | | | | | The `logging.basicConfig` does not reconfigure default logger. This results in printing only warnings/errors to stderr instead of also info (or debug). This fixes the issue by setting log level on root logger. Signed-off-by: Kamil Trzciński <ayufan@ayufan.eu>
* klippy: Minor changes to message protocol errorKevin O'Connor2022-05-061-33/+18
| | | | | | | | Minor indentation and variable name changes. Don't remove linebreaks from message_protocol_error lines. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Reworked the MCU protocol error message (#5470)Felicia Hummel2022-05-061-18/+49
| | | | | | | | | | | | The MCU protocol error message often confuses users, especially after getting bombarded with the config format error line. This PR tries to improve it and has the following goals: - Put the technical error at the end to prevent confusion and avoid the immediate jump to help channels instead of continuing to read - Inform the user first what the type of error is (In this case: MCU Protocol error) and not at the end of the long error message - Give the users a clear instruction what to do (pretty much unchanged), but possibly more approachable because the user is not confused by the technical error anymore - Shows the version numbers of Klipper separate from all MCU version numbers so that it is more obvious that this is the version of Klipper - Separates the version numbers between outdated MCUs and up-to-date MCUs, so that it becomes obvious if a MCU flash failed because the MCU doesn't disappear from the outdated list - Previously, when viewing the errors in a web frontend, additional line breaks made it extremely hard to read the message, sometimes with as little as one word on one line. The error messages are now formatted to not have rogue line breaks, improving readability. Signed-off-by: Felicia Alexa Hummel <felicia@drachenkatze.org>
* klippy: Add a build import test toolKevin O'Connor2021-10-041-0/+19
| | | | | | | | Add a test case to verify that every optional module successfully loads on both Python2 and Python3. This is intended to catch syntax and module imports that are not compatible between Python versions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Add a newline between initial error message and hint textKevin O'Connor2021-06-101-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Report known software versions on a protocol error during connectionKevin O'Connor2021-05-021-2/+15
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Fix check for duplicate objectsKevin O'Connor2021-03-051-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Move definition of CommandError and Coord from homing.py to gcode.pyKevin O'Connor2021-01-081-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Remove import of unused threading moduleKevin O'Connor2020-10-301-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* reactor: Record time of recent gc collection sweepsKevin O'Connor2020-09-171-4/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* reactor: Add support for explicit Python garbage collectionKevin O'Connor2020-09-161-1/+2
| | | | | | | Add support for performing Python gc work only from the main reactor thread and only when it appears the main thread is idle. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Call gc.collect() on a "restart" requestKevin O'Connor2020-09-161-2/+4
| | | | | | | Explicitly run the python garbage collector on a restart. This cleans up memory from the previous session. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* reactor: Add explicit finalize() method to clean up reactor stateKevin O'Connor2020-09-161-3/+5
| | | | | | | | | The existence of a __del__() method prevents deallocation on python2 if there are circular references. Replace the __del__() method with a new finalize() call and arrange for it to be called when the main reactor is released. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Improve handling of reactor.run() exceptionsKevin O'Connor2020-09-061-2/+11
| | | | | | | Try to invoke a shutdown on an unhandled exception from reactor.run(). If that fails, try to do a clean exit. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Report "shutdown" category from get_state_message()Kevin O'Connor2020-08-161-0/+2
| | | | | | Reported by @Arksine. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Require a subscription to receive gcode outputKevin O'Connor2020-08-161-1/+1
| | | | | | | | | | | Add a new "gcode/subscribe_output" webhook endpoint to subscribe to gcode output. Only client connections that subscribe to the gcode output will receive that output. This also moves all the gcode webhooks from gcode.py to webhooks.py and arranges for gcode.py to be initialized prior to webhooks.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Specify server_address on klippy command-lineKevin O'Connor2020-08-161-1/+4
| | | | | | | | Don't default to "/tmp/klippy_uds" for the webhooks unix domain socket filename. Instead, require the filename to be specified on the command-line (via a new "-a" parameter). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* webhooks: Introduce add_early_printer_objects()Kevin O'Connor2020-08-061-2/+3
| | | | | | | Create the initial gcode class via new module level add_early_printer_objects() function. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Introduce add_early_printer_objects()Kevin O'Connor2020-08-061-1/+1
| | | | | | | Create the initial gcode class via new module level add_early_printer_objects() function. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Pass the pseudo-tty fd via the start_args systemKevin O'Connor2020-08-061-7/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: return message category in get_state_message()Arksine2020-06-241-1/+7
| | | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* klippy: Instantiate the webhooks moduleArksine2020-06-241-4/+7
| | | | | | Add 'cpu_info' to start_args so it may be reported via the "info" endpoint in webhooks.py. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* klippy: Rename try_load_module() to load_object()Kevin O'Connor2020-05-081-6/+11
| | | | | | | | Rename try_load_module() so that it uses consistent naming for "printer objects". Change the function to raise an error by default if the specified module does not exist. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Minor code movementKevin O'Connor2020-05-081-5/+5
| | | | | | Move set_rollover_info() - no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* heaters: Make heater.py an "extras" moduleKevin O'Connor2020-04-251-2/+2
| | | | | | | The heater logic is an independent module that does not need to be treated as part of the "core" klipper code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Add an is_shutdown() methodKevin O'Connor2020-04-251-3/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Log shutdown state in invoke_shutdown()Kevin O'Connor2020-03-241-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* util: Try to dump mcu build information on a connection errorKevin O'Connor2020-03-221-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Contact and identify all the mcus prior to configuring themKevin O'Connor2019-11-061-0/+1
| | | | | | | | | | | Break up the connect phase into two phases - mcu_identify and connect. The first phase will contact all the micro-controllers and obtain the "identify" data dictionaries for them. Once all the micro-controllers have been contacted, then they can be configured. This fixes an issue with FIRMWARE_RESTART not working correctly on multi-mcu setups that use restart_method=command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Warn if starting klippy with logging disabledKevin O'Connor2019-09-011-0/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Only set the run_result if it hasn't already been setKevin O'Connor2019-06-281-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Provide global access to a printer.command_error exception classKevin O'Connor2019-06-061-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Report the underlying error on an internal error during connectKevin O'Connor2019-04-041-5/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Wrap code to 80 columnsKevin O'Connor2019-02-271-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Report the first error generatedKevin O'Connor2019-01-111-1/+2
| | | | | | | | Only update the status message with the first error report. Subsequent errors are often the result of the first error and reporting the last error can be misleading. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Fix error handling during connect phaseKevin O'Connor2019-01-081-0/+4
| | | | | | | Make sure to exit the _connect() method if a connect event handler raises an error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Convert printer_state("connect") to an event handlerKevin O'Connor2019-01-081-6/+2
| | | | | | | Convert all users of the printer_state("connect") handler to register a "klippy:connect" event handler instead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Convert printer_state("ready") to an event handlerKevin O'Connor2019-01-081-7/+10
| | | | | | | Convert all users of the printer_state("ready") handler to register a "klippy:ready" event handler instead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Convert printer_state("shutdown") to an event handlerKevin O'Connor2019-01-081-5/+8
| | | | | | | Convert all users of the printer_state("shutdown") handler to register a "klippy:shutdown" event handler instead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: No need to return anything from _connect() methodKevin O'Connor2018-10-181-3/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Add a basic event dispatch mechanismKevin O'Connor2018-10-161-0/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Move config file code from klippy.py to new fileKevin O'Connor2018-09-251-110/+11
| | | | | | | Add a klippy/configfile.py file with the code needed to read the main printer config file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Send proactive state messagesKevin O'Connor2018-09-121-1/+1
| | | | | | Send a g-code info message on printer state changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Remove unneeded loop in run() methodKevin O'Connor2018-09-121-18/+17
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Log MCU information before configuringKevin O'Connor2018-09-031-2/+3
| | | | | | | | Log the details of the MCU prior to attempting to configure the MCU. This way, the log contains the MCU information even if a configuration error occurs. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* statistics: Move stats handling to new "extras" moduleKevin O'Connor2018-09-021-14/+1
| | | | | | Move the generation of statistics to its own module. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Rename lookup_module_objects() to lookup_objects()Kevin O'Connor2018-09-021-6/+9
| | | | | | Rename the method and support returning all known objects. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Use reactor register_callback() mechanismKevin O'Connor2018-09-021-9/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Move tracking of accessed config items into _read_config() methodKevin O'Connor2018-08-031-8/+9
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>