Commit Graph

220 Commits

Author SHA1 Message Date
Kevin O'Connor f97fd7c6e3 gcode: Handle M117 and M118 commands that start with a special character
Commit 7ef7bf60 broke the special handling for M117 commands that
start with a number or special character.  Fix that support and extend
to M118 as well.

Also improve handling of commands not separated by a space (eg,
"M117HELLO").

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2022-01-18 11:34:40 -05:00
Alex Zellner 05a8aca0a8
gcode: Allow rename_existing also for register_mux_command (#4843)
Signed-off-by: Alex Zellner <alexander.zellner@googlemail.com>
2021-11-22 11:22:12 -05:00
Pedro Lamas 7ef7bf608a gcode_macro: Add "rawparams" pseudo-variable
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-11-19 11:22:36 -05:00
Kevin O'Connor d23c1b06c6 gcode: Fix Python3 syntax error
Fix error introduced in d6c3aaad.  Also, go back to only accepting
ascii characters on input.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-31 14:15:32 -04:00
Kevin O'Connor d6c3aaad8a gcode: Use regular str() types for g-code commands on Python2
Avoid using unicode() types on Python2 as it can lead to subtle
errors.

Also, accept utf8 on gcode input (instead of just ascii).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-31 13:51:52 -04:00
Kevin O'Connor adeb869f56 gcode: Convert to Python3 string encoding
The error checking is not complete in this change - the code should
handle the case where an input string is not valid utf8.

The code will continue to run on Python2 after this change, however
the execution time on Python2 is measurably slower after making this
change.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-01 21:00:03 -04:00
Stefan Dej b5e4f3d204
gcode: Update gcode descriptions (#4335)
Add help description to HELP
Add help description to RESPOND
Add help description to MEASURE_AXES_NOISE, TEST_RESONANCES and SHAPER_CALIBRATE
Add help description to PAUSE, RESUME, CLEAR_PAUSE and CANCEL_PRINT
Add help description to GET_POSITION
Add help description to SET_RETRACTION and GET_RETRACTION

Signed-off-by: Stefan Dej <meteyou@gmail.com>
2021-06-02 10:45:27 -04:00
Kevin O'Connor 0990a3da6f gcode: Generate M115 output even if command not sent from gcode pseudo-terminal
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-28 21:40:03 -04: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 6bba285f8e gcode: Don't log debugging output for unknown commands if command is blank
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-17 21:46:00 -04:00
Kevin O'Connor 6763210558 gcode: Fix out-of-order cmd_M112 reference
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-23 13:18:30 -04:00
Kevin O'Connor 1286d3006c gcode_move: Move GCodeMove class from gcode.py to new extras module
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor 4c5e93d51d gcode: Split G0/G1 command handling to new gcode_move class
Split up the main GCodeParser class into GCodeDispatch and GCodeMove
classes.  The GCodeMove class is now available using the "gcode_move"
printer object name.  This split simplifies the gcode.py code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor cd7c1b8e68 toolhead: Move G4 and M400 commands from gcode.py to toolhead.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor 80a6f59c8f gcode: Convert get_status() last_xpos to use a namedtuple
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor 2d5f9b6cda gcode: Remove unneeded base_xpos variables from get_status()
Convert the only user of base_zpos to use gcode_position.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor c0daf43d2f gcode: Convert get_status() homing_xpos to use a namedtuple
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor 39261d884d gcode: Remove unused move_xpos get_status() variables
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor b2c78d71b0 gcode: Remove "action_" commands from get_status() calls
Rename printer.gcode.action_emergency_stop() to
action_emergency_stop(), printer.gcode.action_respond_info() to
action_respond_info(), and printer.gcode.action_respond_error() to
action_raise_error() in command templates.

This simplifies the get_status() interface, as returning callable
functions from that interface was confusing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor 2caaaea9a4 toolhead: Add a manual_move() helper function
Add a helper function for submitting relative movements.  This
function will also automatically ensure gcode.reset_last_position() is
called.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -04:00
Kevin O'Connor 4115a77342 gcode: Automatically call reset_last_position() on a toolhead set_position()
Generate a "toolhead:set_position" event on a call to
toolhead.set_position() and use that event to automatically call
gcode.reset_last_position().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-20 21:03:22 -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 568393c941 webhooks: Remove "method" parameter from webhook requests
Don't require or use the "method" parameter of requests.  This
simplifies the interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:20:25 -04:00
Kevin O'Connor e5a3fd7cee gcode: Fix error causing _dump_debug() to fail
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-08 10:02:38 -04:00
Kevin O'Connor 447374f73e gcode: Separate IO handling to its own class
Move the pseudo-tty IO handling from the main gcode class to a new
gcode_io class.  This simplifies the main gcode class.

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
Kevin O'Connor b66dd1a60f gcode: Allow handlers to be registered for all gcode output
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 8ed1696624 gcode: Only write to the gcode pseudo-tty if it appears to be active
If there isn't a reader of the output pipe it can lead to the
generation of a large number of errors.  Only attempt to write if it
appears the pipe is active.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 1f7c3fc8ec gcode: Report the final print_time in debuginput mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-07-30 12:53:59 -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 72962c5ca2 gcode: add webhooks support
Register "gcode/script", "gcode/help", "gcode/restart", and "gcode/firmware_restart" endpoints.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-06-24 19:07:33 -04:00
Kevin O'Connor 1ab41cf41d gcode: Make it clear that gcode.get_status() can be called without eventtime
Make it clear that gcode.get_status() to be called without an
eventtime by defaulting eventtime=None.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-26 14:59:15 -04:00
Kevin O'Connor 2d4b520260 gcode: Move "ok" tracking to GCodeCommand class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-05 11:08:12 -04:00
Kevin O'Connor bf4bd5cfc1 gcode: Remove parsing helpers from main gcode class
Remove the parsing helpers from the main gcode class now that all
callers have been converted to use the parsing helpers in the
GCodeCommand class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-05 11:08:12 -04:00
Kevin O'Connor c79f135cd5 gcode: Use new GCodeCommand wrappers in command handlers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-05 11:08:11 -04:00
Kevin O'Connor ddb8311890 gcode: Create new wrapper class for gcode command parameters
Instead of passing a dictionary to the command handlers, create a
wrapper class and pass that class to the command handlers.  This can
simplify the command handler code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-05 11:08:11 -04:00
Kevin O'Connor 3aacc4d6a2 gcode: Only call position_with_transform() when printer is ready
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-02 07:35:23 -04:00
Kevin O'Connor d858498a53 heater: Move M105 command handling from gcode.py to heater.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-25 14:26:28 -04:00
Kevin O'Connor 64031ab3d7 gcode: Rename respond() to respond_raw()
Rename the method to make it more clear that it is a low-level call
that should be rarely used.

Also, change gcode_button.py, hall_filament_width_sensor.py, and
tsl1401cl_filament_width_sensor.py to use respond_info() instead of
respond_raw().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-24 15:54:18 -04:00
Kevin O'Connor 61524542d2 gcode: Don't export respond_error()
Don't export the respond_error() method as callers should raise a
gcode.error() instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-24 14:59:25 -04:00
Kevin O'Connor ed3e6b42c7 gcode: Raise a gcode.error() from G20 command
It's important to raise an error (instead of calling respond_error() )
so that a G20 will stop a virtual_sdcard print.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-24 14:53:41 -04:00
Kevin O'Connor 402110f655 gcode_arcs: Fix Z moves and E moves
Fix Z moves so that the movement is spaced out among the arc movements.

Fix extrude moves when in absolute extrude mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-22 16:30:02 -04:00
Kevin O'Connor 5bca4e6fa1 gcode: Add a "command_error" event notifier
Allow other modules to be notified if there is a gcode command error
detected.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-15 17:52:44 -05:00
Kevin O'Connor 0cfab84e1a gcode: Return previous handler from register_command(cmd, None)
When overriding a g-code command, allow the caller to obtain the
previous command handler.  Use this feature in homing_override and
safe_z_home.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-12 20:19:18 -05:00
Kevin O'Connor 005cfea5c3 gcode: Fix detection of some "extended" g-code commands
Fix typo that resulted in _get_extended_params() being called for all
commands.  Allow "extended" g-code commands to contain numbers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-07 19:17:20 -05:00
Kevin O'Connor f4c4de1a24 extruder: Move M104/M140 commands from gcode.py to extruder.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-12-16 20:16:21 -05:00
Kevin O'Connor 9654816abf heater_bed: Move M140/M190 commands from gcode.py to heater_bed.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-12-16 20:02:48 -05:00
Kevin O'Connor 0e2d1a190e gcode: Rename bg_temp() to wait_for_temperature()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-12-16 19:21:37 -05:00
Kevin O'Connor 665323eb29 heater: Use printer.command_error() instead of internal heater.error()
Use the more standard command_error to report invalid temperature
requests.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-12-16 19:16:58 -05:00