]> sigrok.org Git - libsigrok.git/commitdiff
scpi-pps: Split boolean set options into enable/disable.
authorBert Vermeulen <redacted>
Fri, 10 Oct 2014 14:00:33 +0000 (16:00 +0200)
committerBert Vermeulen <redacted>
Mon, 13 Oct 2014 10:50:28 +0000 (12:50 +0200)
This makes it easier to support devices that need something else
than "ON" or "OFF".

src/hardware/scpi-pps/api.c
src/hardware/scpi-pps/profiles.c
src/hardware/scpi-pps/protocol.h

index bd7e6d6e983ea48d0a1c7dcca8eed0bbdfbdd163..4c5e9afc96f547ee09e5919b5d01469f64d9df9a 100644 (file)
@@ -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);
index efd871931b1682ffa88e4a2277de27f168af9131..deb200dc2acd01abcb8e1222ac89938476e27259 100644 (file)
@@ -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?" },
index 552d5030a0e752f08360442cf22150afb122e9ea..597ed09f48bccb046d7f63108e90552f84d74222 100644 (file)
@@ -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,