aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-05-24 13:30:24 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-05-28 10:43:40 -0400
commit75f870994722cf2340d8bc39c0600ca592dadc7a (patch)
tree0448247983438b3786f7be1b890f86455ea09fe8 /klippy/chelper
parent528f9f76042a7d82a2108f4ea582c61481368ecf (diff)
downloadkutter-75f870994722cf2340d8bc39c0600ca592dadc7a.tar.gz
kutter-75f870994722cf2340d8bc39c0600ca592dadc7a.tar.xz
kutter-75f870994722cf2340d8bc39c0600ca592dadc7a.zip
command: Wait to send ack until after processing commands
Send the ack after processing commands - this gives the host code more information on serial buffer utilization. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper')
-rw-r--r--klippy/chelper/serialqueue.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/klippy/chelper/serialqueue.c b/klippy/chelper/serialqueue.c
index ab55d176..06ee0ee0 100644
--- a/klippy/chelper/serialqueue.c
+++ b/klippy/chelper/serialqueue.c
@@ -363,7 +363,7 @@ struct serialqueue {
double last_receive_sent_time;
// Retransmit support
uint64_t send_seq, receive_seq;
- uint64_t ignore_nak_seq, retransmit_seq, rtt_sample_seq;
+ uint64_t ignore_nak_seq, last_ack_seq, retransmit_seq, rtt_sample_seq;
struct list_head sent_queue;
double srtt, rttvar, rto;
// Pending transmission message queues
@@ -509,10 +509,14 @@ handle_message(struct serialqueue *sq, double eventtime, int len)
if (rseq != sq->receive_seq)
// New sequence number
update_receive_seq(sq, eventtime, rseq);
- else if (len == MESSAGE_MIN && rseq > sq->ignore_nak_seq
- && !list_empty(&sq->sent_queue))
- // Duplicate sequence number in an empty message is a nak
- pollreactor_update_timer(&sq->pr, SQPT_RETRANSMIT, PR_NOW);
+ if (len == MESSAGE_MIN) {
+ // Ack/nak message
+ if (sq->last_ack_seq < rseq)
+ sq->last_ack_seq = rseq;
+ else if (rseq > sq->ignore_nak_seq && !list_empty(&sq->sent_queue))
+ // Duplicate Ack is a Nak - do fast retransmit
+ pollreactor_update_timer(&sq->pr, SQPT_RETRANSMIT, PR_NOW);
+ }
if (len > MESSAGE_MIN) {
// Add message to receive queue