From 777a0b817bc01425d562e42354bf09463a1d7852 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 11 Jul 2016 11:41:49 -0400 Subject: serialhdl: Calculate baudadjust from MCU's baud instead of host baud Store the baud rate the MCU is configured for in the "identify" data and use that rate when calculating the baudadjust parameter. Signed-off-by: Kevin O'Connor --- klippy/serialqueue.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'klippy/serialqueue.c') diff --git a/klippy/serialqueue.c b/klippy/serialqueue.c index 60ceeb4b..b3451ad6 100644 --- a/klippy/serialqueue.c +++ b/klippy/serialqueue.c @@ -770,11 +770,10 @@ background_thread(void *data) // Create a new 'struct serialqueue' object struct serialqueue * -serialqueue_alloc(int serial_fd, double baud_adjust, int write_only) +serialqueue_alloc(int serial_fd, int write_only) { struct serialqueue *sq = malloc(sizeof(*sq)); memset(sq, 0, sizeof(*sq)); - sq->baud_adjust = baud_adjust; // Reactor setup sq->serial_fd = serial_fd; @@ -961,6 +960,14 @@ exit: pthread_mutex_unlock(&sq->lock); } +void +serialqueue_set_baud_adjust(struct serialqueue *sq, double baud_adjust) +{ + pthread_mutex_lock(&sq->lock); + sq->baud_adjust = baud_adjust; + pthread_mutex_unlock(&sq->lock); +} + // Set the estimated clock rate of the mcu on the other end of the // serial port void -- cgit v1.2.3-70-g09d2