switch (key) {
case SR_CONF_CONN:
- if (!sdi->conn)
- return SR_ERR_ARG;
usb = sdi->conn;
- if (usb->address == 0xff) {
- /*
- * Device still needs to re-enumerate after firmware
- * upload, so we don't know its (future) address.
- */
- return SR_ERR;
- }
*data = g_variant_new_printf("%d.%d", usb->bus, usb->address);
break;
case SR_CONF_SAMPLERATE:
int ret, cg_type;
size_t logic_idx, analog_idx;
struct pwm_setting *pwm;
+ double value_f;
double low, high;
int idx;
return ret;
break;
case SR_CONF_OUTPUT_FREQUENCY:
- pwm->freq = g_variant_get_double(data);
+ value_f = g_variant_get_double(data);
+ if (value_f <= 0.0 || value_f > MAX_PWM_FREQ)
+ return SR_ERR_ARG;
+ pwm->freq = value_f;
ret = la2016_write_pwm_config(sdi, analog_idx);
if (ret != SR_OK)
return ret;
break;
case SR_CONF_DUTY_CYCLE:
- pwm->duty = g_variant_get_double(data);
+ value_f = g_variant_get_double(data);
+ if (value_f <= 0.0 || value_f > 100.0)
+ return SR_ERR_ARG;
+ pwm->duty = value_f;
ret = la2016_write_pwm_config(sdi, analog_idx);
if (ret != SR_OK)
return ret;
devc = sdi->priv;
/* Clamp threshold setting to valid range for LA2016. */
- if (voltage > 4.0) {
- voltage = 4.0;
- } else if (voltage < -4.0) {
- voltage = -4.0;
+ if (voltage > LA2016_THR_VOLTAGE_MAX) {
+ voltage = LA2016_THR_VOLTAGE_MAX;
+ } else if (voltage < -LA2016_THR_VOLTAGE_MAX) {
+ voltage = -LA2016_THR_VOLTAGE_MAX;
}
/*