2 * Copyright (C) 2012-2013, 2016 Czech Technical University in Prague
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use,
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
28 * This file contains commands for testing MOUT
39 #include "cmdproc_utils.h"
41 int cmd_do_mout_set(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
49 if (sscanf(p, "%d %d %1s", &pin, &val, spareParams) != 2)
50 return -CMDERR_BADPAR;
51 ret = rpp_mout_set(pin, val);
53 rpp_sci_printf("Pin out of range.\n");
54 return -CMDERR_BADPAR;
58 rpp_sci_printf("MOUT set failed.\n");
62 return cmd_opchar_replong(cmd_io, param, val, 0, 10);
65 int cmd_do_mout_diag(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
72 if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
73 return -CMDERR_BADPAR;
75 ret = rpp_mout_diag(pin);
77 rpp_sci_printf("Pin out of range.\n");
78 return -CMDERR_BADPAR;
81 rpp_sci_printf("moutdiag%d=%d\n", pin, ret);
87 /** Command descriptor for mout set port value */
88 cmd_des_t const cmd_des_mout_set = {
90 "moutset*","Set a value of the MOUT pin",
91 "### Command syntax ###\n"
93 " moutset<PIN> <VALUE>\n"
96 "- `<PIN>` is a number in range 1-6\n"
97 "- `<VALUE>` is a binary value to be set (0 or 1)\n"
99 "### Description ###\n"
101 "The command sets the digital value on the MOUT pin.\n"
113 "Sets MOUT2 to 0.\n",
114 CMD_HANDLER(cmd_do_mout_set), (void *)&cmd_list_mout
117 /** Command descriptor for mout get pin diag value */
118 cmd_des_t const cmd_des_mout_diag = {
120 "moutdiag*","Read a diagnostic value from an MOUT pin",
121 "### Command syntax ###\n"
125 "where `<PIN>` is a number in range 1-8\n"
127 "### Description ###\n"
129 "The command reads a logical value of the MOUT diagnostic signal.\n"
135 "Reads value of the MOUT1 diagnostic signal.\n",
136 CMD_HANDLER(cmd_do_mout_diag), (void *)&cmd_list_mout
140 /** List of commands for hout, defined as external */
141 cmd_des_t const *cmd_list_mout[] = {