mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests: add test that shows sequence of received messages
This commit is contained in:
parent
049838841a
commit
6bc9ad69c3
4
tests/test_thread_msg_seq/Makefile
Normal file
4
tests/test_thread_msg_seq/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
export PROJECT = test_thread_msg_seq
|
||||
include ../Makefile.tests_common
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
65
tests/test_thread_msg_seq/main.c
Normal file
65
tests/test_thread_msg_seq/main.c
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Christian Mehlis <mehlis@inf.fu-berlin.de>
|
||||
* (C) 2014 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Thread test application
|
||||
*
|
||||
* @author Christian Mehlis <mehlis@inf.fu-berlin.de>
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "msg.h"
|
||||
|
||||
char t1_stack[KERNEL_CONF_STACKSIZE_PRINTF];
|
||||
char t2_stack[KERNEL_CONF_STACKSIZE_PRINTF];
|
||||
char t3_stack[KERNEL_CONF_STACKSIZE_PRINTF];
|
||||
|
||||
uint16_t p1, p2, p3;
|
||||
|
||||
void sub_thread(void)
|
||||
{
|
||||
int pid = thread_getpid();
|
||||
printf("THREAD %s (pid:%i) start\n", thread_getname(pid), pid);
|
||||
|
||||
msg_t msg;
|
||||
|
||||
msg.content.ptr = (char*)thread_getname(pid);
|
||||
|
||||
msg_send(&msg, 1, 1);
|
||||
|
||||
printf("THREAD %s (pid:%i) end.\n", thread_getname(pid), pid);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
msg_t msg;
|
||||
|
||||
p1 = thread_create(t1_stack, KERNEL_CONF_STACKSIZE_PRINTF, PRIORITY_MAIN - 1,
|
||||
CREATE_WOUT_YIELD | CREATE_STACKTEST, sub_thread, "nr1");
|
||||
p2 = thread_create(t2_stack, KERNEL_CONF_STACKSIZE_PRINTF, PRIORITY_MAIN - 1,
|
||||
CREATE_WOUT_YIELD | CREATE_STACKTEST, sub_thread, "nr2");
|
||||
p3 = thread_create(t3_stack, KERNEL_CONF_STACKSIZE_PRINTF, PRIORITY_MAIN - 1,
|
||||
CREATE_WOUT_YIELD | CREATE_STACKTEST, sub_thread, "nr3");
|
||||
|
||||
puts("THREADS CREATED\n");
|
||||
for(int i = 0; i < 3; i++) {
|
||||
msg_receive(&msg);
|
||||
printf("Got msg from pid %i: \"%s\"\n", msg.sender_pid, msg.content.ptr);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user