| | 1 | = Hello World = |
| | 2 | |
| | 3 | Hello world is the basic useless example. It tends to prove you have a complete working setup. |
| | 4 | |
| | 5 | This example will print "Hello world !" message infinitely repeated (due tu DsxThreads). |
| | 6 | |
| | 7 | == Task == |
| | 8 | |
| | 9 | First we will create our task and declare it. |
| | 10 | |
| | 11 | hello.c: |
| | 12 | |
| | 13 | {{{ |
| | 14 | #include <dsx.h> |
| | 15 | #include "hello_proto.h" |
| | 16 | |
| | 17 | FUNC(hello) { |
| | 18 | dsx_log_printf(NONE, "Hello world!\n"); |
| | 19 | } |
| | 20 | }}} |
| | 21 | |
| | 22 | Task description in dsx's API: |
| | 23 | |
| | 24 | {{{ |
| | 25 | hello_task = TaskModel( |
| | 26 | 'hello', |
| | 27 | impl = [ |
| | 28 | SwTask('hello', stack_size = 128, sources = ['hello.c']) |
| | 29 | ] ) |
| | 30 | }}} |
| | 31 | |
| | 32 | == Test under Posix == |
| | 33 | |
| | 34 | Let's create a task graph containing only this one. |
| | 35 | |
| | 36 | {{{ |
| | 37 | tcg = Tcg( Task('hello', hello_task) |
| | 38 | ) |
| | 39 | }}} |
| | 40 | |
| | 41 | And let's create Posix test application (and also a TopMakefile): |
| | 42 | |
| | 43 | {{{ |
| | 44 | px = Posix() |
| | 45 | |
| | 46 | tcg.generate(px) |
| | 47 | TopMakefile(px) |
| | 48 | }}} |
| | 49 | |
| | 50 | Now we can compile and launch it. |
| | 51 | |
| | 52 | {{{ |
| | 53 | $ make |
| | 54 | [...] |
| | 55 | $ ./exe.posix |
| | 56 | Hello world! |
| | 57 | Hello world! |
| | 58 | Hello world! |
| | 59 | Hello world! |
| | 60 | Hello world! |
| | 61 | Hello world! |
| | 62 | Hello world! |
| | 63 | Hello world! |
| | 64 | ^C |
| | 65 | $ |
| | 66 | }}} |
| | 67 | |
| | 68 | It works ! |