]> sigrok.org Git - libsigrok.git/commitdiff
scpi-pps: Add config keys SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE,
authorFrank Stettner <redacted>
Tue, 9 Apr 2019 13:47:19 +0000 (15:47 +0200)
committerUwe Hermann <redacted>
Wed, 17 Apr 2019 15:11:21 +0000 (17:11 +0200)
SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE and
SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE to HP 66xxB power supplies.

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

index 22c79740ed1fada6f042e2b644ebe6b16dd40e86..02a34499ee2d901f244bf4c446ddad781029e04d 100644 (file)
@@ -313,7 +313,7 @@ static int config_get(uint32_t key, GVariant **data,
        char *channel_group_name;
        int cmd, ret;
        const char *s;
-       int oper_cond;
+       int reg;
 
        if (!sdi)
                return SR_ERR_ARG;
@@ -376,7 +376,10 @@ static int config_get(uint32_t key, GVariant **data,
                cmd = SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED;
                break;
        case SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE:
-               gvtype = G_VARIANT_TYPE_BOOLEAN;
+               if (devc->device->dialect == SCPI_DIALECT_HP_66XXB)
+                       gvtype = G_VARIANT_TYPE_STRING;
+               else
+                       gvtype = G_VARIANT_TYPE_BOOLEAN;
                cmd = SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE;
                break;
        case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
@@ -388,7 +391,10 @@ static int config_get(uint32_t key, GVariant **data,
                cmd = SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED;
                break;
        case SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE:
-               gvtype = G_VARIANT_TYPE_BOOLEAN;
+               if (devc->device->dialect == SCPI_DIALECT_HP_66XXB)
+                       gvtype = G_VARIANT_TYPE_STRING;
+               else
+                       gvtype = G_VARIANT_TYPE_BOOLEAN;
                cmd = SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE;
                break;
        case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
@@ -399,6 +405,13 @@ static int config_get(uint32_t key, GVariant **data,
                gvtype = G_VARIANT_TYPE_BOOLEAN;
                cmd = SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION;
                break;
+       case SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE:
+               if (devc->device->dialect == SCPI_DIALECT_HP_66XXB)
+                       gvtype = G_VARIANT_TYPE_STRING;
+               else
+                       gvtype = G_VARIANT_TYPE_BOOLEAN;
+               cmd = SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION_ACTIVE;
+               break;
        case SR_CONF_REGULATION:
                gvtype = G_VARIANT_TYPE_STRING;
                cmd = SCPI_CMD_GET_OUTPUT_REGULATION;
@@ -442,13 +455,13 @@ static int config_get(uint32_t key, GVariant **data,
                if (devc->device->dialect == SCPI_DIALECT_HP_66XXB) {
                        /* Evaluate Operational Status Register from a HP 66xxB. */
                        s = g_variant_get_string(*data, NULL);
-                       sr_atoi(s, &oper_cond);
+                       sr_atoi(s, &reg);
                        g_variant_unref(*data);
-                       if (oper_cond & (1 << 8))
+                       if (reg & (1 << 8))
                                *data = g_variant_new_string("CV");
-                       else if (oper_cond & (1 << 10))
+                       else if (reg & (1 << 10))
                                *data = g_variant_new_string("CC");
-                       else if (oper_cond & (1 << 11))
+                       else if (reg & (1 << 11))
                                *data = g_variant_new_string("CC-");
                        else
                                *data = g_variant_new_string("UR");
@@ -463,6 +476,36 @@ static int config_get(uint32_t key, GVariant **data,
                }
        }
 
+       if (cmd == SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE) {
+               if (devc->device->dialect == SCPI_DIALECT_HP_66XXB) {
+                       /* Evaluate Questionable Status Register bit 0 from a HP 66xxB. */
+                       s = g_variant_get_string(*data, NULL);
+                       sr_atoi(s, &reg);
+                       g_variant_unref(*data);
+                       *data = g_variant_new_boolean(reg & (1 << 0));
+               }
+       }
+
+       if (cmd == SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE) {
+               if (devc->device->dialect == SCPI_DIALECT_HP_66XXB) {
+                       /* Evaluate Questionable Status Register bit 1 from a HP 66xxB. */
+                       s = g_variant_get_string(*data, NULL);
+                       sr_atoi(s, &reg);
+                       g_variant_unref(*data);
+                       *data = g_variant_new_boolean(reg & (1 << 1));
+               }
+       }
+
+       if (cmd == SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION_ACTIVE) {
+               if (devc->device->dialect == SCPI_DIALECT_HP_66XXB) {
+                       /* Evaluate Questionable Status Register bit 4 from a HP 66xxB. */
+                       s = g_variant_get_string(*data, NULL);
+                       sr_atoi(s, &reg);
+                       g_variant_unref(*data);
+                       *data = g_variant_new_boolean(reg & (1 << 4));
+               }
+       }
+
        return ret;
 }
 
index 6d52b05bad13c8729f72781232ef846d13da8b28..a72c90a2ffa9fd55f61849a46c1fb7d90901a7d9 100644 (file)
@@ -458,8 +458,11 @@ static const uint32_t hp_6630b_devopts_cg[] = {
        SR_CONF_CURRENT | SR_CONF_GET,
        SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE | SR_CONF_GET,
        SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE | SR_CONF_GET,
+       SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE | SR_CONF_GET,
        SR_CONF_REGULATION | SR_CONF_GET,
 };
 
@@ -519,8 +522,11 @@ static const struct scpi_command hp_6630b_cmd[] = {
        { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":CURR:PROT:STAT?" },
        { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":CURR:PROT:STAT 1" },
        { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":CURR:PROT:STAT 0" },
+       { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, "STAT:QUES:COND?" },
+       { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, "STAT:QUES:COND?" },
        { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":VOLT:PROT?" },
        { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":VOLT:PROT %.6f" },
+       { SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION_ACTIVE, "STAT:QUES:COND?" },
        { SCPI_CMD_GET_OUTPUT_REGULATION, "STAT:OPER:COND?" },
        ALL_ZERO
 };
index 420d5345abf1d38aaca04bf3b5c499ff3eabaf7a..3ffe3cb7292e60a8ab2b34ef1de026fb675f6f18 100644 (file)
@@ -53,6 +53,7 @@ enum pps_scpi_cmds {
        SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION,
        SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE,
        SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE,
+       SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION_ACTIVE,
        SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED,
        SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE,
        SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE,