4 * Created on: 31.7.2012
7 * Definition of commands for cmdProc library. Command are stored as lists.
12 #include "sys_common.h"
13 #include "cmdio_tisci.h"
17 cmd_des_t const **cmd_list;
19 /* ------------------------------
20 * User defined command functions
21 * ------------------------------
23 int cmd_do_testopchar(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
27 opchar=cmd_opchar_check(cmd_io,des,param);
28 if(opchar<0) return opchar;
29 char str[] = {"\r\ncmd_do_testopchar called\r\nparam[0]="};
31 print((uint8_t *)str);
32 print((uint8_t *)param[0]);
33 print((uint8_t *)"\r\nparam[1]=");
34 print((uint8_t *)param[1]);
35 print((uint8_t *)"\r\nparam[2]=");
36 print((uint8_t *)param[2]);
37 print((uint8_t *)"\r\nparam[3]=");
38 print((uint8_t *)param[3]);
39 print((uint8_t *)"\r\nopchar=");
41 i2str(opcharBuf, opchar, 1, 10);
42 print((uint8_t *)opcharBuf);
43 print((uint8_t *)"\r\n");
47 int cmd_do_testparam(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
50 char str[] = {"cmd_do_testparam called\r\nparam[0]="};
52 print((uint8_t *)str);
53 print((uint8_t *)param[0]);
54 print((uint8_t *)"\r\nparam[1]=");
55 print((uint8_t *)param[1]);
56 print((uint8_t *)"\r\nparam[2]=");
57 print((uint8_t *)param[2]);
58 print((uint8_t *)"\r\n");
63 int cmd_do_testerror(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
68 int cmd_do_test(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
70 char str[] = {"This is the simplest command\r\n"};
71 print((uint8_t *)str);
76 int cmd_do_testcmdio(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
78 cmd_io_puts(cmd_io, "The first line of text\r\n");
79 cmd_io_puts(cmd_io, "The second line of text\r\n");
82 for (i = 0; i < 1000; i++) {
86 print((uint8_t *)str);
87 /* Only ED_LINE_CHARS character can be sent. */
92 /* ------------------------------
93 * User defined command variables
94 * ------------------------------
98 /* -------------------
100 * -------------------
102 cmd_des_t const cmd_des_help={
104 "HELP","prints help for commands\r\n",
105 cmd_do_help, (void *)&cmd_list
108 cmd_des_t const cmd_des_val={
109 0, CDESM_OPCHR|CDESM_RW,
110 "VAL","use ':' or '?' to store/read value of an integer variable",
111 cmd_do_rw_int, (void *)&val};
113 cmd_des_t const cmd_des_valro={
114 0, CDESM_OPCHR|CDESM_RD,
115 "VALRO","read only access to an integer variable",
116 cmd_do_rw_int, (void *)&val};
118 cmd_des_t const cmd_des_valwo={
119 0, CDESM_OPCHR|CDESM_WR,
120 "VALWO","write only access to an integer variable",
121 cmd_do_rw_int, (void *)&val};
123 cmd_des_t const cmd_des_opchar_test={
124 0, CDESM_OPCHR|CDESM_RW,
125 "OPCHAR","opchar test (use ':' or '?' as suffix)",
128 cmd_des_t const cmd_des_testio={
130 "TESTIO","test of cmd_io inside functions (universal way to print results)",
133 cmd_des_t const cmd_des_error={
135 "TESTERROR","should produce an error",
138 cmd_des_t const cmd_des_param={
140 "PARAM","test of parameters",
143 cmd_des_t const cmd_des_opchar_testro={
144 0, CDESM_OPCHR|CDESM_RD,
145 "OPCHARRO","opchar test (only '?' is allowed)",
148 cmd_des_t const cmd_des_test={
150 "TEST","the simplest command",
153 cmd_des_t const cmd_des_prefix={
155 "PREFIX*","suffix of the command is supplied as a parametr",
158 cmd_des_t const cmd_des_num={
160 "NUM##","suffix of the command (two digits) is supplied as a parametr",
163 cmd_des_t const cmd_des_char={
165 "CHAR?","suffix of the command (one character) is supplied as a parametr",
168 cmd_des_t const cmd_des_charmid={
170 "CHAR?MID","middle character of the command is supplied as a parametr",
173 cmd_des_t const cmd_des_hiddedn={
175 "HIDDEN","should not be available",
178 /* ------------------------
179 * Command lists definitons
180 * ------------------------
182 cmd_des_t const *cmd_list_1[]={
186 &cmd_des_opchar_test,
187 &cmd_des_opchar_testro,
191 cmd_des_t const *cmd_list_2[]={
202 cmd_des_t const *cmd_list_main[]={
205 CMD_DES_INCLUDE_SUBLIST(cmd_list_1),
206 CMD_DES_CONTINUE_AT(cmd_list_2),
211 cmd_des_t const **cmd_list = cmd_list_main;