aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
Commit message (Collapse)AuthorAgeFilesLines
* mcu: Add send_wait_ack() support to CommandWrapperKevin O'Connor2024-01-191-0/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Increase trsync_state reporting during multi-mcu homingKevin O'Connor2024-01-161-2/+2
| | | | | | | | | | | | | | | The current code has the mcu report a trsync_state message every 10ms and expects a time extension within 25ms. However, this means that if a single mcu->host report is lost then 20ms would elapse until the next report, which would allow for only a 5ms round-trip time before a timeout error is reported. Increase the trsync_state timing so that a message is sent every 7.5ms. This increases the total number of messages per second sent from mcu to host to 133 (from 100). With this change, a single lost message would still allow for up to a 10ms round-trip time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Stagger trsync reporting time during multi-mcu homingKevin O'Connor2024-01-161-5/+10
| | | | | | | | | | When multiple MCUs are involved in homing, stagger the scheduling of the trsync_state report messages from each mcu. Staggering helps spread the bandwidth, helps reduce locking contention in the host, and reduces the chance that intermittent latency could result in a communication timeout. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Keep stepcompress move history relative to current time (#6439)Francois Chagnon2023-12-301-2/+5
| | | | | Expire history relative to current time rather than last move in history queue Signed-off-by: Francois Chagnon <fc@francoischagnon.net>
* mcu: Add support for registering callbacks during move queue flushKevin O'Connor2023-12-161-11/+17
| | | | | | | Support notification callbacks each time the mcu move queue is flushed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Enhance RetryAsyncCommand to handle low-level retransmitsKevin O'Connor2023-09-211-2/+4
| | | | | | | | | | | | | | | | | | | | | The RetryAsyncCommand code needs to ensure that any response messages are not from a previous (unrelated) query. To do that it compares the '#sent_time' from potential responses to ensure they are not from a previous session. However, if there are any low-level serial retransmits then the low-level code sets the '#sent_time' to zero (to indicate that the query send time is not strictly known). That could result in a valid response not being accepted by RetryAsyncCommand. If a low-level connection is experiencing a small amount of periodic retransmits it could result in multiple high-level retry attempts failing to the point that there is a user-facing error. This could result in "Timeout on wait for 'tmcuart_response' response" errors. Fix by accepting responses even if there is a low-level retransmit once the code can confirm that there can be no previous query still in progress. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Move lookup_command_tag() to CommandWrapper classKevin O'Connor2023-02-221-8/+11
| | | | | | | | Use mcu.lookup_command().get_command_tag() instead of mcu.lookup_command_tag(). This improves error reporting on a protocol mismatch. It also enables support for a msgtag that is negative. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Code movement in mcu.pyKevin O'Connor2023-02-221-73/+88
| | | | | | This is code movement and comment updates only - no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Add a get_serialqueue() methodKevin O'Connor2023-01-061-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Delay reset signaling for usb to canbus bridge nodesKevin O'Connor2022-07-291-2/+13
| | | | | | | | 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>
* mcu: Add checks to ensure pin max_duration doesn't overflow 32bit counterKevin O'Connor2021-11-221-7/+15
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Verify start value equal to shutdown value when using max durationKevin O'Connor2021-11-221-0/+6
| | | | | | | The mcu can only enforce the max duration if the start value is the same as the shutdown value, so verify that before configuing the mcu. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Make a minor change to the protocol to require mcu updateKevin O'Connor2021-11-061-1/+1
| | | | | | | | Commit 9ecddd1b fixed a serious error (introduced in 7d95a004). Force a protocol version change so users are aware of the need to update the mcu code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Remove support for deprecated pin_map optionKevin O'Connor2021-11-021-4/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Convert to Python3 string encodingKevin O'Connor2021-10-011-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Add support for reporting deprecated optionsKevin O'Connor2021-09-161-0/+1
| | | | | | | Add a new printer.configfile.warnings with a list of config features that are deprecated. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support multi-mcu homingKevin O'Connor2021-08-281-12/+31
| | | | | | | Support endstops and probes attached to a different micro-controller than their associated steppers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Return time of trigger from home_wait()Kevin O'Connor2021-08-171-1/+11
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* 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>