]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
Add MOUT commands
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 13 Apr 2016 15:32:51 +0000 (17:32 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 13 Apr 2016 15:32:51 +0000 (17:32 +0200)
The commands work, but the pin voltage does not change and diag signals
a fault. Probably, the pin driving EN signal is not set to 1. This needs
to be fixed later.

Fixes #1580

rpp-lib
rpp-test-sw/Makefile.var
rpp-test-sw/commands/cmd.c
rpp-test-sw/commands/cmd_mout.c [new file with mode: 0644]
rpp-test-sw/commands/cmd_mout.h [new file with mode: 0644]

diff --git a/rpp-lib b/rpp-lib
index df67e668b0bbfd7bb543ea62780753422411923c..5572fa344e3f4d25e66f5d02471d07d9592a35d7 160000 (submodule)
--- a/rpp-lib
+++ b/rpp-lib
@@ -1 +1 @@
-Subproject commit df67e668b0bbfd7bb543ea62780753422411923c
+Subproject commit 5572fa344e3f4d25e66f5d02471d07d9592a35d7
index ec601a3eb2678a3148f596456ba20611a0de083d..f61291f3a4c86ebf67039ed1730cbee181a8a963 100644 (file)
@@ -25,6 +25,7 @@ SOURCES_tms570_rpp = \
        commands/cmd_hout.c \
        commands/cmd_lin.c \
        commands/cmd_lout.c \
+       commands/cmd_mout.c \
        commands/cmd_motor_example.c \
        commands/cmd_nc.c \
        commands/cmd_netstats.c \
index 8326d5b97caace3556da35771ea77449ffea8ded..982d45401c5c49409e727b76098e04507f038fc9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2015 Czech Technical University in Prague
+ * Copyright (C) 2012-2016 Czech Technical University in Prague
  *
  * Created on: 31.7.2012
  *
@@ -35,6 +35,7 @@
 #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"
@@ -156,6 +157,7 @@ cmd_des_t const *cmd_list_main[] = {
        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),
diff --git a/rpp-test-sw/commands/cmd_mout.c b/rpp-test-sw/commands/cmd_mout.c
new file mode 100644 (file)
index 0000000..c8ab76a
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * 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
+};
diff --git a/rpp-test-sw/commands/cmd_mout.h b/rpp-test-sw/commands/cmd_mout.h
new file mode 100644 (file)
index 0000000..8926681
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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