scpi-pps: Split boolean set options into enable/disable.
This makes it easier to support devices that need something else than "ON" or "OFF".
This commit is contained in:
parent
b9a348f56c
commit
53a81803e4
|
@ -320,7 +320,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
struct pps_channel *pch;
|
||||
double d;
|
||||
int ret;
|
||||
const char *s;
|
||||
|
||||
if (!sdi)
|
||||
return SR_ERR_ARG;
|
||||
|
@ -333,8 +332,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
switch (key) {
|
||||
/* No channel group: global options. */
|
||||
case SR_CONF_OUTPUT_ENABLED:
|
||||
s = g_variant_get_boolean(data) ? "ON" : "OFF";
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_ENABLED, s);
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_ENABLE);
|
||||
else
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_DISABLE);
|
||||
break;
|
||||
case SR_CONF_OUTPUT_VOLTAGE_MAX:
|
||||
d = g_variant_get_double(data);
|
||||
|
@ -345,8 +346,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
ret = scpi_cmd(sdi, SCPI_CMD_SET_CURRENT_MAX, d);
|
||||
break;
|
||||
case SR_CONF_OVER_TEMPERATURE_PROTECTION:
|
||||
s = g_variant_get_boolean(data) ? "ON" : "OFF";
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION, s);
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE);
|
||||
else
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE);
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_NA;
|
||||
|
@ -357,8 +360,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
pch = ch->priv;
|
||||
switch (key) {
|
||||
case SR_CONF_OUTPUT_ENABLED:
|
||||
s = g_variant_get_boolean(data) ? "ON" : "OFF";
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_ENABLED, pch->hwname, s);
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_ENABLE, pch->hwname);
|
||||
else
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_DISABLE, pch->hwname);
|
||||
break;
|
||||
case SR_CONF_OUTPUT_VOLTAGE_MAX:
|
||||
d = g_variant_get_double(data);
|
||||
|
@ -369,9 +374,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
ret = scpi_cmd(sdi, SCPI_CMD_SET_CURRENT_MAX, pch->hwname, d);
|
||||
break;
|
||||
case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED:
|
||||
s = g_variant_get_boolean(data) ? "ON" : "OFF";
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLED,
|
||||
pch->hwname, s);
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE,
|
||||
pch->hwname);
|
||||
else
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE,
|
||||
pch->hwname);
|
||||
break;
|
||||
case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
|
||||
d = g_variant_get_double(data);
|
||||
|
@ -379,9 +387,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
|||
pch->hwname, d);
|
||||
break;
|
||||
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
|
||||
s = g_variant_get_boolean(data) ? "ON" : "OFF";
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLED,
|
||||
pch->hwname, s);
|
||||
if (g_variant_get_boolean(data))
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE,
|
||||
pch->hwname);
|
||||
else
|
||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE,
|
||||
pch->hwname);
|
||||
break;
|
||||
case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
|
||||
d = g_variant_get_double(data);
|
||||
|
|
|
@ -91,17 +91,21 @@ struct scpi_command rigol_dp800_cmd[] = {
|
|||
{ SCPI_CMD_GET_CURRENT_MAX, ":SOUR%s:CURR?" },
|
||||
{ SCPI_CMD_SET_CURRENT_MAX, ":SOUR%s:CURR %.6f" },
|
||||
{ SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP? CH%s" },
|
||||
{ SCPI_CMD_SET_OUTPUT_ENABLED, ":OUTP CH%s,%s" },
|
||||
{ SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP CH%s,ON" },
|
||||
{ SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP CH%s,OFF" },
|
||||
{ SCPI_CMD_GET_OUTPUT_REGULATION, ":OUTP:MODE? CH%s" },
|
||||
{ SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP?" },
|
||||
{ SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP %s" },
|
||||
{ SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE, ":SYST:OTP ON" },
|
||||
{ SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE, ":SYST:OTP OFF" },
|
||||
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP? CH%s" },
|
||||
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP CH%s,%s" },
|
||||
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE, ":OUTP:OVP CH%s,ON" },
|
||||
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE, ":OUTP:OVP CH%s,OFF" },
|
||||
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":OUTP:OVP:QUES? CH%s" },
|
||||
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL? CH%s" },
|
||||
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL CH%s,%.6f" },
|
||||
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP? CH%s" },
|
||||
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP CH%s,%s" },
|
||||
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":OUTP:OCP CH%s,ON" },
|
||||
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":OUTP:OCP CH%s,OFF" },
|
||||
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":OUTP:OCP:QUES? CH%s" },
|
||||
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL? CH%s" },
|
||||
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL CH%s,%.6f" },
|
||||
|
@ -128,7 +132,8 @@ struct channel_group_spec hp_6632b_cg[] = {
|
|||
|
||||
struct scpi_command hp_6632b_cmd[] = {
|
||||
{ SCPI_CMD_GET_OUTPUT_ENABLED, "OUTP:STAT?" },
|
||||
{ SCPI_CMD_SET_OUTPUT_ENABLED, "OUTP:STAT %s" },
|
||||
{ SCPI_CMD_SET_OUTPUT_ENABLE, "OUTP:STAT ON" },
|
||||
{ SCPI_CMD_SET_OUTPUT_DISABLE, "OUTP:STAT OFF" },
|
||||
{ SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
|
||||
{ SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
|
||||
{ SCPI_CMD_GET_VOLTAGE_MAX, ":SOUR:VOLT?" },
|
||||
|
|
|
@ -37,17 +37,21 @@ enum pps_scpi_cmds {
|
|||
SCPI_CMD_GET_CURRENT_MAX,
|
||||
SCPI_CMD_SET_CURRENT_MAX,
|
||||
SCPI_CMD_GET_OUTPUT_ENABLED,
|
||||
SCPI_CMD_SET_OUTPUT_ENABLED,
|
||||
SCPI_CMD_SET_OUTPUT_ENABLE,
|
||||
SCPI_CMD_SET_OUTPUT_DISABLE,
|
||||
SCPI_CMD_GET_OUTPUT_REGULATION,
|
||||
SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION,
|
||||
SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION,
|
||||
SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE,
|
||||
SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE,
|
||||
SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED,
|
||||
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLED,
|
||||
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE,
|
||||
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE,
|
||||
SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE,
|
||||
SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD,
|
||||
SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD,
|
||||
SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED,
|
||||
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLED,
|
||||
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE,
|
||||
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE,
|
||||
SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE,
|
||||
SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD,
|
||||
SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD,
|
||||
|
|
Loading…
Reference in New Issue