mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2026-01-01 01:41:18 +01:00
Merge pull request #1171 from haukepetersen/example_ipcpingpong_readme
examples: added README.md to ipc_pingpong example
This commit is contained in:
commit
bdad2ba997
38
examples/ipc_pingpong/README.md
Normal file
38
examples/ipc_pingpong/README.md
Normal file
@ -0,0 +1,38 @@
|
||||
IPC Pingpong!
|
||||
=============
|
||||
|
||||
This example is to illustrate the usage of RIOTs IPC messaging system.
|
||||
|
||||
The application starts a second thread (in addition to the main thread) and sends messages between
|
||||
these two threads. The main thread calls `thread_send_receive()` in an endless loop. The second
|
||||
thread receives the message, prints `2nd: got msg from x` to stdout and sends a reply message with
|
||||
an incrementing number back to the main thread. The main thread then prints the number it received
|
||||
from the 2nd thread.
|
||||
|
||||
The correct output should look like this:
|
||||
```
|
||||
This is RIOT! (Version: xxx)
|
||||
kernel_init(): jumping into first task...
|
||||
Starting IPC Ping-pong example...
|
||||
1st thread started, pid: 1
|
||||
2nd thread started, pid: 2
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 2
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 3
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 4
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 5
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 6
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 7
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 8
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 9
|
||||
2nd: Got msg from 1
|
||||
1st: Got msg with content 10
|
||||
[...]
|
||||
```
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Freie Universität Berlin
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
*
|
||||
* 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
|
||||
@ -14,6 +14,7 @@
|
||||
* @brief IPC pingpong application
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
@ -26,12 +27,12 @@
|
||||
|
||||
void second_thread(void)
|
||||
{
|
||||
printf("second_thread starting.\n");
|
||||
printf("2nd thread started, pid: %i\n", thread_getpid());
|
||||
msg_t m;
|
||||
|
||||
while (1) {
|
||||
msg_receive(&m);
|
||||
printf("2nd: got msg from %i\n", m.sender_pid);
|
||||
printf("2nd: Got msg from %i\n", m.sender_pid);
|
||||
m.content.value++;
|
||||
msg_reply(&m, &m);
|
||||
}
|
||||
@ -41,7 +42,8 @@ char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
printf("Starting IPC Ping-pong example...\n");
|
||||
printf("1st thread started, pid: %i\n", thread_getpid());
|
||||
|
||||
msg_t m;
|
||||
|
||||
@ -53,6 +55,6 @@ int main(void)
|
||||
|
||||
while (1) {
|
||||
msg_send_receive(&m, &m, pid);
|
||||
printf("Got msg with content %u\n", m.content.value);
|
||||
printf("1st: Got msg with content %u\n", (unsigned int)m.content.value);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user