Commit Graph

258 Commits

Author SHA1 Message Date
Kevin O'Connor 751bff7d38 mcu: Delay reset signaling for usb to canbus bridge nodes
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>
2022-07-29 11:40:54 -04:00
Kevin O'Connor faea45e60f mcu: Add checks to ensure pin max_duration doesn't overflow 32bit counter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-22 10:11:09 -05:00
Kevin O'Connor d1e13b7e12 mcu: Verify start value equal to shutdown value when using max duration
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>
2021-11-22 10:08:56 -05:00
Kevin O'Connor d4aee4f55e mcu: Make a minor change to the protocol to require mcu update
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>
2021-11-06 18:47:44 -04:00
Kevin O'Connor 0382ffbf68 pins: Remove support for deprecated pin_map option
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-11-02 12:45:11 -04:00
Kevin O'Connor 2978771ce5 mcu: Convert to Python3 string encoding
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-01 19:22:13 -04:00
Kevin O'Connor 46167cae67 configfile: Add support for reporting deprecated options
Add a new printer.configfile.warnings with a list of config features
that are deprecated.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-09-16 13:44:54 -04:00
Kevin O'Connor 950477849d mcu: Support multi-mcu homing
Support endstops and probes attached to a different micro-controller
than their associated steppers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-28 16:08:57 -04:00
Kevin O'Connor 1dc2ab048f mcu: Return time of trigger from home_wait()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-17 22:01:23 -04:00
Kevin O'Connor 24586f0c31 stepper: Query the stepper mcu position during startup
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>
2021-08-06 13:12:49 -04:00
Kevin O'Connor c632b377ca mcu: Support returning the mcu reported shutdown time
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor f24210054a mcu: Set reqclock on trsync_start commands
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>
2021-07-09 14:34:38 -04:00
Kevin O'Connor bc29ee1c6d homing: Check for failures during multi-endstop homing
If any endstop reports a failure, then stop homing on all endstops.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 983951443c mcu: Enable trdispatch infrastructure during homing
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>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 05c2d51a12 trsync: Introduce new "trigger synchronization" support
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>
2021-06-09 18:58:35 -04:00
Kevin O'Connor ecbfa76242 mcu: Raise config_error (not protocol error) on pin enumeration errors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:26 -04:00
Kevin O'Connor 31fcd491fd serialhdl: Support prepending a warn_prefix to error and log messages
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:26 -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 edea52863a endstop: Report trigger time in endstop_query response
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-30 11:40:37 -04:00
Kevin O'Connor 8f76e53c0e stepper: Remove min_stop_interval from mcu code
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>
2021-04-30 11:26:19 -04:00
Kevin O'Connor 8eceb9d40a mcu: Update hints for "Timer too close" and "No next step" errors
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>
2021-03-19 08:35:21 -04:00
Kevin O'Connor 041692828c mcu: Add support for connecting to devices on a CAN bus
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 11:29:41 -05:00
Kevin O'Connor 7dd2bf4af3 tmc2130: Verify SPI register writes
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>
2021-03-10 17:12:25 -05:00
Kevin O'Connor 9d3a3f3f30 serialhdl: Update callers to decide serial fd type
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>
2021-03-02 11:38:50 -05:00
Kevin O'Connor 0bdee6bc04 mcu: Raise a command_error on a command timeout event
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>
2021-02-27 10:39:46 -05:00
Kevin O'Connor 81da5379d4 buildcommands: Extend number of available mcu messages from 96 to 128
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>
2021-02-18 15:21:32 -05:00
Kevin O'Connor efa497dfd8 msgproto: Avoid peeking into the msgproto class members
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>
2021-02-18 14:33:44 -05:00
Kevin O'Connor 8a6619d18e mcu: Add a get_status() callback with micro-controller info and stats
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-19 23:12:41 -05:00
Kevin O'Connor e786748f18 heaters: Always register heater pin as a pwm pin
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>
2020-12-15 12:21:04 -05:00
Kevin O'Connor f3c5be0f00 gpiocmds: Merge digital output and soft pwm code
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>
2020-12-10 12:06:26 -05:00
Kevin O'Connor 19a96346a8 gpiocmds: Use move queue for software pwm
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Pascal Pieper 9cdf9bb6ec gpiocmds: Use move queue for digital output pins
Signed-off-by: Pascal Pieper <accounts@pascalpieper.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Pascal Pieper e8ec1801ff pwmcmds: Use move queue for hard PWM
Signed-off-by: Pascal Pieper <accounts@pascalpieper.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Pascal Pieper 99fe290753 mcu: Support reserving move queue slots
Signed-off-by: Pascal Pieper <accounts@pascalpieper.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Kevin O'Connor 086f0fafde gpiocmds: Send soft pwm cycle_time separately from schedule_soft_pwm_out
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Kevin O'Connor 79877acb14 mcu: Add support for setting reqclock in CommandQueryWrapper.send()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-29 12:00:28 -04:00
Kevin O'Connor 56004c0228 mcu: Don't default serial config option to /dev/ttyS0
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>
2020-10-28 15:35:08 -04:00
Kevin O'Connor 27249dc709 mcu: Increase the time to reset a pwm pin during startup
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>
2020-10-11 11:14:32 -04:00
Kevin O'Connor 4d0d219716 mcu: Fix set_pwm() for hard pwm
Must use self._pwm_max to calculate range for hard pwm updates.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-27 18:09:53 -04:00
Kevin O'Connor 55e20f2c19 mcu: Add support for changing cycle_time in set_pwm()
Signed-off-by: Guy Shapira <gayuha@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-26 20:55:56 -04:00
Guy Shapira 27cefb2b38 gpiocmds: Add soft-pwm frequency modulation support
Signed-off-by: Guy Shapira <gayuha@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-26 20:51:38 -04:00
Kevin O'Connor 9814daa999 mcu: Setup for steppersync_free to be automatically called
Use ffi_main.gc() to automatically free the C steppersync object.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-16 23:53:45 -04:00
Kevin O'Connor 2447025fa6 mcu: Don't define a __del__() method
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>
2020-09-16 23:53:45 -04:00
Kevin O'Connor 13ee6032ae mcu: Use schedule_pwm_out instead of set_pwm_out on a restart
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>
2020-09-09 13:16:02 -04:00
Kevin O'Connor 122fd88c6a mcu: Reset pwm and digital output pins to start values on a host restart
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>
2020-07-25 11:36:44 -04:00
Kevin O'Connor d204cc1fb7 mcu: Add support for commands to send only on a host restart
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>
2020-07-25 11:36:44 -04:00
Kevin O'Connor 25b6bc2f73 mcu: Remove undocumented "custom" config parameter
The "custom" config parameter is not documented and has not been
recommended in years.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-07-19 12:07:53 -04:00
Kevin O'Connor f5cdfad333 mcu: Avoid using "async" for variables as it conflicts with Python3
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-06-15 17:15:53 -04:00
Grigori Goronzy 0a20430e07 serial: Add Fysetc Cheetah board specific reset sequence
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>
2020-04-02 13:56:50 -04:00
Kevin O'Connor eeee2a9a35 mcu: Shutdown if a spontaneous restart of an mcu is observed
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-22 12:20:09 -04:00