drivers: Remove some unneeded 'ret' variables.
This commit is contained in:
parent
50ccb36f20
commit
758906aa71
|
@ -187,21 +187,18 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = g_variant_new_uint64(devc->cur_samplerate);
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
ret = sr_sw_limits_config_get(&devc->limits, key, data);
|
||||
break;
|
||||
return sr_sw_limits_config_get(&devc->limits, key, data);
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
*data = g_variant_new_string(data_sources[devc->data_source]);
|
||||
break;
|
||||
|
@ -209,7 +206,7 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_set(uint32_t key, GVariant *data,
|
||||
|
@ -217,35 +214,32 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
{
|
||||
struct dev_context *devc;
|
||||
uint64_t samplerate;
|
||||
int ret, idx;
|
||||
int idx;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
samplerate = g_variant_get_uint64(data);
|
||||
if (samplerate < samplerates[0] || samplerate > samplerates[1])
|
||||
ret = SR_ERR_ARG;
|
||||
else
|
||||
devc->cur_samplerate = g_variant_get_uint64(data);
|
||||
return SR_ERR_ARG;
|
||||
devc->cur_samplerate = g_variant_get_uint64(data);
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
ret = sr_sw_limits_config_set(&devc->limits, key, data);
|
||||
break;
|
||||
return sr_sw_limits_config_set(&devc->limits, key, data);
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
devc->data_source = idx;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -237,29 +237,24 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
return sr_sw_limits_config_set(&devc->limits, key, data);
|
||||
case SR_CONF_ENABLED:
|
||||
ret = reloadpro_set_on_off(sdi, g_variant_get_boolean(data));
|
||||
break;
|
||||
return reloadpro_set_on_off(sdi, g_variant_get_boolean(data));
|
||||
case SR_CONF_CURRENT_LIMIT:
|
||||
ret = reloadpro_set_current_limit(sdi,
|
||||
g_variant_get_double(data));
|
||||
break;
|
||||
return reloadpro_set_current_limit(sdi, g_variant_get_double(data));
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -194,17 +194,14 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
{
|
||||
struct dev_context *devc;
|
||||
uint64_t tmp;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
ret = sigma_set_samplerate(sdi, g_variant_get_uint64(data));
|
||||
break;
|
||||
return sigma_set_samplerate(sdi, g_variant_get_uint64(data));
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
devc->limit_msec = g_variant_get_uint64(data);
|
||||
break;
|
||||
|
@ -222,10 +219,10 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -240,31 +240,27 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
struct dev_context *devc;
|
||||
struct sr_channel *ch;
|
||||
gdouble dval;
|
||||
int channel, ret, ival;
|
||||
int channel, ival;
|
||||
gboolean bval;
|
||||
|
||||
ret = SR_OK;
|
||||
devc = sdi->priv;
|
||||
|
||||
if (!cg) {
|
||||
switch (key) {
|
||||
case SR_CONF_CHANNEL_CONFIG:
|
||||
if ((ival = std_str_idx(data, ARRAY_AND_SIZE(channel_modes))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
if (devc->model->channel_modes && (1 << ival) == 0) {
|
||||
/* Not supported on this model. */
|
||||
ret = SR_ERR_ARG;
|
||||
}
|
||||
if (devc->model->channel_modes && (1 << ival) == 0)
|
||||
return SR_ERR_ARG; /* Not supported on this model. */
|
||||
if (ival == devc->channel_mode_set)
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
break; /* Nothing to do. */
|
||||
devc->channel_mode_set = ival;
|
||||
devc->config_dirty = TRUE;
|
||||
break;
|
||||
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
|
||||
bval = g_variant_get_boolean(data);
|
||||
if (bval == devc->over_current_protection_set)
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
break; /* Nothing to do. */
|
||||
devc->over_current_protection_set = bval;
|
||||
devc->config_dirty = TRUE;
|
||||
break;
|
||||
|
@ -280,31 +276,30 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
case SR_CONF_VOLTAGE_TARGET:
|
||||
dval = g_variant_get_double(data);
|
||||
if (dval < 0 || dval > devc->model->channels[channel].voltage[1])
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
devc->config[channel].output_voltage_max = dval;
|
||||
devc->config_dirty = TRUE;
|
||||
break;
|
||||
case SR_CONF_CURRENT_LIMIT:
|
||||
dval = g_variant_get_double(data);
|
||||
if (dval < 0 || dval > devc->model->channels[channel].current[1])
|
||||
ret = SR_ERR_ARG;
|
||||
return SR_ERR_ARG;
|
||||
devc->config[channel].output_current_max = dval;
|
||||
devc->config_dirty = TRUE;
|
||||
break;
|
||||
case SR_CONF_ENABLED:
|
||||
bval = g_variant_get_boolean(data);
|
||||
if (bval == devc->config[channel].output_enabled_set)
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
break; /* Nothing to do. */
|
||||
devc->config[channel].output_enabled_set = bval;
|
||||
devc->config_dirty = TRUE;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -142,11 +142,11 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
ret = sr_sw_limits_config_get(&devc->limits, key, data);
|
||||
break;
|
||||
return sr_sw_limits_config_get(&devc->limits, key, data);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = g_variant_new_uint64(devc->samplerate);
|
||||
break;
|
||||
|
@ -176,22 +176,18 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
{
|
||||
struct dev_context *devc;
|
||||
uint64_t samplerate;
|
||||
int ret;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
ret = sr_sw_limits_config_set(&devc->limits, key, data);
|
||||
break;
|
||||
return sr_sw_limits_config_set(&devc->limits, key, data);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
samplerate = g_variant_get_uint64(data);
|
||||
if (samplerate > MAX_SAMPLE_RATE) {
|
||||
sr_err("Maximum sample rate is %d", MAX_SAMPLE_RATE);
|
||||
ret = SR_ERR_SAMPLERATE;
|
||||
break;
|
||||
return SR_ERR_SAMPLERATE;
|
||||
}
|
||||
devc->samplerate = samplerate;
|
||||
bl_acme_maybe_set_update_interval(sdi, samplerate);
|
||||
|
@ -199,18 +195,16 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
case SR_CONF_PROBE_FACTOR:
|
||||
if (!cg)
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
ret = bl_acme_set_shunt(cg, g_variant_get_uint64(data));
|
||||
break;
|
||||
return bl_acme_set_shunt(cg, g_variant_get_uint64(data));
|
||||
case SR_CONF_POWER_OFF:
|
||||
if (!cg)
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
ret = bl_acme_set_power_off(cg, g_variant_get_boolean(data));
|
||||
break;
|
||||
return bl_acme_set_power_off(cg, g_variant_get_boolean(data));
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -138,7 +138,9 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
return SR_ERR_ARG;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
*data = g_variant_new_uint64(devc->limit_samples);
|
||||
|
@ -197,20 +199,18 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int tmp, ret, idx;
|
||||
int tmp, idx;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
break;
|
||||
case SR_CONF_DATALOG:
|
||||
ret = cem_dt_885x_recording_set(sdi, g_variant_get_boolean(data));
|
||||
break;
|
||||
return cem_dt_885x_recording_set(sdi, g_variant_get_boolean(data));
|
||||
case SR_CONF_SPL_WEIGHT_FREQ:
|
||||
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_freq))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
|
@ -223,19 +223,17 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
SR_MQFLAG_SPL_TIME_WEIGHT_F : SR_MQFLAG_SPL_TIME_WEIGHT_S);
|
||||
case SR_CONF_HOLD_MAX:
|
||||
tmp = g_variant_get_boolean(data) ? SR_MQFLAG_MAX : 0;
|
||||
ret = cem_dt_885x_holdmode_set(sdi, tmp);
|
||||
break;
|
||||
return cem_dt_885x_holdmode_set(sdi, tmp);
|
||||
case SR_CONF_HOLD_MIN:
|
||||
tmp = g_variant_get_boolean(data) ? SR_MQFLAG_MIN : 0;
|
||||
ret = cem_dt_885x_holdmode_set(sdi, tmp);
|
||||
break;
|
||||
return cem_dt_885x_holdmode_set(sdi, tmp);
|
||||
case SR_CONF_SPL_MEASUREMENT_RANGE:
|
||||
if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(meas_ranges))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
return cem_dt_885x_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
|
||||
case SR_CONF_POWER_OFF:
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = cem_dt_885x_power_off(sdi);
|
||||
return cem_dt_885x_power_off(sdi);
|
||||
break;
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
|
||||
|
@ -244,10 +242,10 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
devc->enable_data_source_memory = (idx == DATA_SOURCE_MEMORY);
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -93,7 +93,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
static int config_set(uint32_t key, GVariant *data,
|
||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
int ret;
|
||||
double dblval;
|
||||
|
||||
(void)cg;
|
||||
|
@ -105,27 +104,24 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
sr_err("Voltage out of range (0 - 35.0)!");
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
ret = send_msg1(sdi, 'V', (int) (dblval * 10 + 0.5));
|
||||
break;
|
||||
return send_msg1(sdi, 'V', (int) (dblval * 10 + 0.5));
|
||||
case SR_CONF_CURRENT:
|
||||
dblval = g_variant_get_double(data);
|
||||
if ((dblval < 0.01) || (dblval > 2.55)) {
|
||||
sr_err("Current out of range (0 - 2.55)!");
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
ret = send_msg1(sdi, 'C', (int) (dblval * 100 + 0.5));
|
||||
break;
|
||||
return send_msg1(sdi, 'C', (int) (dblval * 100 + 0.5));
|
||||
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = send_msg1(sdi, 'V', 900);
|
||||
return send_msg1(sdi, 'V', 900);
|
||||
else /* Constant current mode */
|
||||
ret = send_msg1(sdi, 'V', 901);
|
||||
break;
|
||||
return send_msg1(sdi, 'V', 901);
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -443,7 +443,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int idx, ret;
|
||||
int idx;
|
||||
gdouble low, high;
|
||||
|
||||
(void)cg;
|
||||
|
@ -453,8 +453,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
if ((idx = std_u64_idx(data, devc->samplerates, devc->num_samplerates)) < 0)
|
||||
|
@ -466,17 +464,16 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
break;
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
devc->capture_ratio = g_variant_get_uint64(data);
|
||||
ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
|
||||
break;
|
||||
return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
|
||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||
if (!strcmp(devc->profile->model, "DSLogic")) {
|
||||
if ((idx = std_double_tuple_idx(data, ARRAY_AND_SIZE(voltage_thresholds))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
devc->cur_threshold = voltage_thresholds[idx][0];
|
||||
ret = dslogic_fpga_firmware_upload(sdi);
|
||||
return dslogic_fpga_firmware_upload(sdi);
|
||||
} else {
|
||||
g_variant_get(data, "(dd)", &low, &high);
|
||||
ret = dslogic_set_voltage_threshold(sdi, (low + high) / 2.0);
|
||||
return dslogic_set_voltage_threshold(sdi, (low + high) / 2.0);
|
||||
}
|
||||
break;
|
||||
case SR_CONF_EXTERNAL_CLOCK:
|
||||
|
@ -491,10 +488,10 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
devc->clock_edge = idx;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -488,7 +488,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int idx, ret;
|
||||
int idx;
|
||||
|
||||
(void)cg;
|
||||
|
||||
|
@ -497,8 +497,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
if ((idx = std_u64_idx(data, devc->samplerates, devc->num_samplerates)) < 0)
|
||||
|
@ -510,13 +508,12 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
break;
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
devc->capture_ratio = g_variant_get_uint64(data);
|
||||
ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
|
||||
break;
|
||||
return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -154,7 +154,7 @@ static int check_channel_group(struct dev_context *devc,
|
|||
static int config_get(uint32_t key, GVariant **data,
|
||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
int ret, cg_type;
|
||||
int cg_type;
|
||||
unsigned int i;
|
||||
struct dev_context *devc;
|
||||
const struct scope_config *model;
|
||||
|
@ -168,19 +168,16 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
|
||||
return SR_ERR;
|
||||
|
||||
ret = SR_ERR_NA;
|
||||
model = devc->model_config;
|
||||
state = devc->model_state;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_NUM_HDIV:
|
||||
*data = g_variant_new_int32(model->num_xdivs);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_TIMEBASE:
|
||||
*data = g_variant_new("(tt)", (*model->timebases)[state->timebase][0],
|
||||
(*model->timebases)[state->timebase][1]);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_NUM_VDIV:
|
||||
if (cg_type == CG_NONE) {
|
||||
|
@ -190,12 +187,10 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
if (cg != devc->analog_groups[i])
|
||||
continue;
|
||||
*data = g_variant_new_int32(model->num_ydivs);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
break;
|
||||
case SR_CONF_VDIV:
|
||||
|
@ -208,25 +203,20 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
*data = g_variant_new("(tt)",
|
||||
(*model->vdivs)[state->analog_channels[i].vdiv][0],
|
||||
(*model->vdivs)[state->analog_channels[i].vdiv][1]);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
*data = g_variant_new_string((*model->trigger_sources)[state->trigger_source]);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_TRIGGER_SLOPE:
|
||||
*data = g_variant_new_string((*model->trigger_slopes)[state->trigger_slope]);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_HORIZ_TRIGGERPOS:
|
||||
*data = g_variant_new_double(state->horiz_triggerpos);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_COUPLING:
|
||||
if (cg_type == CG_NONE) {
|
||||
|
@ -236,23 +226,20 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
if (cg != devc->analog_groups[i])
|
||||
continue;
|
||||
*data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
break;
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = g_variant_new_uint64(state->sample_rate);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_set(uint32_t key, GVariant *data,
|
||||
|
|
|
@ -245,7 +245,6 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
static int config_set(uint32_t key, GVariant *data,
|
||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
int ret;
|
||||
enum sr_mq mq;
|
||||
enum sr_mqflag mq_flags;
|
||||
struct dev_context *devc;
|
||||
|
@ -255,7 +254,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
|
@ -265,17 +263,15 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
mq = g_variant_get_uint32(tuple_child);
|
||||
tuple_child = g_variant_get_child_value(data, 1);
|
||||
mq_flags = g_variant_get_uint64(tuple_child);
|
||||
ret = hp_3457a_set_mq(sdi, mq, mq_flags);
|
||||
g_variant_unref(tuple_child);
|
||||
break;
|
||||
return hp_3457a_set_mq(sdi, mq, mq_flags);
|
||||
case SR_CONF_ADC_POWERLINE_CYCLES:
|
||||
ret = hp_3457a_set_nplc(sdi, g_variant_get_double(data));
|
||||
break;
|
||||
return hp_3457a_set_nplc(sdi, g_variant_get_double(data));
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -248,11 +248,9 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
devc = sdi->priv;
|
||||
|
||||
switch (key) {
|
||||
|
@ -266,35 +264,31 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_set(uint32_t key, GVariant *data,
|
||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
uint64_t samplerate, limit_samples, capture_ratio;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
limit_samples = g_variant_get_uint64(data);
|
||||
ret = sl2_set_limit_samples(sdi, limit_samples);
|
||||
break;
|
||||
return sl2_set_limit_samples(sdi, limit_samples);
|
||||
case SR_CONF_SAMPLERATE:
|
||||
samplerate = g_variant_get_uint64(data);
|
||||
ret = sl2_set_samplerate(sdi, samplerate);
|
||||
break;
|
||||
return sl2_set_samplerate(sdi, samplerate);
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
capture_ratio = g_variant_get_uint64(data);
|
||||
ret = sl2_set_capture_ratio(sdi, capture_ratio);
|
||||
break;
|
||||
return sl2_set_capture_ratio(sdi, capture_ratio);
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -217,7 +217,6 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
case SR_CONF_DATALOG:
|
||||
/* There really isn't a way to be sure the device is logging. */
|
||||
return SR_ERR_NA;
|
||||
break;
|
||||
case SR_CONF_SPL_WEIGHT_FREQ:
|
||||
if (devc->mqflags & SR_MQFLAG_SPL_FREQ_WEIGHT_A)
|
||||
*data = g_variant_new_string("A");
|
||||
|
|
|
@ -158,27 +158,26 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
ret = SR_OK;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_DATALOG:
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = lascar_start_logging(sdi);
|
||||
return lascar_start_logging(sdi);
|
||||
else
|
||||
ret = lascar_stop_logging(sdi);
|
||||
return lascar_stop_logging(sdi);
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -401,6 +401,7 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
default:
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,7 +228,6 @@ static int config_get(int key, GVariant **data,
|
|||
static int config_set(int key, GVariant *data,
|
||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
int ret;
|
||||
struct dev_context *devc;
|
||||
uint64_t num_samples;
|
||||
const char *slope;
|
||||
|
@ -239,7 +238,6 @@ static int config_set(int key, GVariant *data,
|
|||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
// FIXME
|
||||
|
@ -248,9 +246,8 @@ static int config_set(int key, GVariant *data,
|
|||
num_samples = g_variant_get_uint64(data);
|
||||
if (num_samples != 1024) {
|
||||
sr_err("Only 1024 samples are supported.");
|
||||
ret = SR_ERR_ARG;
|
||||
break;
|
||||
};
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
devc->limit_samples = num_samples;
|
||||
break;
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
|
@ -260,8 +257,7 @@ static int config_set(int key, GVariant *data,
|
|||
|
||||
if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
|
||||
sr_err("Invalid trigger slope");
|
||||
ret = SR_ERR_ARG;
|
||||
break;
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
devc->trigger_slope = (slope[0] == 'r')
|
||||
? SLOPE_POSITIVE : SLOPE_NEGATIVE;
|
||||
|
@ -270,8 +266,7 @@ static int config_set(int key, GVariant *data,
|
|||
pos = g_variant_get_double(data);
|
||||
if (pos < 0 || pos > 255) {
|
||||
sr_err("Trigger position (%f) should be between 0 and 255.", pos);
|
||||
ret = SR_ERR_ARG;
|
||||
break;
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
trigger_pos = (int)pos;
|
||||
devc->trigger_holdoff[0] = trigger_pos & 0xff;
|
||||
|
@ -279,10 +274,10 @@ static int config_set(int key, GVariant *data,
|
|||
case SR_CONF_RLE:
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(int key, GVariant **data,
|
||||
|
|
|
@ -321,39 +321,31 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
{
|
||||
struct dev_context *devc;
|
||||
struct sr_modbus_dev_inst *modbus;
|
||||
int ret;
|
||||
|
||||
(void)cg;
|
||||
|
||||
modbus = sdi->conn;
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
ret = sr_sw_limits_config_set(&devc->limits, key, data);
|
||||
break;
|
||||
return sr_sw_limits_config_set(&devc->limits, key, data);
|
||||
case SR_CONF_ENABLED:
|
||||
ret = maynuo_m97_set_input(modbus, g_variant_get_boolean(data));
|
||||
break;
|
||||
return maynuo_m97_set_input(modbus, g_variant_get_boolean(data));
|
||||
case SR_CONF_VOLTAGE_TARGET:
|
||||
ret = maynuo_m97_set_float(modbus, UFIX, g_variant_get_double(data));
|
||||
break;
|
||||
return maynuo_m97_set_float(modbus, UFIX, g_variant_get_double(data));
|
||||
case SR_CONF_CURRENT_LIMIT:
|
||||
ret = maynuo_m97_set_float(modbus, IFIX, g_variant_get_double(data));
|
||||
break;
|
||||
return maynuo_m97_set_float(modbus, IFIX, g_variant_get_double(data));
|
||||
case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
|
||||
ret = maynuo_m97_set_float(modbus, UMAX, g_variant_get_double(data));
|
||||
break;
|
||||
return maynuo_m97_set_float(modbus, UMAX, g_variant_get_double(data));
|
||||
case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
|
||||
ret = maynuo_m97_set_float(modbus, IMAX, g_variant_get_double(data));
|
||||
break;
|
||||
return maynuo_m97_set_float(modbus, IMAX, g_variant_get_double(data));
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -612,7 +612,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
return SR_ERR_NA;
|
||||
devc->channel_status[ch_idx].output_current_max = dval;
|
||||
return lps_cmd_ok(sdi->conn, "ISET%d %05.4f", ch_idx+1, dval);
|
||||
break;
|
||||
case SR_CONF_ENABLED:
|
||||
bval = g_variant_get_boolean(data);
|
||||
if (bval == devc->channel_status[ch_idx].output_enabled) /* Nothing to do. */
|
||||
|
|
|
@ -198,6 +198,7 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
return SR_ERR_ARG;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = g_variant_new_uint64(devc->cur_samplerate);
|
||||
|
@ -232,7 +233,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
struct dev_context *devc;
|
||||
uint16_t flag;
|
||||
uint64_t tmp_u64;
|
||||
int ret;
|
||||
const char *stropt;
|
||||
|
||||
(void)cg;
|
||||
|
@ -244,21 +244,19 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
tmp_u64 = g_variant_get_uint64(data);
|
||||
if (tmp_u64 < samplerates[0] || tmp_u64 > samplerates[1])
|
||||
return SR_ERR_SAMPLERATE;
|
||||
ret = ols_set_samplerate(sdi, g_variant_get_uint64(data));
|
||||
break;
|
||||
return ols_set_samplerate(sdi, g_variant_get_uint64(data));
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
tmp_u64 = g_variant_get_uint64(data);
|
||||
if (tmp_u64 < MIN_NUM_SAMPLES)
|
||||
return SR_ERR;
|
||||
devc->limit_samples = tmp_u64;
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
devc->capture_ratio = g_variant_get_uint64(data);
|
||||
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
|
||||
ret = SR_ERR;
|
||||
return SR_ERR;
|
||||
else
|
||||
ret = SR_OK;
|
||||
return SR_OK;
|
||||
break;
|
||||
case SR_CONF_EXTERNAL_CLOCK:
|
||||
if (g_variant_get_boolean(data)) {
|
||||
|
@ -268,23 +266,21 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
sr_info("Disabled external clock.");
|
||||
devc->flag_reg &= ~FLAG_CLOCK_EXTERNAL;
|
||||
}
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_PATTERN_MODE:
|
||||
stropt = g_variant_get_string(data, NULL);
|
||||
ret = SR_OK;
|
||||
flag = 0xffff;
|
||||
if (!strcmp(stropt, STR_PATTERN_NONE)) {
|
||||
sr_info("Disabling test modes.");
|
||||
flag = 0x0000;
|
||||
}else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
|
||||
} else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
|
||||
sr_info("Enabling internal test mode.");
|
||||
flag = FLAG_INTERNAL_TEST_MODE;
|
||||
} else if (!strcmp(stropt, STR_PATTERN_EXTERNAL)) {
|
||||
sr_info("Enabling external test mode.");
|
||||
flag = FLAG_EXTERNAL_TEST_MODE;
|
||||
} else {
|
||||
ret = SR_ERR;
|
||||
return SR_ERR;
|
||||
}
|
||||
if (flag != 0xffff) {
|
||||
devc->flag_reg &= ~(FLAG_INTERNAL_TEST_MODE | FLAG_EXTERNAL_TEST_MODE);
|
||||
|
@ -299,9 +295,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
sr_info("Disabling channel swapping.");
|
||||
devc->flag_reg &= ~FLAG_SWAP_CHANNELS;
|
||||
}
|
||||
ret = SR_OK;
|
||||
break;
|
||||
|
||||
case SR_CONF_RLE:
|
||||
if (g_variant_get_boolean(data)) {
|
||||
sr_info("Enabling RLE.");
|
||||
|
@ -310,13 +304,12 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
sr_info("Disabling RLE.");
|
||||
devc->flag_reg &= ~FLAG_RLE;
|
||||
}
|
||||
ret = SR_OK;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -114,7 +114,7 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
return SR_ERR_ARG;
|
||||
|
||||
devc = sdi->priv;
|
||||
ret = SR_OK;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
*data = g_variant_new_uint64(devc->limit_samples);
|
||||
|
@ -140,6 +140,8 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
case SR_CONF_SPL_MEASUREMENT_RANGE:
|
||||
if ((ret = pce_322a_meas_range_get(sdi, &low, &high)) == SR_OK)
|
||||
*data = std_gvar_tuple_u64(low, high);
|
||||
else
|
||||
return ret;
|
||||
break;
|
||||
case SR_CONF_POWER_OFF:
|
||||
*data = g_variant_new_boolean(FALSE);
|
||||
|
@ -154,20 +156,19 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
|
||||
const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int ret, idx;
|
||||
int idx;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
|
@ -175,23 +176,20 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
case SR_CONF_SPL_WEIGHT_FREQ:
|
||||
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_freq))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
ret = pce_322a_weight_freq_set(sdi, (weight_freq[idx][0] == 'A') ?
|
||||
return pce_322a_weight_freq_set(sdi, (weight_freq[idx][0] == 'A') ?
|
||||
SR_MQFLAG_SPL_FREQ_WEIGHT_A : SR_MQFLAG_SPL_FREQ_WEIGHT_C);
|
||||
break;
|
||||
case SR_CONF_SPL_WEIGHT_TIME:
|
||||
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_time))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
ret = pce_322a_weight_time_set(sdi, (weight_time[idx][0] == 'F') ?
|
||||
return pce_322a_weight_time_set(sdi, (weight_time[idx][0] == 'F') ?
|
||||
SR_MQFLAG_SPL_TIME_WEIGHT_F : SR_MQFLAG_SPL_TIME_WEIGHT_S);
|
||||
break;
|
||||
case SR_CONF_SPL_MEASUREMENT_RANGE:
|
||||
if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(meas_ranges))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
ret = pce_322a_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
|
||||
break;
|
||||
return pce_322a_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
|
||||
case SR_CONF_POWER_OFF:
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = pce_322a_power_off(sdi);
|
||||
return pce_322a_power_off(sdi);
|
||||
break;
|
||||
case SR_CONF_DATA_SOURCE:
|
||||
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
|
||||
|
@ -199,10 +197,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
devc->cur_data_source = idx;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -206,6 +206,7 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
return SR_ERR_ARG;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
*data = g_variant_new_uint64(devc->cur_samplerate);
|
||||
|
@ -243,7 +244,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
struct dev_context *devc;
|
||||
uint16_t flag;
|
||||
uint64_t tmp_u64;
|
||||
int ret;
|
||||
const char *stropt;
|
||||
|
||||
(void)cg;
|
||||
|
@ -255,21 +255,19 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
tmp_u64 = g_variant_get_uint64(data);
|
||||
if (tmp_u64 < samplerates[0] || tmp_u64 > samplerates[1])
|
||||
return SR_ERR_SAMPLERATE;
|
||||
ret = p_ols_set_samplerate(sdi, g_variant_get_uint64(data));
|
||||
break;
|
||||
return p_ols_set_samplerate(sdi, g_variant_get_uint64(data));
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
tmp_u64 = g_variant_get_uint64(data);
|
||||
if (tmp_u64 < MIN_NUM_SAMPLES)
|
||||
return SR_ERR;
|
||||
devc->limit_samples = tmp_u64;
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
devc->capture_ratio = g_variant_get_uint64(data);
|
||||
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
|
||||
ret = SR_ERR;
|
||||
return SR_ERR;
|
||||
else
|
||||
ret = SR_OK;
|
||||
return SR_OK;
|
||||
break;
|
||||
case SR_CONF_EXTERNAL_CLOCK:
|
||||
if (g_variant_get_boolean(data)) {
|
||||
|
@ -279,23 +277,21 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
sr_info("Disabled external clock.");
|
||||
devc->flag_reg &= ~FLAG_CLOCK_EXTERNAL;
|
||||
}
|
||||
ret = SR_OK;
|
||||
break;
|
||||
case SR_CONF_PATTERN_MODE:
|
||||
stropt = g_variant_get_string(data, NULL);
|
||||
ret = SR_OK;
|
||||
flag = 0xffff;
|
||||
if (!strcmp(stropt, STR_PATTERN_NONE)) {
|
||||
sr_info("Disabling test modes.");
|
||||
flag = 0x0000;
|
||||
}else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
|
||||
} else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
|
||||
sr_info("Enabling internal test mode.");
|
||||
flag = FLAG_INTERNAL_TEST_MODE;
|
||||
} else if (!strcmp(stropt, STR_PATTERN_EXTERNAL)) {
|
||||
sr_info("Enabling external test mode.");
|
||||
flag = FLAG_EXTERNAL_TEST_MODE;
|
||||
} else {
|
||||
ret = SR_ERR;
|
||||
return SR_ERR;
|
||||
}
|
||||
if (flag != 0xffff) {
|
||||
devc->flag_reg &= ~(FLAG_INTERNAL_TEST_MODE | FLAG_EXTERNAL_TEST_MODE);
|
||||
|
@ -310,9 +306,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
sr_info("Disabling channel swapping.");
|
||||
devc->flag_reg &= ~FLAG_SWAP_CHANNELS;
|
||||
}
|
||||
ret = SR_OK;
|
||||
break;
|
||||
|
||||
case SR_CONF_RLE:
|
||||
if (g_variant_get_boolean(data)) {
|
||||
sr_info("Enabling RLE.");
|
||||
|
@ -321,13 +315,12 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
sr_info("Disabling RLE.");
|
||||
devc->flag_reg &= ~FLAG_RLE;
|
||||
}
|
||||
ret = SR_OK;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -632,7 +632,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
return SR_ERR;
|
||||
}
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_LIMIT_FRAMES:
|
||||
devc->limit_frames = g_variant_get_uint64(data);
|
||||
|
@ -642,8 +641,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
return SR_ERR_ARG;
|
||||
g_free(devc->trigger_slope);
|
||||
devc->trigger_slope = g_strdup((trigger_slopes[idx][0] == 'r') ? "POS" : "NEG");
|
||||
ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
|
||||
break;
|
||||
return rigol_ds_config_set(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
|
||||
case SR_CONF_HORIZ_TRIGGERPOS:
|
||||
t_dbl = g_variant_get_double(data);
|
||||
if (t_dbl < 0.0 || t_dbl > 1.0) {
|
||||
|
@ -655,23 +653,21 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
* need to express this in seconds. */
|
||||
t_dbl = -(devc->horiz_triggerpos - 0.5) * devc->timebase * devc->num_timebases;
|
||||
g_ascii_formatd(buffer, sizeof(buffer), "%.6f", t_dbl);
|
||||
ret = rigol_ds_config_set(sdi, ":TIM:OFFS %s", buffer);
|
||||
break;
|
||||
return rigol_ds_config_set(sdi, ":TIM:OFFS %s", buffer);
|
||||
case SR_CONF_TRIGGER_LEVEL:
|
||||
t_dbl = g_variant_get_double(data);
|
||||
g_ascii_formatd(buffer, sizeof(buffer), "%.3f", t_dbl);
|
||||
ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:LEV %s", buffer);
|
||||
if (ret == SR_OK)
|
||||
devc->trigger_level = t_dbl;
|
||||
break;
|
||||
return ret;
|
||||
case SR_CONF_TIMEBASE:
|
||||
if ((idx = std_u64_tuple_idx(data, devc->timebases, devc->num_timebases)) < 0)
|
||||
return SR_ERR_ARG;
|
||||
devc->timebase = (float)devc->timebases[idx][0] / devc->timebases[idx][1];
|
||||
g_ascii_formatd(buffer, sizeof(buffer), "%.9f",
|
||||
devc->timebase);
|
||||
ret = rigol_ds_config_set(sdi, ":TIM:SCAL %s", buffer);
|
||||
break;
|
||||
return rigol_ds_config_set(sdi, ":TIM:SCAL %s", buffer);
|
||||
case SR_CONF_TRIGGER_SOURCE:
|
||||
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_sources))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
|
@ -689,8 +685,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
tmp_str = "CHAN4";
|
||||
else
|
||||
tmp_str = (char *)devc->trigger_source;
|
||||
ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
|
||||
break;
|
||||
return rigol_ds_config_set(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
|
||||
case SR_CONF_VDIV:
|
||||
if (!cg)
|
||||
return SR_ERR_CHANNEL_GROUP;
|
||||
|
@ -759,7 +754,7 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -403,12 +403,10 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
{
|
||||
struct dev_context *devc;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
int ret;
|
||||
unsigned int i;
|
||||
|
||||
(void)cg;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_CONN:
|
||||
if (!sdi || !sdi->conn)
|
||||
|
@ -436,34 +434,31 @@ static int config_get(uint32_t key, GVariant **data,
|
|||
if (!sdi)
|
||||
return SR_ERR;
|
||||
devc = sdi->priv;
|
||||
ret = SR_ERR;
|
||||
for (i = 0; i < ARRAY_SIZE(volt_thresholds); i++) {
|
||||
if (devc->selected_voltage_range !=
|
||||
volt_thresholds_ranges[i].range)
|
||||
continue;
|
||||
*data = std_gvar_tuple_double(volt_thresholds[i][0], volt_thresholds[i][1]);
|
||||
ret = SR_OK;
|
||||
break;
|
||||
return SR_OK;
|
||||
}
|
||||
break;
|
||||
return SR_ERR;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_set(uint32_t key, GVariant *data,
|
||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
int ret, idx;
|
||||
int idx;
|
||||
|
||||
(void)cg;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
ret = SR_OK;
|
||||
switch (key) {
|
||||
case SR_CONF_SAMPLERATE:
|
||||
devc->cur_samplerate = g_variant_get_uint64(data);
|
||||
|
@ -473,18 +468,17 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
break;
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
devc->capture_ratio = g_variant_get_uint64(data);
|
||||
ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
|
||||
break;
|
||||
return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
|
||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||
if ((idx = std_double_tuple_idx(data, ARRAY_AND_SIZE(volt_thresholds))) < 0)
|
||||
return SR_ERR_ARG;
|
||||
devc->selected_voltage_range = volt_thresholds_ranges[idx].range;
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
|
@ -433,7 +433,6 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
{
|
||||
struct dev_context *devc;
|
||||
double d;
|
||||
int ret;
|
||||
|
||||
if (!sdi)
|
||||
return SR_ERR_ARG;
|
||||
|
@ -446,66 +445,66 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
switch (key) {
|
||||
case SR_CONF_ENABLED:
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OUTPUT_ENABLE);
|
||||
else
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OUTPUT_DISABLE);
|
||||
break;
|
||||
case SR_CONF_VOLTAGE_TARGET:
|
||||
d = g_variant_get_double(data);
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_VOLTAGE_TARGET, d);
|
||||
break;
|
||||
case SR_CONF_OUTPUT_FREQUENCY_TARGET:
|
||||
d = g_variant_get_double(data);
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_FREQUENCY_TARGET, d);
|
||||
break;
|
||||
case SR_CONF_CURRENT_LIMIT:
|
||||
d = g_variant_get_double(data);
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_CURRENT_LIMIT, d);
|
||||
break;
|
||||
case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED:
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE);
|
||||
else
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE);
|
||||
break;
|
||||
case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
|
||||
d = g_variant_get_double(data);
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, d);
|
||||
break;
|
||||
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE);
|
||||
else
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE);
|
||||
break;
|
||||
case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
|
||||
d = g_variant_get_double(data);
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, d);
|
||||
break;
|
||||
case SR_CONF_OVER_TEMPERATURE_PROTECTION:
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE);
|
||||
else
|
||||
ret = scpi_cmd(sdi, devc->device->commands,
|
||||
return scpi_cmd(sdi, devc->device->commands,
|
||||
SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE);
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
return SR_ERR_NA;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int config_list(uint32_t key, GVariant **data,
|
||||
|
|
Loading…
Reference in New Issue