*/
#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;
}
/**
* @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) {
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;
}
/**
/** 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"
"\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"
/** 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"
"\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",