aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepcompress.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-11-30 12:04:28 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-11-30 21:19:43 -0500
commit4f07ee4d92732d0b619553d366b50b4b758c3d87 (patch)
treee4bf83d205001cafba04725aa6b1da9254620575 /klippy/stepcompress.c
parentb14db404b55424ef783a163a02da8868120b36c9 (diff)
downloadkutter-4f07ee4d92732d0b619553d366b50b4b758c3d87.tar.gz
kutter-4f07ee4d92732d0b619553d366b50b4b758c3d87.tar.xz
kutter-4f07ee4d92732d0b619553d366b50b4b758c3d87.zip
pyhelper: Add ability to route error messages to python logging
Instead of writing error messages to stderr, route them into the python code and use the standard python logging system. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/stepcompress.c')
-rw-r--r--klippy/stepcompress.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c
index 732afe99..4f41cfee 100644
--- a/klippy/stepcompress.c
+++ b/klippy/stepcompress.c
@@ -17,9 +17,9 @@
#include <math.h> // sqrt
#include <stddef.h> // offsetof
#include <stdint.h> // uint32_t
-#include <stdio.h> // fprintf
#include <stdlib.h> // malloc
#include <string.h> // memset
+#include "pyhelper.h" // errorf
#include "serialqueue.h" // struct queue_message
#define CHECK_LINES 1
@@ -219,16 +219,16 @@ check_line(struct stepcompress *sc, struct step_move move)
if (move.count == 1) {
if (move.interval != (uint32_t)(*sc->queue_pos - sc->last_step_clock)
|| *sc->queue_pos < sc->last_step_clock) {
- fprintf(stderr, "ERROR: Count 1 point out of range: %d %d %d\n"
- , move.interval, move.count, move.add);
+ errorf("Count 1 point out of range: %d %d %d"
+ , move.interval, move.count, move.add);
sc->errors++;
}
return;
}
int err = 0;
if (!move.count || !move.interval || move.interval >= 0x80000000) {
- fprintf(stderr, "ERROR: Point out of range: %d %d %d\n"
- , move.interval, move.count, move.add);
+ errorf("Point out of range: %d %d %d"
+ , move.interval, move.count, move.add);
err++;
}
uint32_t interval = move.interval, p = 0;
@@ -237,13 +237,13 @@ check_line(struct stepcompress *sc, struct step_move move)
struct points point = minmax_point(sc, sc->queue_pos + i);
p += interval;
if (p < point.minp || p > point.maxp) {
- fprintf(stderr, "ERROR: Point %d of %d: %d not in %d:%d\n"
- , i+1, move.count, p, point.minp, point.maxp);
+ errorf("Point %d of %d: %d not in %d:%d"
+ , i+1, move.count, p, point.minp, point.maxp);
err++;
}
if (interval >= 0x80000000) {
- fprintf(stderr, "ERROR: Point %d of %d: interval overflow %d\n"
- , i+1, move.count, interval);
+ errorf("Point %d of %d: interval overflow %d"
+ , i+1, move.count, interval);
err++;
}
interval += move.add;
@@ -385,8 +385,8 @@ stepcompress_push_factor(struct stepcompress *sc
int count = steps + .5 - step_offset;
if (count <= 0 || count > 1000000) {
if (count && steps)
- fprintf(stderr, "ERROR: push_factor invalid count %d %f %f %f %f\n"
- , sc->oid, steps, step_offset, clock_offset, factor);
+ errorf("push_factor invalid count %d %f %f %f %f"
+ , sc->oid, steps, step_offset, clock_offset, factor);
return 0;
}
check_expand(sc, sdir, count);
@@ -419,9 +419,9 @@ stepcompress_push_sqrt(struct stepcompress *sc, double steps, double step_offset
int count = steps + .5 - step_offset;
if (count <= 0 || count > 1000000) {
if (count && steps)
- fprintf(stderr, "ERROR: push_sqrt invalid count %d %f %f %f %f %f\n"
- , sc->oid, steps, step_offset, clock_offset, sqrt_offset
- , factor);
+ errorf("push_sqrt invalid count %d %f %f %f %f %f"
+ , sc->oid, steps, step_offset, clock_offset, sqrt_offset
+ , factor);
return 0;
}
check_expand(sc, sdir, count);
@@ -452,10 +452,9 @@ stepcompress_push_delta_const(
- height - zdist) / step_dist + .5;
if (count <= 0 || count > 1000000) {
if (count)
- fprintf(stderr, "ERROR: push_delta_const invalid count"
- " %d %d %f %f %f %f %f %f %f %f\n"
- , sc->oid, count, clock_offset, dist, step_dist, start_pos
- , closest_height2, height, movez_r, inv_velocity);
+ errorf("push_delta_const invalid count %d %d %f %f %f %f %f %f %f %f"
+ , sc->oid, count, clock_offset, dist, step_dist, start_pos
+ , closest_height2, height, movez_r, inv_velocity);
return 0;
}
check_expand(sc, step_dist > 0., count);
@@ -488,10 +487,9 @@ stepcompress_push_delta_accel(
- height - zdist) / step_dist + .5;
if (count <= 0 || count > 1000000) {
if (count)
- fprintf(stderr, "ERROR: push_delta_accel invalid count"
- " %d %d %f %f %f %f %f %f %f %f\n"
- , sc->oid, count, clock_offset, dist, step_dist, start_pos
- , closest_height2, height, movez_r, accel_multiplier);
+ errorf("push_delta_accel invalid count %d %d %f %f %f %f %f %f %f %f"
+ , sc->oid, count, clock_offset, dist, step_dist, start_pos
+ , closest_height2, height, movez_r, accel_multiplier);
return 0;
}
check_expand(sc, step_dist > 0., count);