Merge pull request #5038 from cgundogan/pr/pktdump/global_pid

gnrc_pktdump: make pid global
This commit is contained in:
Martine Lenders 2016-03-11 15:33:36 +01:00
commit 78136ff25f
10 changed files with 14 additions and 22 deletions

View File

@ -55,7 +55,7 @@ int main(void)
#ifdef MODULE_NETIF
gnrc_netreg_entry_t dump;
dump.pid = gnrc_pktdump_getpid();
dump.pid = gnrc_pktdump_pid;
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
#endif

View File

@ -103,7 +103,7 @@ static void start_server(char *port_str)
return;
}
/* start server (which means registering pktdump for the chosen port) */
server.pid = gnrc_pktdump_getpid();
server.pid = gnrc_pktdump_pid;
server.demux_ctx = (uint32_t)port;
gnrc_netreg_register(GNRC_NETTYPE_UDP, &server);
printf("Success: started UDP server on port %" PRIu16 "\n", port);

View File

@ -50,12 +50,9 @@ extern "C" {
#endif
/**
* @brief Get the PID of the pktdump thread
*
* @return PID of the pktdump thread
* @return @ref KERNEL_PID_UNDEF if not initialized
* @brief The PID of the pktdump thread
*/
kernel_pid_t gnrc_pktdump_getpid(void);
extern kernel_pid_t gnrc_pktdump_pid;
/**
* @brief Start the packet dump thread and listening for incoming packets

View File

@ -36,7 +36,7 @@
/**
* @brief PID of the pktdump thread
*/
static kernel_pid_t _pid = KERNEL_PID_UNDEF;
kernel_pid_t gnrc_pktdump_pid = KERNEL_PID_UNDEF;
/**
* @brief Stack for the pktdump thread
@ -154,17 +154,12 @@ static void *_eventloop(void *arg)
return NULL;
}
kernel_pid_t gnrc_pktdump_getpid(void)
{
return _pid;
}
kernel_pid_t gnrc_pktdump_init(void)
{
if (_pid == KERNEL_PID_UNDEF) {
_pid = thread_create(_stack, sizeof(_stack), GNRC_PKTDUMP_PRIO,
if (gnrc_pktdump_pid == KERNEL_PID_UNDEF) {
gnrc_pktdump_pid = thread_create(_stack, sizeof(_stack), GNRC_PKTDUMP_PRIO,
THREAD_CREATE_STACKTEST,
_eventloop, NULL, "pktdump");
}
return _pid;
return gnrc_pktdump_pid;
}

View File

@ -36,7 +36,7 @@ int main(void)
/* register the pktdump thread */
puts("Register the packet dump thread for GNRC_NETTYPE_UNDEF packets");
dump.pid = gnrc_pktdump_getpid();
dump.pid = gnrc_pktdump_pid;
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);

View File

@ -32,7 +32,7 @@ int main(void)
/* register the pktdump thread */
puts("Register the packet dump thread for GNRC_NETTYPE_UNDEF packets");
dump.pid = gnrc_pktdump_getpid();
dump.pid = gnrc_pktdump_pid;
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);

View File

@ -41,7 +41,7 @@ int main(void)
gnrc_nomac_init(nomac_stack, sizeof(nomac_stack), 5, "nomac", &dev);
/* initialize packet dumper */
netobj.pid = gnrc_pktdump_getpid();
netobj.pid = gnrc_pktdump_pid;
netobj.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &netobj);

View File

@ -35,7 +35,7 @@ int main(void)
puts("Xbee S1 device driver test");
/* initialize and register pktdump */
dump.pid = gnrc_pktdump_getpid();
dump.pid = gnrc_pktdump_pid;
if (dump.pid <= KERNEL_PID_UNDEF) {
puts("Error starting pktdump thread");
return -1;

View File

@ -35,7 +35,7 @@ int main(void)
puts("SLIP test");
/* initialize and register pktdump */
dump.pid = gnrc_pktdump_getpid();
dump.pid = gnrc_pktdump_pid;
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
if (dump.pid <= KERNEL_PID_UNDEF) {

View File

@ -35,7 +35,7 @@ int main(void)
puts("ZEP module test");
/* initialize and register pktdump */
dump.pid = gnrc_pktdump_getpid();
dump.pid = gnrc_pktdump_pid;
if (dump.pid <= KERNEL_PID_UNDEF) {
puts("Error starting pktdump thread");