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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-10-18 15:17:29 -04:00
parent 6d5fd9164e
commit 9916459af8

View File

@@ -576,25 +576,26 @@ check_upcoming_queues(struct serialqueue *sq, uint64_t ack_clock)
static double
check_send_command(struct serialqueue *sq, int pending, double eventtime)
{
// Check for upcoming messages now ready
double idletime = eventtime > sq->idle_time ? eventtime : sq->idle_time;
idletime += calculate_bittime(sq, pending + MESSAGE_MIN);
uint64_t ack_clock = clock_from_time(&sq->ce, idletime);
uint64_t min_stalled_clock = check_upcoming_queues(sq, ack_clock);
// Check if valid to send messages
if (sq->send_seq - sq->receive_seq >= MAX_PENDING_BLOCKS
&& sq->receive_seq != (uint64_t)-1)
// Need an ack before more messages can be sent
return PR_NEVER;
return eventtime + 0.250;
if (sq->send_seq > sq->receive_seq && sq->receive_window) {
int need_ack_bytes = sq->need_ack_bytes + MESSAGE_MAX;
if (sq->last_ack_seq < sq->receive_seq)
need_ack_bytes += sq->last_ack_bytes;
if (need_ack_bytes > sq->receive_window)
// Wait for ack from past messages before sending next message
return PR_NEVER;
return eventtime + 0.250;
}
// Check for upcoming messages now ready
double idletime = eventtime > sq->idle_time ? eventtime : sq->idle_time;
idletime += calculate_bittime(sq, pending + MESSAGE_MIN);
uint64_t ack_clock = clock_from_time(&sq->ce, idletime);
uint64_t min_stalled_clock = check_upcoming_queues(sq, ack_clock);
// Check if a block is fully ready to send
if (sq->ready_bytes >= MESSAGE_PAYLOAD_MAX)
return PR_NOW;