Remove empty packets from the queue after their first transmission

This commit is contained in:
Thomas Kolb 2024-07-27 00:50:04 +02:00
parent 04dcfff6fd
commit d2ef6d9741
3 changed files with 19 additions and 0 deletions

View file

@ -160,6 +160,19 @@ void layer2_tx_restart(layer2_tx_t *ctx)
}
void layer2_tx_clean_empty_packet(layer2_tx_t *ctx)
{
const packet_queue_entry_t *entry = packet_queue_get(&ctx->packet_queue, 0);
if(entry && entry->header.msg_type == L2_MSG_TYPE_EMPTY) {
packet_queue_delete(&ctx->packet_queue, 1);
if(ctx->next_packet_index > 0) {
ctx->next_packet_index--;
}
}
}
void layer2_tx_handle_ack(layer2_tx_t *ctx, uint8_t acked_seq, bool do_ack)
{
ctx->next_packet_index = 0;

View file

@ -57,6 +57,10 @@ size_t layer2_tx_encode_next_packet(layer2_tx_t *ctx, uint8_t ack_seq_nr, uint8_
*/
void layer2_tx_restart(layer2_tx_t *ctx);
/*!\brief Remove the first packet from the queue if it is an empty packet.
*/
void layer2_tx_clean_empty_packet(layer2_tx_t *ctx);
/*!\brief Handle acknowledgements.
* \details
* Removes all packets before the given sequence number from the queue.

View file

@ -284,6 +284,8 @@ int main(int argc, char **argv)
// generate the ramp-down
RESULT_CHECK(layer1_tx_finalize_burst(&tx));
layer2_tx_clean_empty_packet(&l2tx);
size_t burst_len = layer1_tx_get_sample_count(&tx);
const float complex *whole_burst = layer1_tx_get_sample_data(&tx);