aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
Commit message (Collapse)AuthorAgeFilesLines
* stepper: Query the stepper mcu position during startupKevin O'Connor2021-08-061-1/+1
| | | | | | | | Try to keep the host mcu_position synchronized with the micro-controller by querying during startup and after every homing event. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support returning the mcu reported shutdown timeKevin O'Connor2021-07-291-0/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Set reqclock on trsync_start commandsKevin O'Connor2021-07-091-2/+3
| | | | | | | | Set the reqclock on trsync commands to ensure those commands do not cause 32-bit timer rollover errors. Otherwise, it may result in "Timer too close" errors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Check for failures during multi-endstop homingKevin O'Connor2021-06-091-1/+3
| | | | | | If any endstop reports a failure, then stop homing on all endstops. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Enable trdispatch infrastructure during homingKevin O'Connor2021-06-091-66/+138
| | | | | | | | | Separate out trsync handling from endstop handling in mcu.py code. Enable the low-level trdispatch C code. This is in preparation for multi-mcu homing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* trsync: Introduce new "trigger synchronization" supportKevin O'Connor2021-06-091-30/+37
| | | | | | | Separate out the stepper stopping code from endstop.c into its own trsync.c code file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Raise config_error (not protocol error) on pin enumeration errorsKevin O'Connor2021-06-091-11/+20
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Support prepending a warn_prefix to error and log messagesKevin O'Connor2021-06-091-1/+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-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Report trigger time in endstop_query responseKevin O'Connor2021-04-301-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Remove min_stop_interval from mcu codeKevin O'Connor2021-04-301-1/+1
| | | | | | | Now that the host never uses a min_stop_interval, remove it from the mcu code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Update hints for "Timer too close" and "No next step" errorsKevin O'Connor2021-03-191-1/+6
| | | | | | | In practice, these errors are usually due to problems on the host computer instead of problems with communication. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add support for connecting to devices on a CAN busKevin O'Connor2021-03-131-6/+19
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Verify SPI register writesKevin O'Connor2021-03-101-4/+10
| | | | | | | | The tmc2130 (and tmc5160) will respond back with the value written during the next SPI command. Use this feature to verify that the value written matches the value sent. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Update callers to decide serial fd typeKevin O'Connor2021-03-021-17/+17
| | | | | | | | Don't try to detect a "real serial port" in serialhdl.py. Instead, have the callers invoke either connect_uart(), connect_file(), or connect_pipe(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Raise a command_error on a command timeout eventKevin O'Connor2021-02-271-4/+6
| | | | | | | | Raise a printer.command_error() instead of an mcu.error() if a query command does not succeed. That error is less likely to result in an unhandled exception error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* buildcommands: Extend number of available mcu messages from 96 to 128Kevin O'Connor2021-02-181-2/+2
| | | | | | | | | | | Some internal code treats the message ids as encoded "variable length quantities", while other internal code assumes the message id is always one byte long. Continue using this scheme, but convert the VLQ users to use the name "msgtag" while the 1-byte users use "msgid". Increase the number of available msgids from 96 to 127 - the higher values get encoded as negative "msgtags". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* msgproto: Avoid peeking into the msgproto class membersKevin O'Connor2021-02-181-7/+10
| | | | | | | Update callers to only use exported methods of the msgproto objects. This makes it easier to make internal changes to the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add a get_status() callback with micro-controller info and statsKevin O'Connor2021-01-191-6/+16
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* heaters: Always register heater pin as a pwm pinKevin O'Connor2020-12-151-2/+0
| | | | | | | There's no need to sometimes register the pin as a 'digital_out' pin instead of as a 'pwm' pin. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Merge digital output and soft pwm codeKevin O'Connor2020-12-101-6/+6
| | | | | | | | The digital output commands implement a subset of the software pwm commands. Change the host code to just use the software pwm commands and simplify the micro-controller code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Use move queue for software pwmKevin O'Connor2020-12-041-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Use move queue for digital output pinsPascal Pieper2020-12-041-4/+5
| | | | | Signed-off-by: Pascal Pieper <accounts@pascalpieper.de> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pwmcmds: Use move queue for hard PWMPascal Pieper2020-12-041-2/+3
| | | | | Signed-off-by: Pascal Pieper <accounts@pascalpieper.de> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support reserving move queue slotsPascal Pieper2020-12-041-1/+6
| | | | | Signed-off-by: Pascal Pieper <accounts@pascalpieper.de> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Send soft pwm cycle_time separately from schedule_soft_pwm_outKevin O'Connor2020-12-041-10/+17
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add support for setting reqclock in CommandQueryWrapper.send()Kevin O'Connor2020-10-291-4/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Don't default serial config option to /dev/ttyS0Kevin O'Connor2020-10-281-10/+10
| | | | | | | | If the mcu config section is omitted, it leads to confusing error messages. Don't default the serial config option to /dev/ttyS0 to improve the error reporting. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Increase the time to reset a pwm pin during startupKevin O'Connor2020-10-111-6/+3
| | | | | | | | Some RPi0 users were reporting "timer too close" errors due to pwm pin resets - increase the time the host has to complete the startup to avoid this. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Fix set_pwm() for hard pwmKevin O'Connor2020-09-271-11/+13
| | | | | | Must use self._pwm_max to calculate range for hard pwm updates. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add support for changing cycle_time in set_pwm()Kevin O'Connor2020-09-261-3/+5
| | | | | Signed-off-by: Guy Shapira <gayuha@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Add soft-pwm frequency modulation supportGuy Shapira2020-09-261-9/+16
| | | | | Signed-off-by: Guy Shapira <gayuha@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Setup for steppersync_free to be automatically calledKevin O'Connor2020-09-161-14/+14
| | | | | | Use ffi_main.gc() to automatically free the C steppersync object. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Don't define a __del__() methodKevin O'Connor2020-09-161-2/+0
| | | | | | | | The existence of a __del__() method prevents deallocation on python2 if there are circular references. Just remove the method as disconnect() should already be called directly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Use schedule_pwm_out instead of set_pwm_out on a restartKevin O'Connor2020-09-091-4/+7
| | | | | | | | Some mcu implementations don't like it when the pwm pin is configured twice, so use the normal schedule_pwm_out implementation to update on a restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Reset pwm and digital output pins to start values on a host restartKevin O'Connor2020-07-251-35/+43
| | | | | | | This makes sure output pins are reset to their defaults when the host is restarted and the micro-controller is not. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add support for commands to send only on a host restartKevin O'Connor2020-07-251-7/+12
| | | | | | | | Add a new "on_restart" parameter to mcu.add_config_cmd() and only send those commands on a host restart that does not involve a micro-controller restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Remove undocumented "custom" config parameterKevin O'Connor2020-07-191-13/+2
| | | | | | | The "custom" config parameter is not documented and has not been recommended in years. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Avoid using "async" for variables as it conflicts with Python3Kevin O'Connor2020-06-151-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial: Add Fysetc Cheetah board specific reset sequenceGrigori Goronzy2020-04-021-2/+14
| | | | | | | | | | | | | | | | | | Fysetc Cheetah v1.2 boards require a special sequence to reset reliably. This sequence works for me in all cases. Simpler sequences without double reset did not work correctly. This is likely because of a weird stateful circuitry for toggling the bootloader state. Cheetah boards use RTS to configure bootloader triggering. By default, pySerial sets RTS on connect, which unfortunately configures the board to start the bootloader on reset. Add a toggle for the RTS state to allow users to workaround. The RTS state is set before the serial connection is opened, so there are no glitches. Addresses #2026. Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
* mcu: Shutdown if a spontaneous restart of an mcu is observedKevin O'Connor2020-03-221-3/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Remove no longer used get_adjusted_freq() functionKevin O'Connor2020-03-061-2/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Calculate homing rest_ticks via standard print_time_to_clock() callKevin O'Connor2020-03-061-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Introduce new lookup_query_command() command wrapperKevin O'Connor2020-02-201-37/+51
| | | | | | | Use new mcu.lookup_query_command() for all commands that query information from the micro-controller. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Convert queries to use new notify message ack systemKevin O'Connor2020-02-201-5/+38
| | | | | | | | | | | Convert standard queries to use the acknowledgments of the sent command to determine if the response was received or not. This also controls command retransmissions (should the response have been lost). The tmc_uart.py will continue to use the old mechanism as the tmcuart responses are not sent synchronously with the query command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Don't raise a TimeoutError from home_wait()Kevin O'Connor2020-02-191-4/+1
| | | | | | | Change home_wait() to return if the homing operation completed succesfully or not. This simplifies the callers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Replace notify callback with a completionKevin O'Connor2020-02-191-9/+7
| | | | | | | | | Update the endstop code to return its trigger completion object during home_start(). Update the toolhead class to take a completion object (instead of creating its own). This reduces the number of intermediate callbacks needed during a homing operation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Merge home_prepare()/home_finalize() into move_begin/move_end eventsKevin O'Connor2020-02-151-4/+0
| | | | | | | | Collapse the "homing:move_begin", "homing:move_end", home_prepare(), and home_finalize() into two new events: "homing:homing_move_begin" and "homing:homing_move_end". This simplifies the homing code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Minor simplification to default reset detectionKevin O'Connor2019-11-121-5/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Move MCU_stepper from mcu.py to stepper.pyKevin O'Connor2019-11-121-133/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>