|
54 | 54 | * cmd_exe( "dymmy;long" );
|
55 | 55 | * }
|
56 | 56 | * \endcode
|
57 |
| - * \startuml {cli_usecase.png} |
58 |
| - actor user |
59 |
| - participant app |
60 |
| - participant cli |
61 |
| - participant mycmd |
62 |
| -
|
63 |
| - == Initialization == |
64 |
| - * app -> cli: cmd_init( &default_cmd_response_out ) |
65 |
| - note right : This initialize command line library |
66 |
| - * mycmd -> cli: cmd_add( mycmd_command, "mycmd", NULL, NULL) |
67 |
| - note right : All commands have to be register \nto cmdline library with cmd_add() function |
68 |
| -
|
69 |
| - == command input characters== |
70 |
| - * app -> cli: cmd_char_input("d") |
71 |
| - * app -> cli: cmd_char_input("u") |
72 |
| - * app -> cli: cmd_char_input("m") |
73 |
| - * app -> cli: cmd_char_input("m") |
74 |
| - * app -> cli: cmd_char_input("y") |
75 |
| - * app -> cli: cmd_char_input("\\n") |
76 |
| - note left : User write command to \nbe execute and press ENTER when \ncommand with all parameters are ready.\nCharacters can be come from serial port for example. |
77 |
| - == command execution== |
78 |
| - * mycmd <- cli: mycmd_command(argc, argv) |
79 |
| - * mycmd -> cli: cmd_printf("hello world!\\n") |
80 |
| - note right : cmd_printf() should \nbe used when command prints \nsomething to the console |
81 |
| - * cli -> user: "hello world!\\n" |
82 |
| - * mycmd -> cli: <<retcode>> |
83 |
| - == finish command and goto forward == |
84 |
| - * app <- cli: cmd_ready_cb() |
85 |
| - * app -> cli: cmd_next() |
86 |
| - note left : this way application can \ndecide when/how to go forward.\nWhen using event-loop, \nyou probably want create tasklet where \ncommands are actually executed.\nif there are some commands in queue cmd_next()\nstart directly next command execution.\n |
87 |
| - == command execution== |
88 |
| - * app -> cli: cmd_exe("long\\n") |
89 |
| - note left : input string can be \ngive also with cmd_exe() -function |
90 |
| - * mycmd <- cli: long_command(argc, argv) |
91 |
| - * mycmd -> cli: <<retcode>> = CMDLINE_RETCODE_EXECUTING_CONTINUE |
92 |
| - note right : When command continue in background, it should return\nCMDLINE_RETCODE_EXECUTING_CONTINUE.\nCommand interpreter not continue next command \nas long as cmd_ready() -function is not called. |
93 |
| - ... Some ~~long delay~~ ... |
94 |
| - * mycmd -> cli: cmd_ready( <<retcode>> ) |
95 |
| - note right : When command is finally finished,\nit should call cmd_ready() function. |
96 |
| - == finish command and goto forward == |
97 |
| - * app <- cli: cmd_ready_cb() |
98 |
| - * app -> cli: cmd_next() |
99 |
| - ... ... |
100 |
| - * \enduml |
101 | 57 | */
|
102 | 58 | #ifndef _CMDLINE_H_
|
103 | 59 | #define _CMDLINE_H_
|
|
0 commit comments