hwdriver: Change TRIGGER_SLOPE setting to string type.

Drivers interpreted the uint64 values to the SR_CONF_TRIGGER_SLOPE
configuration setting in different ways.  In order to orthogonalize
the API, change the type of the setting to a string with the same
format as uses for logic probes.
This commit is contained in:
Daniel Elstner 2014-01-27 00:22:01 +01:00 committed by Bert Vermeulen
parent fe90fbb782
commit ca9b9f4834
5 changed files with 26 additions and 20 deletions

View File

@ -513,7 +513,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
struct scope_config *model;
struct scope_state *state;
const char *tmp;
uint64_t p, q, tmp_u64;
uint64_t p, q;
double tmp_d;
gboolean update_sample_rate;
@ -612,16 +612,16 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
ret = sr_scpi_send(sdi->conn, command);
break;
case SR_CONF_TRIGGER_SLOPE:
tmp_u64 = g_variant_get_uint64(data);
tmp = g_variant_get_string(data, NULL);
if (tmp_u64 != 0 && tmp_u64 != 1)
return SR_ERR;
if (!tmp || !(tmp[0] == 'f' || tmp[0] == 'r'))
return SR_ERR_ARG;
state->trigger_slope = tmp_u64;
state->trigger_slope = (tmp[0] == 'r') ? 0 : 1;
g_snprintf(command, sizeof(command),
(*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SLOPE],
tmp_u64 ? "POS" : "NEG");
(state->trigger_slope == 0) ? "POS" : "NEG");
ret = sr_scpi_send(sdi->conn, command);
break;

View File

@ -478,10 +478,11 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
devc->limit_frames = g_variant_get_uint64(data);
break;
case SR_CONF_TRIGGER_SLOPE:
tmp_u64 = g_variant_get_uint64(data);
if (tmp_u64 != SLOPE_NEGATIVE && tmp_u64 != SLOPE_POSITIVE)
ret = SR_ERR_ARG;
devc->triggerslope = tmp_u64;
tmp_str = g_variant_get_string(data, NULL);
if (!tmp_str || !(tmp_str[0] == 'f' || tmp_str[0] == 'r'))
return SR_ERR_ARG;
devc->triggerslope = (tmp_str[0] == 'r')
? SLOPE_POSITIVE : SLOPE_NEGATIVE;
break;
case SR_CONF_HORIZ_TRIGGERPOS:
tmp_double = g_variant_get_double(data);

View File

@ -302,7 +302,8 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
{
int ret;
struct dev_context *devc;
uint64_t num_samples, slope;
uint64_t num_samples;
const char *slope;
int trigger_pos;
double pos;
@ -334,12 +335,14 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
ret = SR_OK;
break;
case SR_CONF_TRIGGER_SLOPE:
slope = g_variant_get_uint64(data);
if (slope != SLOPE_NEGATIVE && slope != SLOPE_POSITIVE) {
slope = g_variant_get_string(data, NULL);
if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
sr_err("Invalid trigger slope");
ret = SR_ERR_ARG;
} else {
devc->trigger_slope = slope;
devc->trigger_slope = (slope[0] == 'r')
? SLOPE_POSITIVE : SLOPE_NEGATIVE;
ret = SR_OK;
}
break;

View File

@ -657,7 +657,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_probe_group *probe_group)
{
struct dev_context *devc;
uint64_t tmp_u64, p, q;
uint64_t p, q;
double t_dbl;
unsigned int i, j;
int ret;
@ -682,11 +682,13 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
devc->limit_frames = g_variant_get_uint64(data);
break;
case SR_CONF_TRIGGER_SLOPE:
tmp_u64 = g_variant_get_uint64(data);
if (tmp_u64 != 0 && tmp_u64 != 1)
return SR_ERR;
tmp_str = g_variant_get_string(data, NULL);
if (!tmp_str || !(tmp_str[0] == 'f' || tmp_str[0] == 'r'))
return SR_ERR_ARG;
g_free(devc->trigger_slope);
devc->trigger_slope = g_strdup(tmp_u64 ? "POS" : "NEG");
devc->trigger_slope = g_strdup((tmp_str[0] == 'r') ? "POS" : "NEG");
ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
break;
case SR_CONF_HORIZ_TRIGGERPOS:

View File

@ -62,7 +62,7 @@ static struct sr_config_info sr_config_info_data[] = {
"Swap channel order", NULL},
{SR_CONF_RLE, SR_T_BOOL, "rle",
"Run Length Encoding", NULL},
{SR_CONF_TRIGGER_SLOPE, SR_T_UINT64, "triggerslope",
{SR_CONF_TRIGGER_SLOPE, SR_T_CHAR, "triggerslope",
"Trigger slope", NULL},
{SR_CONF_TRIGGER_SOURCE, SR_T_CHAR, "triggersource",
"Trigger source", NULL},