]> rtime.felk.cvut.cz Git - rpp-test-sw.git/blob - rpp-test-sw/commands/cmd.c
cmd: Add echoserver functionality and command
[rpp-test-sw.git] / rpp-test-sw / commands / cmd.c
1 /*
2  * Copyright (C) 2012-2013 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_dac.h"
26 #include "cmd_emac.h"
27 #include "cmd_fray.h"
28 #include "cmd_can.h"
29 #include "cmd_din.h"
30 #include "cmd_hbr.h"
31 #include "cmd_hout.h"
32 #include "cmd_lin.h"
33 #include "cmd_lout.h"
34 #include "cmd_nc.h"
35 #include "cmd_echoserver.h"
36 #include "cmd_netstats.h"
37 #include "cmd_pin.h"
38 #include "cmd_port.h"
39 #include "cmd_sdram.h"
40 #include "cmd_spi.h"
41 #include "cmd_vbat.h"
42 #include "cmd_motor_example.h"
43 #include "cmd_fr_basic_test.h"
44
45 #ifndef DOCGEN
46
47 #include "rpp/rpp.h"
48 #include "hal/hal.h"
49
50
51 /**
52  *  @brief      Sleep the board
53  *
54  * @param[in]   cmd_io  Pointer to IO stack
55  * @param[in]   des             Pointer to command descriptor
56  * @param[in]   param   Parameters of command
57  * @return      0 when OK or error code
58  */
59 int cmd_do_sleep(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
60 {
61         hal_gpio_pin_set_value(PIN_DSC_CANNSTB, 1);
62         hal_gpio_pin_set_value(PIN_DSC_CANEN, 1);
63         hal_gpio_pin_set_value(PIN_DSC_LIN2NSLP, 1);
64         hal_gpio_pin_set_value(PIN_DSC_LIN1NSLP, 1);
65         vTaskDelay(10/portTICK_RATE_MS);
66         hal_gpio_pin_set_value(PIN_DSC_LIN2NSLP, 0);
67         hal_gpio_pin_set_value(PIN_DSC_LIN1NSLP, 0);
68         hal_gpio_pin_set_value(PIN_DSC_CANNSTB, 0);
69         return 0;
70 }
71
72 #include <version.h>
73
74 int cmd_do_version(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
75 {
76         rpp_sci_printf("version=%s\n", GIT_VERSION);
77         return 0;
78 }
79
80 #endif  /* DOCGEN */
81
82 /** Root list in which commands are stored */
83 cmd_des_t const **cmd_list;
84
85 /** Command descriptor for sleep command */
86 cmd_des_t const cmd_des_sleep = {
87         0, 0,
88         "sleep","Sleep the board",
89         "### Syntax ###\n"
90         "\n"
91         " sleep\n"
92         "\n"
93         "### Description ###\n"
94         "\n"
95         "This command configures the LIN and CAN peripherals to enter sleep mode\n"
96         "and turn the whole device into sleep mode. External signal on CAN or\n"
97         "LIN will wake the device up.\n",
98         CMD_HANDLER(cmd_do_sleep), (void *)&cmd_list
99 };
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         &cmd_des_sleep,
147         &cmd_des_version,
148         CMD_DES_INCLUDE_SUBLIST(cmd_list_adc),
149         CMD_DES_INCLUDE_SUBLIST(cmd_list_can),
150         CMD_DES_INCLUDE_SUBLIST(cmd_list_dac),
151         CMD_DES_INCLUDE_SUBLIST(cmd_list_din),
152         CMD_DES_INCLUDE_SUBLIST(cmd_list_emac),
153         CMD_DES_INCLUDE_SUBLIST(cmd_list_fray),
154         CMD_DES_INCLUDE_SUBLIST(cmd_list_hbr),
155         CMD_DES_INCLUDE_SUBLIST(cmd_list_hout),
156         CMD_DES_INCLUDE_SUBLIST(cmd_list_lin),
157         CMD_DES_INCLUDE_SUBLIST(cmd_list_lout),
158         CMD_DES_INCLUDE_SUBLIST(cmd_list_nc),
159         CMD_DES_INCLUDE_SUBLIST(cmd_list_es),
160         CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
161         CMD_DES_INCLUDE_SUBLIST(cmd_list_pin),
162         CMD_DES_INCLUDE_SUBLIST(cmd_list_port),
163         CMD_DES_INCLUDE_SUBLIST(cmd_list_sdram),
164         CMD_DES_INCLUDE_SUBLIST(cmd_list_spi),
165         CMD_DES_INCLUDE_SUBLIST(cmd_list_vbat),
166         CMD_DES_INCLUDE_SUBLIST(cmd_list_motor_example),
167         CMD_DES_INCLUDE_SUBLIST(cmd_list_fr_basic_test),
168         NULL
169 };
170
171 /** Pointer to the root list */
172 cmd_des_t const **cmd_list = cmd_list_main;