/*
- * Copyright (C) 2012-2015 Czech Technical University in Prague
+ * Copyright (C) 2012-2016 Czech Technical University in Prague
*
* Created on: 31.7.2012
*
#include "cmd_hout.h"
#include "cmd_lin.h"
#include "cmd_lout.h"
+#include "cmd_mout.h"
#include "cmd_nc.h"
#include "cmd_echoserver.h"
#include "cmd_netstats.h"
CMD_DES_INCLUDE_SUBLIST(cmd_list_hout),
CMD_DES_INCLUDE_SUBLIST(cmd_list_lin),
CMD_DES_INCLUDE_SUBLIST(cmd_list_lout),
+ CMD_DES_INCLUDE_SUBLIST(cmd_list_mout),
CMD_DES_INCLUDE_SUBLIST(cmd_list_motor_example),
CMD_DES_INCLUDE_SUBLIST(cmd_list_nc),
CMD_DES_INCLUDE_SUBLIST(cmd_list_es),
--- /dev/null
+/*
+ * Copyright (C) 2012-2013, 2016 Czech Technical University in Prague
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ * File : cmd_mout.c
+ *
+ * Abstract:
+ * This file contains commands for testing MOUT
+ *
+ */
+
+
+#include "cmd_mout.h"
+#include "stdio.h"
+
+#ifndef DOCGEN
+
+#include "rpp/rpp.h"
+#include "cmdproc_utils.h"
+
+int cmd_do_mout_set(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+ int pin;
+ char *p = param[1];
+ char spareParams[2];
+ int val;
+ int ret;
+
+ if (sscanf(p, "%d %d %1s", &pin, &val, spareParams) != 2)
+ return -CMDERR_BADPAR;
+ ret = rpp_mout_set(pin, val);
+ if (ret == -1) {
+ rpp_sci_printf("Pin out of range.\n");
+ return -CMDERR_BADPAR;
+ }
+
+ if (ret != SUCCESS) {
+ rpp_sci_printf("MOUT set failed.\n");
+ return -CMDERR_EIO;
+ }
+
+ return cmd_opchar_replong(cmd_io, param, val, 0, 10);
+}
+
+int cmd_do_mout_diag(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+ int pin;
+ char *p = param[1];
+ char spareParams[2];
+ int ret;
+
+ if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
+ return -CMDERR_BADPAR;
+
+ ret = rpp_mout_diag(pin);
+ if (ret < 0) {
+ rpp_sci_printf("Pin out of range.\n");
+ return -CMDERR_BADPAR;
+ }
+
+ rpp_sci_printf("moutdiag%d=%d\n", pin, ret);
+ return 0;
+}
+
+#endif /* DOCGEN */
+
+/** Command descriptor for mout set port value */
+cmd_des_t const cmd_des_mout_set = {
+ 0, 0,
+ "moutset*","Set a value of the MOUT pin",
+ "### Command syntax ###\n"
+ "\n"
+ " moutset<PIN> <VALUE>\n"
+ "where\n"
+ "\n"
+ "- `<PIN>` is a number in range 1-6\n"
+ "- `<VALUE>` is a binary value to be set (0 or 1)\n"
+ "\n"
+ "### Description ###\n"
+ "\n"
+ "The command sets the digital value on the MOUT pin.\n"
+ "\n"
+ "### Example ###\n"
+ "\n"
+ " --> moutset1 1\n"
+ " moutset1 =1\n"
+ "\n"
+ "Sets MOUT1 to 1.\n"
+ "\n"
+ " --> moutset2 0\n"
+ " moutset2 =0\n"
+ "\n"
+ "Sets MOUT2 to 0.\n",
+ CMD_HANDLER(cmd_do_mout_set), (void *)&cmd_list_mout
+};
+
+/** Command descriptor for mout get pin diag value */
+cmd_des_t const cmd_des_mout_diag = {
+ 0, 0,
+ "moutdiag*","Read a diagnostic value from an MOUT pin",
+ "### Command syntax ###\n"
+ "\n"
+ " moutdiag<PIN>\n"
+ "\n"
+ "where `<PIN>` is a number in range 1-8\n"
+ "\n"
+ "### Description ###\n"
+ "\n"
+ "The command reads a logical value of the MOUT diagnostic signal.\n"
+ "\n"
+ "### Example ###\n"
+ "\n"
+ " --> moutdiag1\n"
+ "\n"
+ "Reads value of the MOUT1 diagnostic signal.\n",
+ CMD_HANDLER(cmd_do_mout_diag), (void *)&cmd_list_mout
+};
+
+
+/** List of commands for hout, defined as external */
+cmd_des_t const *cmd_list_mout[] = {
+ &cmd_des_mout_set,
+ &cmd_des_mout_diag,
+ NULL
+};
--- /dev/null
+/*
+ * Copyright (C) 2016 Czech Technical University in Prague
+ *
+ * Authors:
+ * - Michal Sojka <sojkam1@fel.cvut.cz>
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ */
+
+#ifndef COMMANDS_CMD_MOUT_H
+#define COMMANDS_CMD_MOUT_H
+
+#include "cmdproc.h"
+
+extern cmd_des_t const *cmd_list_mout[];
+
+#endif