aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/serialqueue.c
Commit message (Collapse)AuthorAgeFilesLines
* serialqueue: Improve limit on number of in-flight bytesKevin O'Connor2017-07-231-6/+5
| | | | | | | | Instead of limiting the amount of non-acked messages to 50ms, limit the amount to one round-trip-time. This should make it less likely that the mcu will be overloaded and it should make retransmits faster. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Further retransmit timing fixesKevin O'Connor2017-07-231-5/+3
| | | | | | | | | The first message always has a sync byte with it, so its size should be one larger. Also, the idle_time should always be the minimum time that the message could be received, so it should always be reset to eventtime on a retransmit. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Allow a second nak after a retransmitKevin O'Connor2017-07-211-3/+11
| | | | | | | | | If a nak message causes a retransmission then also accept a second nak message as long as it is for a sequence greater than the first nak. This should allow faster retransmits when there are multiple transmission errors in a small time period. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Fix off-by-one error in retransmit sequence number trackingKevin O'Connor2017-07-211-3/+3
| | | | | | | | Track the sequence number of the message last retransmitted (not the sequence number of the next message to be transmitted). This fixes a small possibility of a valid nak not being honored. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Improve timing of multiple retransmitsKevin O'Connor2017-07-211-8/+12
| | | | | | | | If a retransmit is triggered by a nak, then it is not necessary to increase the rto. The next retransmit time should be based on the expected reception of the first retransmitted message, not the last. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Rename clock estimation variable namesKevin O'Connor2017-06-301-12/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Clarify code that associates sent messages to received messagesKevin O'Connor2017-06-301-6/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Message receive_time must be taken after read()Kevin O'Connor2017-03-241-1/+1
| | | | | | | | | | | | The est_clock calculation code requires timestamps on status messages to never be prior to the reception of the message. The eventtime of handle_message() is taken before the read() and there is a small possibility that it could be inaccurate enough to corrupt the est_clock calculation. Take a new timestamp when storing receive_time to prevent this. This fix prevents some firmware "Move queue empty" shutdowns. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Don't retransmit on a NAK if no sent data is pendingKevin O'Connor2017-03-241-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* reactor: Use the system monotonic clock instead of the normal system clockKevin O'Connor2017-02-061-3/+3
| | | | | | | | | | | | | The normal system clock can have sudden jumps if the system clock is changed. Use the system monotonic clock to avoid these sudden changes in time. It appears the Raspbian OS (which is used by OctoPi) is setup to update the system clock upon network connectivity. This could cause sudden system clock changes which could lead to Klippy processing errors. Using the monotonic clock eliminates these issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Remove serialqueue_flush_ready()Kevin O'Connor2016-12-301-14/+1
| | | | | | | | | The serialqueue_flush_ready() code was used to flush queue_step commands during a homing operation. It's no longer necessary now that moves during a homing operation use the normal message priority system. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pyhelper: Add ability to route error messages to python loggingKevin O'Connor2016-11-301-2/+2
| | | | | | | 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>
* pyhelper: Move helper functions from serialqueue.c to new fileKevin O'Connor2016-11-301-59/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Be careful to free memory allocated in C codeKevin O'Connor2016-11-301-18/+46
| | | | | | Free steppersync, stepcompress, and commandqueue objects. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Fully deallocate serialqueue on disconnectKevin O'Connor2016-11-291-0/+34
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Kick the background thread from serialqueue_exitKevin O'Connor2016-11-291-9/+10
| | | | | | | Wake the background thread up when exiting - as this makes the exit complete faster (and have more predictable timing). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Fix possible memory leak in serialqueue_extract_old()Kevin O'Connor2016-11-291-2/+2
| | | | | | | Make sure to free all messages even if the requested size is smaller than the number of messages. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Calculate baudadjust from MCU's baud instead of host baudKevin O'Connor2016-07-161-2/+9
| | | | | | | 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 <kevin@koconnor.net>
* serialqueue: Add debugging helper functions for dumping a binary bufferKevin O'Connor2016-06-051-0/+24
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Initial commit of source code.Kevin O'Connor2016-05-251-0/+1021
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>