]> rtime.felk.cvut.cz Git - rpp-test-sw.git/blob - rpp-test-sw/commands/cmd.c
Add testing tool iperf
[rpp-test-sw.git] / rpp-test-sw / commands / cmd.c
1 /*
2  * Copyright (C) 2012-2016 Czech Technical University in Prague
3  *
4  * Created on: 31.7.2012
5  *
6  * Authors:
7  *     - Michal Horn
8  *
9  * This document contains proprietary information belonging to Czech
10  * Technical University in Prague. Passing on and copying of this
11  * document, and communication of its contents is not permitted
12  * without prior written authorization.
13  *
14  * File : cmd.c
15  *
16  * Abstract:
17  *      This file contains root of the list of the commands.
18  *
19  */
20
21 /* Include files */
22 #include "cmdproc.h"
23 #include "cmd.h"
24 #include "cmd_adc.h"
25 #include "cmd_can.h"
26 #include "cmd_pin.h"
27 #include "cmd_port.h"
28 #include "cmd_nc.h"
29 #include "cmd_netstats.h"
30 #include "cmd_emac.h"
31 #include "cmd_echoserver.h"
32 #include "cmd_ping.h"
33 #include "cmd_iperf.h"
34
35 #ifdef TARGET_TMS570_RPP
36 #include "cmd_dac.h"
37 #include "cmd_fray.h"
38 #include "cmd_din.h"
39 #include "cmd_hbr.h"
40 #include "cmd_hout.h"
41 #include "cmd_lin.h"
42 #include "cmd_lout.h"
43 #include "cmd_mout.h"
44 #include "cmd_sdram.h"
45 #include "cmd_spi.h"
46 #include "cmd_vbat.h"
47 #include "cmd_motor_example.h"
48 #include "cmd_fr_basic_test.h"
49 #endif
50
51 #ifndef DOCGEN
52
53 #include "rpp/rpp.h"
54
55 #include <version.h>
56
57 int cmd_do_version(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
58 {
59         rpp_sci_printf("version=%s\n", GIT_VERSION);
60         return 0;
61 }
62
63 #endif  /* DOCGEN */
64
65 /** Root list in which commands are stored */
66 cmd_des_t const **cmd_list;
67
68 #ifdef TARGET_TMS570_RPP
69 int cmd_do_sleep(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
70 {
71 #ifndef DOCGEN
72         if (rpp_gio_set(PIN_CANNSTB, 1) == FAILURE) return -CMDERR_BADDIO;
73         if (rpp_gio_set(PIN_CANEN, 1) == FAILURE) return -CMDERR_BADDIO;
74         if (rpp_gio_set(PIN_LIN2NSLP, 1) == FAILURE) return -CMDERR_BADDIO;
75         if (rpp_gio_set(PIN_LIN1NSLP, 1) == FAILURE) return -CMDERR_BADDIO;
76         vTaskDelay(10/portTICK_RATE_MS);
77         if (rpp_gio_set(PIN_LIN2NSLP, 0) == FAILURE) return -CMDERR_BADDIO;
78         if (rpp_gio_set(PIN_LIN1NSLP, 0) == FAILURE) return -CMDERR_BADDIO;
79         if (rpp_gio_set(PIN_CANNSTB, 0) == FAILURE) return -CMDERR_BADDIO;
80 #endif
81         return 0;
82 }
83
84 /** Command descriptor for sleep command */
85 cmd_des_t const cmd_des_sleep = {
86                 0, 0,
87                 "sleep","Sleep the board",
88                 "### Syntax ###\n"
89                 "\n"
90                 " sleep\n"
91                 "\n"
92                 "### Description ###\n"
93                 "\n"
94                 "This command configures the LIN and CAN peripherals to enter sleep mode\n"
95                 "and turn the whole device into sleep mode. External signal on CAN or\n"
96                 "LIN will wake the device up.\n",
97                 CMD_HANDLER(cmd_do_sleep), (void *)&cmd_list
98 };
99 #endif
100
101 /** Command descriptor for show help command */
102 cmd_des_t const cmd_des_help = {
103         0, 0,
104         "help","Print help for commands",
105         "### Syntax ###\n"
106         "\n"
107         " help [command]\n"
108         "\n"
109         "### Description ###\n"
110         "\n"
111         "This command without parameter prints the list of all available\n"
112         "commands with short help text for each of them. If a parameter is\n"
113         "provided, the command prints a long description for given command.\n",
114         CMD_HANDLER(cmd_do_help), (void *)&cmd_list
115 };
116
117 cmd_des_t const cmd_des_version = {
118         0, 0,
119         "version","Print version of the software",
120         "### Syntax ###\n"
121         "\n"
122         " version\n"
123         "\n"
124         "### Description ###\n"
125         "\n"
126         "This command prints the version of the test software. The version\n"
127         "number is the output of 'git describe' command, i.e. it is composed\n"
128         "from the last tag in the git repository, the number of commits since\n"
129         "the tag and the abbreviated commit hash.\n"
130         "\n"
131         "### Example ###\n"
132         "\n"
133         "    --> version\n"
134         "    version=v0.2-109-ga81a9dd\n",
135         CMD_HANDLER(cmd_do_version),
136 };
137
138 /*  ------------------------
139  *  Command lists definitons
140  *  ------------------------
141  */
142
143 /** @brief Main list of commands */
144 cmd_des_t const *cmd_list_main[] = {
145         &cmd_des_help,
146 #ifdef TARGET_TMS570_RPP
147         &cmd_des_sleep,
148 #endif
149         &cmd_des_version,
150         CMD_DES_INCLUDE_SUBLIST(cmd_list_adc),
151         CMD_DES_INCLUDE_SUBLIST(cmd_list_can),
152         CMD_DES_INCLUDE_SUBLIST(cmd_list_emac),
153         CMD_DES_INCLUDE_SUBLIST(cmd_list_nc),
154         CMD_DES_INCLUDE_SUBLIST(cmd_list_es),
155         CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
156         CMD_DES_INCLUDE_SUBLIST(cmd_list_ping),
157         CMD_DES_INCLUDE_SUBLIST(cmd_list_iperf),
158 #ifdef TARGET_TMS570_RPP
159         CMD_DES_INCLUDE_SUBLIST(cmd_list_dac),
160         CMD_DES_INCLUDE_SUBLIST(cmd_list_din),
161         CMD_DES_INCLUDE_SUBLIST(cmd_list_fr_basic_test),
162         CMD_DES_INCLUDE_SUBLIST(cmd_list_fray),
163         CMD_DES_INCLUDE_SUBLIST(cmd_list_hbr),
164         CMD_DES_INCLUDE_SUBLIST(cmd_list_hout),
165         CMD_DES_INCLUDE_SUBLIST(cmd_list_lin),
166         CMD_DES_INCLUDE_SUBLIST(cmd_list_lout),
167         CMD_DES_INCLUDE_SUBLIST(cmd_list_mout),
168         CMD_DES_INCLUDE_SUBLIST(cmd_list_motor_example),
169 #endif
170         CMD_DES_INCLUDE_SUBLIST(cmd_list_pin),
171         CMD_DES_INCLUDE_SUBLIST(cmd_list_port),
172 #ifdef TARGET_TMS570_RPP
173         CMD_DES_INCLUDE_SUBLIST(cmd_list_sdram),
174         CMD_DES_INCLUDE_SUBLIST(cmd_list_spi),
175         CMD_DES_INCLUDE_SUBLIST(cmd_list_vbat),
176 #endif
177         NULL
178 };
179
180 /** Pointer to the root list */
181 cmd_des_t const **cmd_list = cmd_list_main;