Skip to content

Commit 9916459

Browse files
committed
serialqueue: Keep moving messages from pending queues to ready queues
Keep moving messages from the pending queues to the ready queues even if it's not currently valid to transmit messages to the mcu. This improves the statistics when debugging. Signed-off-by: Kevin O'Connor <[email protected]>
1 parent 6d5fd91 commit 9916459

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

klippy/chelper/serialqueue.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -576,25 +576,26 @@ check_upcoming_queues(struct serialqueue *sq, uint64_t ack_clock)
576576
static double
577577
check_send_command(struct serialqueue *sq, int pending, double eventtime)
578578
{
579+
// Check for upcoming messages now ready
580+
double idletime = eventtime > sq->idle_time ? eventtime : sq->idle_time;
581+
idletime += calculate_bittime(sq, pending + MESSAGE_MIN);
582+
uint64_t ack_clock = clock_from_time(&sq->ce, idletime);
583+
uint64_t min_stalled_clock = check_upcoming_queues(sq, ack_clock);
584+
585+
// Check if valid to send messages
579586
if (sq->send_seq - sq->receive_seq >= MAX_PENDING_BLOCKS
580587
&& sq->receive_seq != (uint64_t)-1)
581588
// Need an ack before more messages can be sent
582-
return PR_NEVER;
589+
return eventtime + 0.250;
583590
if (sq->send_seq > sq->receive_seq && sq->receive_window) {
584591
int need_ack_bytes = sq->need_ack_bytes + MESSAGE_MAX;
585592
if (sq->last_ack_seq < sq->receive_seq)
586593
need_ack_bytes += sq->last_ack_bytes;
587594
if (need_ack_bytes > sq->receive_window)
588595
// Wait for ack from past messages before sending next message
589-
return PR_NEVER;
596+
return eventtime + 0.250;
590597
}
591598

592-
// Check for upcoming messages now ready
593-
double idletime = eventtime > sq->idle_time ? eventtime : sq->idle_time;
594-
idletime += calculate_bittime(sq, pending + MESSAGE_MIN);
595-
uint64_t ack_clock = clock_from_time(&sq->ce, idletime);
596-
uint64_t min_stalled_clock = check_upcoming_queues(sq, ack_clock);
597-
598599
// Check if a block is fully ready to send
599600
if (sq->ready_bytes >= MESSAGE_PAYLOAD_MAX)
600601
return PR_NOW;

0 commit comments

Comments
 (0)