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
16 changes: 16 additions & 0 deletions tests/net/gnrc_legacy_tx_sync/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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

FEATURES_REQUIRED += cpu_nrf52

include $(RIOTBASE)/Makefile.include

TEST_ON_CI_WHITELIST += nrf52840dk

CFLAGS += -DDEBUG_ASSERT_VERBOSE=1
97 changes: 97 additions & 0 deletions tests/net/gnrc_legacy_tx_sync/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* 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"

char result_thread_stack[THREAD_STACKSIZE_MAIN];

msg_t error_msg = { .content.value = 0 };
msg_t success_msg = { .content.value = 1 };


Check warning on line 34 in tests/net/gnrc_legacy_tx_sync/main.c

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static gnrc_netif_t *netif;

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

void *result_thread(void *arg)
{
(void)arg;
/* Only receiving one message ever */
msg_t msg;
msg_receive(&msg);
if (msg.content.value) {
puts("TEST PASSED");
}
else {
puts("TEST FAILED");
}
return NULL;
}

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 */
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);

/* Starting the result thread */
pid_t pid = thread_create(result_thread_stack, sizeof(result_thread_stack),
THREAD_PRIORITY_MAIN - 1, 0, result_thread, NULL,
"result_thread");

/* Set timeout message in case tx sync fails */
ztimer_t timer;
ztimer_set_msg(ZTIMER_SEC, &timer, 1, &error_msg, pid);

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

/* Cancel error message and send success message */
if (ztimer_remove(ZTIMER_SEC, &timer)) {
/* Successfully removed error message, not too late to send success */
msg_send(&success_msg, pid);
}

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