From: Michal Sojka Date: Wed, 13 Apr 2016 15:32:51 +0000 (+0200) Subject: Add MOUT commands X-Git-Url: http://rtime.felk.cvut.cz/gitweb/pes-rpp/rpp-test-sw.git/commitdiff_plain/a9139dba590c3902d731f57310cb8ddf12724da1 Add MOUT commands 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 --- diff --git a/rpp-lib b/rpp-lib index df67e66..5572fa3 160000 --- a/rpp-lib +++ b/rpp-lib @@ -1 +1 @@ -Subproject commit df67e668b0bbfd7bb543ea62780753422411923c +Subproject commit 5572fa344e3f4d25e66f5d02471d07d9592a35d7 diff --git a/rpp-test-sw/Makefile.var b/rpp-test-sw/Makefile.var index ec601a3..f61291f 100644 --- a/rpp-test-sw/Makefile.var +++ b/rpp-test-sw/Makefile.var @@ -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 \ diff --git a/rpp-test-sw/commands/cmd.c b/rpp-test-sw/commands/cmd.c index 8326d5b..982d454 100644 --- a/rpp-test-sw/commands/cmd.c +++ b/rpp-test-sw/commands/cmd.c @@ -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 index 0000000..c8ab76a --- /dev/null +++ b/rpp-test-sw/commands/cmd_mout.c @@ -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 \n" + "where\n" + "\n" + "- `` is a number in range 1-6\n" + "- `` 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\n" + "\n" + "where `` 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 index 0000000..8926681 --- /dev/null +++ b/rpp-test-sw/commands/cmd_mout.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2016 Czech Technical University in Prague + * + * Authors: + * - Michal Sojka + * + * 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