]> rtime.felk.cvut.cz Git - rpp-test-sw.git/commitdiff
HBR commands syntax changed to avoid character :
authorMichal Horn <hornmich@fel.cvut.cz>
Thu, 1 Aug 2013 13:52:33 +0000 (15:52 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Thu, 1 Aug 2013 13:52:33 +0000 (15:52 +0200)
commands/cmd_hbr.c

index 77e404e588faa061036bd814efed88b8cd498b1f..e6c59bae2f6b4df80e32eaecd3d32b1a215f9035 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include "cmd_hbr.h"
+#include "stdio.h"
 
 #ifndef DOCGEN
 
  * @return     0 when OK or error code
  */
 int cmd_do_hbr_enable(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
-       char *p;
-       int opchar;
        uint32_t period;
        int ret;
+       char *p=param[1];
+       char spareParams;
 
-       if((opchar=cmd_opchar_check(cmd_io,des,param)) < 0)
-               return opchar;
-       p = param[3];
-       if(si_long(&p,(long*)&period, 0) < 0)
+       if (sscanf(p, "%d %1s", &period, &spareParams) != 1) {
                return -CMDERR_BADPAR;
+       }
 
        ret = rpp_hbr_enable(period);
        if (ret == FAILURE) {
                rpp_sci_printf("Enable procedure failed.\n");
        }
 
-       return cmd_opchar_replong(cmd_io, param, period, 0, 10);
+       rpp_sci_printf("hbrenable=%d\n", period, ret);
+       return 0;
 }
 
 /**
@@ -72,16 +72,14 @@ int cmd_do_hbr_enable(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]
  * @return     0 when OK or error code
  */
 int cmd_do_hbr_control(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
-       char *p;
-       int opchar;
        int cmd;
        int ret;
+       char *p=param[1];
+       char spareParams;
 
-       if((opchar=cmd_opchar_check(cmd_io,des,param)) < 0)
-               return opchar;
-       p = param[3];
-       if(si_long(&p,(long*)&cmd, 0) < 0)
+       if (sscanf(p, "%d %1s", &cmd, &spareParams) != 1) {
                return -CMDERR_BADPAR;
+       }
 
        ret = rpp_hbr_control((double)cmd/(double)100);
        if (ret == -1) {
@@ -92,7 +90,8 @@ int cmd_do_hbr_control(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
                rpp_sci_printf("Command out of range.\n");
                return -CMDERR_BADPAR;
        }
-       return cmd_opchar_replong(cmd_io, param, cmd, 0, 10);
+       rpp_sci_printf("hbrcontrol=%d\n", cmd, ret);
+       return 0;
 }
 
 /**
@@ -116,11 +115,11 @@ int cmd_do_hbr_disable(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
 
 /** Command descriptor for HBR enable command */
 cmd_des_t const cmd_des_hbr_enable = {
-    0, CDESM_OPCHR|CDESM_WR,
-    "hbrenable","Enable the H-bridge and set its PWM period",
+    0, 0,
+    "hbrenable*","Enable the H-bridge and set its PWM period",
     "=== Command syntax ===\n"
     "\n"
-    "   hbrenable:<PER>\n"
+    "   hbrenable<PER>\n"
     "\n"
     "where <PER> is PWM period in microseconds.\n"
     "\n"
@@ -137,7 +136,7 @@ cmd_des_t const cmd_des_hbr_enable = {
     "\n"
     "=== Example ===\n"
     "\n"
-    "   --> hbrenable:1000\n"
+    "   --> hbrenable1000\n"
     "   hbrenable=1000\n"
     "\n"
     "Enables HBR with period 1kHz. HBR output is still inactive, but ready\n"
@@ -147,11 +146,11 @@ cmd_des_t const cmd_des_hbr_enable = {
 
 /** Command descriptor for HBR control command */
 cmd_des_t const cmd_des_hbr_control = {
-    0, CDESM_OPCHR|CDESM_WR,
-    "hbrcontrol","Set the motor voltage direction and size in percent",
+    0, 0,
+    "hbrcontrol*","Set the motor voltage direction and size in percent",
     "=== Command syntax ===\n"
     "\n"
-    "   hbrcontrol:<SPEED>\n"
+    "   hbrcontrol<SPEED>\n"
     "\n"
     "where <SPEED> specifies direction and PWM duty cycle in percent (a\n"
     "number in range -100, 100).\n"
@@ -166,17 +165,17 @@ cmd_des_t const cmd_des_hbr_control = {
     "\n"
     "=== Example ===\n"
     "\n"
-    "   --> hbrcontrol:-25\n"
+    "   --> hbrcontrol-25\n"
     "   hbrcontrol=-25\n"
     "\n"
     "Rotates the motor to the left with 25% speed.\n"
     "\n"
-    "   --> hbrcontrol:25\n"
+    "   --> hbrcontrol25\n"
     "   hbrcontrol=25\n"
     "\n"
     "Rotates the motor to the right with 25% speed.\n"
     "\n"
-    "   --> hbrcontrol:0\n"
+    "   --> hbrcontrol0\n"
     "   hbrcontrol=0\n"
     "\n"
     "Stops the motor.\n",