From 7b03b04c786863bc32d3b790862857061f71f072 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 11 Apr 2017 11:37:09 -0400 Subject: klippy: Support minimum/maximum value checks on configuration variables Verify that numeric parameters are in a sane range when reading the config. Signed-off-by: Kevin O'Connor --- klippy/toolhead.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'klippy/toolhead.py') diff --git a/klippy/toolhead.py b/klippy/toolhead.py index d7b677ce..bd4ccd10 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -188,18 +188,24 @@ class ToolHead: 'corexy': corexy.CoreXYKinematics, 'delta': delta.DeltaKinematics} self.kin = config.getchoice('kinematics', kintypes)(printer, config) - self.max_speed = config.getfloat('max_velocity') - self.max_accel = config.getfloat('max_accel') - self.max_accel_to_decel = config.getfloat('max_accel_to_decel' - , self.max_accel * 0.5) - self.junction_deviation = config.getfloat('junction_deviation', 0.02) + self.max_speed = config.getfloat('max_velocity', above=0.) + self.max_accel = config.getfloat('max_accel', above=0.) + self.max_accel_to_decel = config.getfloat( + 'max_accel_to_decel', self.max_accel * 0.5 + , above=0., maxval=self.max_accel) + self.junction_deviation = config.getfloat( + 'junction_deviation', 0.02, above=0.) self.move_queue = MoveQueue(self.extruder.lookahead) self.commanded_pos = [0., 0., 0., 0.] # Print time tracking - self.buffer_time_high = config.getfloat('buffer_time_high', 2.000) - self.buffer_time_low = config.getfloat('buffer_time_low', 1.000) - self.buffer_time_start = config.getfloat('buffer_time_start', 0.250) - self.move_flush_time = config.getfloat('move_flush_time', 0.050) + self.buffer_time_low = config.getfloat( + 'buffer_time_low', 1.000, above=0.) + self.buffer_time_high = config.getfloat( + 'buffer_time_high', 2.000, above=self.buffer_time_low) + self.buffer_time_start = config.getfloat( + 'buffer_time_start', 0.250, above=0.) + self.move_flush_time = config.getfloat( + 'move_flush_time', 0.050, above=0.) self.print_time = 0. self.need_check_stall = -1. self.print_stall = 0 @@ -208,7 +214,8 @@ class ToolHead: self.flush_timer = self.reactor.register_timer(self._flush_handler) self.move_queue.set_flush_time(self.buffer_time_high) # Motor off tracking - self.motor_off_time = config.getfloat('motor_off_time', 600.000) + self.motor_off_time = config.getfloat( + 'motor_off_time', 600.000, minval=0.) self.motor_off_timer = self.reactor.register_timer( self._motor_off_handler) # Determine the maximum velocity a cartesian axis could have -- cgit v1.2.3-70-g09d2