Introduce a heaters.set_temperature() command and call that from
commands that set a heater temperature. This new function calls
toolhead.register_lookahead_callback() so that the idle_timeout gets
notification that activity has occurred.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make the baud rate an optional parameter to the console.py tool. When
not present, it will default to 250000.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Add new fields to Command_Templates.md.
Remove unused self.rpm variable.
Use an explicit get_frequency() method in keeping with Klipper's
convention of not "peeking into member variables".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This adds new config options for fans: 'tachometer_pin' to specify the
GPIO pin, and 'tachometer_ppr' (default 2) to specify the number of
signal pulses per revolution. The rpm is also exposed by get_status for
command templates and the API server. For fast fans (at least 10000
RPM), the polling interval can be shortened using the
'tachometer_poll_interval' option.
There is a new mcu object for a generic edge counter, which repeatedly
polls a GPIO pin and periodically reports the count to the host.
Signed-off-by: Adrian Keet <arkeet@gmail.com>
If `klippy` loses connection to a device, the next `read()` from the
device file descriptor will result in a zero-byte result, i.e. an `EOF`.
Right now this gives a confusing error message, so this simply handles
the special case of `EOF` and outputs a better log message.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
When `serialhdl` opens a terminal device it must prevent the device from
becoming the controlling terminal of `klippy`, as such a terminal will
send additional messages to the session leader, e.g. a SIGHUP, which
would kill `klippy`. See e.g. #3981.
pySerial already does this, but for e.g. `klipper_mcu` we were not doing
this ourselves.
On Linux a process must set `O_NOCTTY` when opening any file that could
potentially be a terminal device, to avoid this.
Earlier process daemonization tools prevent this from being an issue by
double forking, but under `systemd` a process must take steps to avoid
opening a controlling terminal.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
With commit 53b10d3a the setup of sensorless homing could occur before
the driver was enabled which would cause the reinitialization of the
driver settings to undo the sensorless homing setup.
Use set_field() when setting the sensorless homing registers so that
it wont conflict with a driver init.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Check the status of all Trinamic stepper motor drivers once a second.
If the driver reports an error then invoke a shutdown. Also log any
serious warnings.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Send the full TMC stepper motor driver initialization sequence every
time the driver is enabled.
Don't raise an error on startup if unable to contact a tmc2208/tmc2209
driver. If the driver is still unavailable when it is enabled then a
shutdown will be issued. This allows users to troubleshoot (and
possibly bring up communication to the driver) prior to enabling the
driver.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The tmc2660 appears to send responses as soon as the clk starts
toggling. That means the 20 bit response is at the top of the 24bit
sent message. Also, this implies that RDSEL must already have the
correct value in the prior message.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Where the tmc2660 flags match other drivers, use lowercase so that the
same monitoring code can be used for all the tmc drivers. Also, use
the same field formatters where applicable.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The tmc5160 field formatters were mostly duplicates of the tmc2130 -
add the "reset" field to tmc2130.py so both drivers have similar
reporting.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Refactor the tmc driver implementations so that there is a single
implementation of the SET_TMC_CURRENT command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
currently, if there are 2 files on the virtual sd card whose names differ only in
case (eg. MyFile.gcode vs myfile.gcode) the actual file that gets loaded is at
best unpredictable. this patch checks for an exact match before attempting a
case-insensitive one.
Signed-off-by: Andre LeBlanc <andrepleblanc@gmail.com>
The stepper positions will only be in sync after the step generation
code has been flushed. This fixes an "internal error in stepcompress"
error during a SYNC_STEPPER_TO_EXTRUDER command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This patch adds the ability to daisy-chain multiple tmc2130 and
tmc5160 drivers.
Signed-off-by: Marco D'Alessio <marco@wrecklab.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If neither rotation_distance nor step_distance is present, then
generate an error saying rotation_distance is needed (instead of an
error about step_distance).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This reverts commit ac61f8b726.
Many temperature sensors are capitalized, so don't make this chaneg to
the bme280.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
Some communication protocols are more efficient if fewer write() calls
are invoked. If multiple message blocks can be sent at the same time
then batch them into a single write() call.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If any callback is invoked from the pollreactor then obtain a new
eventtime before calculating a sleep duration. This improves the
timing of events.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 73b78af6 inadvertently removed the check for a successful gcc
compilation. Add the check back in.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Initial commit of code to support 1-wire (Dallas) sensors such
as the DS18B20. Requires Linux kernel drivers to create a file
in /sysfs which is read by this module, and temperature
typically returned to a temperature_fan.
Signed-off-by: Alan Lord <alanslists@gmail.com>
Signed-off-by: Josh Headapohl <joshhead@gmail.com>
Call mcu_adc.setup_minmax() even in debug output mode so that the
debugging output contains a more accurate configuration.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make available the parsed value (or default value) for config options
to command templates and to the api server.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If a get_status() method returns a mutable object (such as a list or
dict) then it would be possible for a gcode command template to
incorrectly alter the program's internal state. Perform a deepcopy()
operation on all get_status() return results to avoid that.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Since Python 2.6, the BaseException.message attribute is deprecated (PEP-352[1])
in favor of e.args[0] or str(e). This commit replaces e.message with str(e).
[1] https://www.python.org/dev/peps/pep-0352/
Signed-off-by: Maël Kerbiriou <m431.kerbiriou@gmail.com>
Commit ea85d419 moved CommandError from homing.py to gcode.py, but
failed to fix the references to CommandError within homing.py. Fix
that.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Calculate the get_status() axis_minimum and axis_maximum fields in
advance so that they don't need to be calculated on each get_status()
call.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Improved algorithm to choose the 'optimal' shaper frequency taking
shaper smoothing into account. This may choose a frequency with
slightly more vibrations but less smoothing. Also allow users to
limit the maximum input shaper smoothing.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Add support for automatically calculating the internal step_distance
from new config parameters - rotation_distance, microsteps,
full_steps_per_rotation, and gear_ratio.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The previous init sequence relied on the display ignoring commands if
they are sent faster than 40us. Some displays may not have this
limit.
Rework the init to make it more robust to command transmission times.
The new init should still transition the display into 4-bit mode even
if the display processes commands faster than 40us.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>