/*
- * Copyright (C) 2012-2013, 2015 Czech Technical University in Prague
+ * Copyright (C) 2012-2013, 2015, 2016 Czech Technical University in Prague
*
* Created on: 28.2.2013
*
* Authors:
* - Michal Horn
*
- * 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.
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*
* File : cmd_hout.c
*
{
uint32_t i;
const struct port_desc *port = &port_desc[PORT_ID_HOUTIFBK];
- uint16_t values[port->numchn];
+ uint16_t values[6];
int ret;
+ assert(ARRAY_SIZE(values) == port->numchn);
ret = port->get(port, values, sizeof(values));
if (ret < 0)
{
int pin;
char *p = param[1];
- char spareParams;
+ char spareParams[2];
- if (sscanf(p, "%d %1s", &pin, &spareParams) != 1)
+ if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
return -CMDERR_BADPAR;
pin--;
if (pin < 0 || pin > 5) return -CMDERR_BADPAR;
{
char *p;
uint32_t values[MAX_PARAM_VALUES_NUM];
- char spareParams;
+ char spareParams[2];
int pin;
p = param[1];
if (param[2] != NULL) { // More parameters = set values
p = param[2];
- if (sscanf(p, "%d %d %1s", &values[0], &values[1], &spareParams) != 2)
+ if (sscanf(p, "%d %d %1s", &values[0], &values[1], spareParams) != 2)
return -CMDERR_BADPAR;
if (values[1] > 100) return -CMDERR_BADPAR;
hout_pwm_set_signal(pin, (double)values[0], values[1]);
double period = hout_pwm_get_period(pin);
uint32_t duty = hout_pwm_get_duty(pin);
- rpp_sci_printf("houtpwm%d_period=%g\r\nhoutpwm%d_duty=%u%%", pin+1, period, pin+1, duty);
+ rpp_sci_printf("houtpwm%d_period=%g\r\nhoutpwm%d_duty=%u%%\n", pin+1, period, pin+1, duty);
return 0;
}
}
{
int pin;
char *p = param[1];
- char spareParams;
+ char spareParams[2];
- if (sscanf(p, "%d %1s", &pin, &spareParams) != 1)
+ if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
return -CMDERR_BADPAR;
pin--;
if (pin < 0 || pin > 5) return -CMDERR_BADPAR;
{
int pin;
char *p = param[1];
- char spareParams;
+ char spareParams[2];
- if (sscanf(p, "%d %1s", &pin, &spareParams) != 1)
+ if (sscanf(p, "%d %1s", &pin, spareParams) != 1)
return -CMDERR_BADPAR;
pin--;
if (pin < 0 || pin > 5) return -CMDERR_BADPAR;
"\n"
" --> houtpwm1\n"
" houtpwm1_period=1000\n"
- " houtpwm1_duty=25\n"
+ " houtpwm1_duty=25%\n"
"\n"
"Prints the actual period of HOUT1 PWM in microseconds and the duty\n"
"cycle in percents.\n",