Commit Graph

131 Commits

Author SHA1 Message Date
Felicia Hummel b18786bc91
klippy: Reworked the MCU protocol error message (#5470)
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>
2022-05-06 20:51:34 -04:00
Kevin O'Connor 41d42a07bf klippy: Add a build import test tool
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>
2021-10-04 14:36:08 -04:00
Kevin O'Connor acdad76408 klippy: Add a newline between initial error message and hint text
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-10 21:30:09 -04:00
Kevin O'Connor 89082b494f klippy: Report known software versions on a protocol error during connection
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-05-02 17:51:15 -04:00
Kevin O'Connor 1950380d6c klippy: Fix check for duplicate objects
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-05 13:59:20 -05:00
Kevin O'Connor ea85d419de gcode: Move definition of CommandError and Coord from homing.py to gcode.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-08 12:07:45 -05:00
Kevin O'Connor 19b2363c93 klippy: Remove import of unused threading module
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-30 13:02:44 -04:00
Kevin O'Connor 1af4a4ae9f reactor: Record time of recent gc collection sweeps
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-17 02:06:20 -04:00
Kevin O'Connor cb0a8f2ed9 reactor: Add support for explicit Python garbage collection
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>
2020-09-16 23:53:45 -04:00
Kevin O'Connor 73cd8c241c klippy: Call gc.collect() on a "restart" request
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>
2020-09-16 23:53:45 -04:00
Kevin O'Connor 760a0f8df5 reactor: Add explicit finalize() method to clean up reactor state
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>
2020-09-16 23:53:45 -04:00
Kevin O'Connor c285f8b6cf klippy: Improve handling of reactor.run() exceptions
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>
2020-09-06 12:45:27 -04:00
Kevin O'Connor 9d9e5c7edc klippy: Report "shutdown" category from get_state_message()
Reported by @Arksine.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 14:10:54 -04:00
Kevin O'Connor 16a53e6918 webhooks: Require a subscription to receive gcode output
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>
2020-08-16 13:20:26 -04:00
Kevin O'Connor 0aad2437c5 webhooks: Specify server_address on klippy command-line
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>
2020-08-16 13:20:25 -04:00
Kevin O'Connor 4346d37c06 webhooks: Introduce add_early_printer_objects()
Create the initial gcode class via new module level
add_early_printer_objects() function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 8c8b9b1812 gcode: Introduce add_early_printer_objects()
Create the initial gcode class via new module level
add_early_printer_objects() function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 0d930bf871 gcode: Pass the pseudo-tty fd via the start_args system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Arksine 014c06f8a2 klippy: return message category in get_state_message()
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-06-24 19:07:33 -04:00
Arksine 14ac453861 klippy: Instantiate the webhooks module
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>
2020-06-24 19:07:33 -04:00
Kevin O'Connor 787ed452c2 klippy: Rename try_load_module() to load_object()
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>
2020-05-08 11:05:14 -04:00
Kevin O'Connor 8472c57b59 klippy: Minor code movement
Move set_rollover_info() - no code changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-08 11:05:14 -04:00
Kevin O'Connor 17123889f6 heaters: Make heater.py an "extras" module
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>
2020-04-25 14:26:45 -04:00
Kevin O'Connor 44f868a802 klippy: Add an is_shutdown() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-25 12:41:44 -04:00
Kevin O'Connor 48237435b2 klippy: Log shutdown state in invoke_shutdown()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-24 08:37:36 -04:00
Kevin O'Connor f3667fd453 util: Try to dump mcu build information on a connection error
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-22 13:22:52 -04:00
Kevin O'Connor 5eb5841eaf mcu: Contact and identify all the mcus prior to configuring them
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>
2019-11-06 10:35:24 -05:00
Kevin O'Connor 296ab7d402 klippy: Warn if starting klippy with logging disabled
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-01 18:09:20 -04:00
Kevin O'Connor 505e96b7ed klippy: Only set the run_result if it hasn't already been set
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-28 10:21:50 -04:00
Kevin O'Connor cacb6f4378 klippy: Provide global access to a printer.command_error exception class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-06 10:22:14 -04:00
Kevin O'Connor 516fbf4f32 klippy: Report the underlying error on an internal error during connect
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-04-04 18:38:46 -04:00
Kevin O'Connor 9be6cf226b klippy: Wrap code to 80 columns
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-27 13:18:43 -05:00
Kevin O'Connor f0b7d6d67a klippy: Report the first error generated
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>
2019-01-11 12:41:55 -05:00
Kevin O'Connor c0ea0312e5 klippy: Fix error handling during connect phase
Make sure to exit the _connect() method if a connect event handler
raises an error.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-08 13:46:26 -05:00
Kevin O'Connor 857e7ed5f1 klippy: Convert printer_state("connect") to an event handler
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>
2019-01-08 11:09:55 -05:00
Kevin O'Connor 797367b9f5 klippy: Convert printer_state("ready") to an event handler
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>
2019-01-08 10:59:43 -05:00
Kevin O'Connor fb7fe282c8 klippy: Convert printer_state("shutdown") to an event handler
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>
2019-01-08 10:59:43 -05:00
Kevin O'Connor 2549ccd722 klippy: No need to return anything from _connect() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-10-18 15:58:52 -04:00
Kevin O'Connor 216905ceca klippy: Add a basic event dispatch mechanism
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-10-16 13:09:23 -04:00
Kevin O'Connor f80456a698 configfile: Move config file code from klippy.py to new file
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>
2018-09-25 13:48:46 -04:00
Kevin O'Connor 094b9de69e gcode: Send proactive state messages
Send a g-code info message on printer state changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-12 21:31:27 -04:00
Kevin O'Connor d1da6100a6 klippy: Remove unneeded loop in run() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-12 21:06:54 -04:00
Kevin O'Connor ef6068dc42 mcu: Log MCU information before configuring
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>
2018-09-03 18:34:10 -04:00
Kevin O'Connor 8fe8a6deb3 statistics: Move stats handling to new "extras" module
Move the generation of statistics to its own module.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-02 13:46:19 -04:00
Kevin O'Connor 18b04ffe68 klippy: Rename lookup_module_objects() to lookup_objects()
Rename the method and support returning all known objects.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-02 12:53:34 -04:00
Kevin O'Connor 50196c7141 klippy: Use reactor register_callback() mechanism
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-02 12:43:40 -04:00
Kevin O'Connor 7783767c35 klippy: Move tracking of accessed config items into _read_config() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-08-03 18:54:23 -04:00
Kevin O'Connor 8faab46ed2 toolhead: Move kinematic modules to new kinematics/ directory
Move extruder.py, cartesian.py, corexy.py, and delta.py to a new
kinematics/ sub-directory.  This is intended to make adding new
kinematics a little easier.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-12 22:50:25 -04:00
Kevin O'Connor 7d897d84d7 klippy: No need to pass printer reference to add_printer_objects()
The config reference already stores a reference to the printer object.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-12 22:26:32 -04:00
Kevin O'Connor 2622b439fc klippy: Allow extras modules to be directories
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-27 13:01:48 -04:00