Commit Graph

12 Commits

Author SHA1 Message Date
Kevin O'Connor 7554c7f694 stepcompress: Do all step rounding in C code
Commits f0cefebf and 8f331f08 changed the way the code determined what
steps to take on fractional steps.  Unfortunately, it was possible in
some situations for the C code to round differently from the python
code which could result in warnings and lost steps.

Change the code so that all fractional step handling is done in the C
code.  Implementing the step rounding logic in one location avoids any
conflicts.

In order to efficiently handle the step rounding in the C code, the C
code has also been extended to directly send the "set_next_step_dir"
command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-13 18:29:45 -05:00
Kevin O'Connor 79da35d023 stepcompress: Minor code movement
Move flush() and check_expand() code to a new location so that the
stepcompress_push_X() functions can flush.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-12 22:55:27 -05:00
Kevin O'Connor 508a934d62 stepcompress: Do 32bit integer overflow checks internally in C code
Update the stepcompress C code to check for integer overflow so that
the python code does not need to.  The new checks also handle the
possibility of a single move lasting long enough to cause an overflow.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-02 13:22:35 -04:00
Kevin O'Connor 8025921fc8 stepcompress: Invert the meaning of the min_clock flag
Use a non-zero qm->min_clock value to indicate that the command uses
the move queue and to also store the clock of when that move queue
item will be released.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-02 10:12:26 -04:00
Kevin O'Connor ff6fef927a stepcompress: Store step times using 64bit integers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-01 19:38:37 -04:00
Kevin O'Connor ab54fcd443 stepcompress: Check for small negative numbers on sqrt() calls
It's theoretically possible for floating point truncation to cause a
math formula to return a small negative number instead of 0.  If
sqrt() is called on this small negative number it could cause a
crash.  Check for this case and return 0.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-10-10 11:39:26 -04:00
Kevin O'Connor 9fa0a62c8a stepcompress: Eliminate possible infinite loop in compress_bisect_add()
Commit 47f30331 converted compress_bisect_add() to use "best reach"
instead of "best add".  However, that change caused
compress_bisect_add() to behave poorly when passed in invalid data
(negative times).  Change the code to better handle invalid data.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-10-10 11:31:56 -04:00
Kevin O'Connor 47f303317b stepcompress: Compress for greatest "reach" instead of greatest "add"
Search for the maximum reachable value instead of the maximum "add".
The maximum reachable value encompasses both the maximum count and a
closest step time to the last requested step time.  This allows for
more "add=0" sequences to be generated which the mcu can optimize for.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-24 11:42:06 -04:00
Kevin O'Connor 4988ba9a71 stepcompress: Fix error causing queue to not be expanded in expand_queue()
The test to check if the queue only needed to be moved was not correct
and it could lead to a segfault if clean_queue() was called instead of
actually increasing the queue size.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-16 21:33:35 -04:00
Kevin O'Connor 3fa7da804d stepcompress: Check for invalid count in step_factor and step_sqrt
Check for an invalid count and report an error if found.  This
prevents some segfaults when count goes negative.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-16 21:33:15 -04:00
Kevin O'Connor ae8d57e650 stepcompress: Fix compress_bisect_add() infinite loop
At high step speeds, it is possible to exit the inner scan due to
integer truncation.  Always update minadd or maxadd so that the outer
loop always terminates.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-10 21:46:57 -04:00
Kevin O'Connor f582a36e4d Initial commit of source code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-05-25 11:37:40 -04:00