Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions sys/net/gnrc/netif/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1922,11 +1922,6 @@
/* try to send anyway */
}
}
/* hold in case device was busy to not having to rewrite *all* the link
* layer implementations in case `gnrc_netif_pktq` is included */
if (gnrc_netif_netdev_legacy_api(netif)) {
gnrc_pktbuf_hold(pkt, 1);
}
#endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */

/* Record send in neighbor statistics if destination is unicast */
Expand All @@ -1947,6 +1942,13 @@
/* Split off the TX sync snip */
gnrc_pktsnip_t *tx_sync = IS_USED(MODULE_GNRC_TX_SYNC)
? gnrc_tx_sync_split(pkt) : NULL;
#if IS_USED(MODULE_GNRC_NETIF_PKTQ)
/* hold in case device was busy to not having to rewrite *all* the link
* layer implementations in case `gnrc_netif_pktq` is included */
if (gnrc_netif_netdev_legacy_api(netif)) {
gnrc_pktbuf_hold(pkt, 1);
}
#endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
int res = netif->ops->send(netif, pkt);

/* For legacy netdevs (no confirm_send) TX is blocking, thus it is always
Expand Down Expand Up @@ -2195,4 +2197,4 @@
}
}
}
/** @} */

Check warning on line 2200 in sys/net/gnrc/netif/gnrc_netif.c

View workflow job for this annotation

GitHub Actions / static-tests

source file is too long
12 changes: 12 additions & 0 deletions tests/net/gnrc_legacy_tx_sync/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include ../Makefile.net_common

USEMODULE += netdev_default
USEMODULE += auto_init_gnrc_netif
USEMODULE += gnrc_tx_sync
USEMODULE += gnrc_netif_pktq
USEMODULE += nrfmin
USEMODULE += ztimer_sec

include $(RIOTBASE)/Makefile.include

CFLAGS += -DDEBUG_ASSERT_VERBOSE=1
76 changes: 76 additions & 0 deletions tests/net/gnrc_legacy_tx_sync/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2025 Technische Universität Dresden
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @{
*
* @file
* @brief Text application for gnrc_legacy_tx_sync
*
* @author Lukas Luger <[email protected]>
*
* @}
*/

#include <stdio.h>

#include "net/af.h"
#include "net/gnrc/pktbuf.h"
#include "net/gnrc/tx_sync.h"
#include "net/gnrc.h"
#include "ztimer.h"
#include "thread.h"

static const char test_msg[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU"
"VWXYZ0123456789.,:;!?@#$%^&*()[]{}-_=+/<>`~\'\""
"\\";

void print_failed(void *arg)
{
(void)arg;
puts("TEST FAILED");
}

int main(void)
{
puts(
"Test application for gnrc_legacy_tx_sync\n"
"========================================\n"
"\n"
"This application sends a single message over the nrfmin netdev.\n"
"Other legacy netdevs can be used by changing the board and using\n"
"a different driver. Note: RIOT will sometimes choose the\n"
"netdev_ieee802154_submac as default driver which is not legacy.\n"
"tx_sync will only fail if gnrc_netif_pktq is used with a legacy driver.\n"
"If tx_sync does not finish in one second, the test will fail.\n"
);

/* Preparing the gnrc message */
gnrc_netif_t *netif = gnrc_netif_iter(NULL);
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(NULL, test_msg, sizeof(test_msg),
GNRC_NETTYPE_UNDEF);
gnrc_tx_sync_t tx_sync;
gnrc_tx_sync_append(pkt, &tx_sync);

/* Set timeout message in case tx sync fails */
ztimer_t timer = {
.callback = print_failed,
.arg = NULL,
};
ztimer_set(ZTIMER_SEC, &timer, 1);

/* Sending and waiting */
gnrc_netapi_send(netif->pid, pkt);
gnrc_tx_sync(&tx_sync);

/* Cancel error message and print success message */
ztimer_remove(ZTIMER_SEC, &timer);
puts("TEST PASSED");

return 0;
}
20 changes: 20 additions & 0 deletions tests/net/gnrc_legacy_tx_sync/tests/01-run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3

# Copyright (C) 2025 Technische Universität Dresden
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.

# @author Lukas Luger <[email protected]>

import sys
from testrunner import run


def testfunc(child):
child.expect("TEST PASSED", timeout=2)


if __name__ == "__main__":
sys.exit(run(testfunc))
Loading