From: Frank Stettner Date: Tue, 9 Apr 2019 13:47:19 +0000 (+0200) Subject: scpi-pps: Add config keys SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE, X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8b5eadf427323318967da09a2824e57920e70a7d;p=libsigrok.git scpi-pps: Add config keys SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE, SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE and SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE to HP 66xxB power supplies. --- diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 22c79740..02a34499 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -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, ®); 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, ®); + 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, ®); + 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, ®); + g_variant_unref(*data); + *data = g_variant_new_boolean(reg & (1 << 4)); + } + } + return ret; } diff --git a/src/hardware/scpi-pps/profiles.c b/src/hardware/scpi-pps/profiles.c index 6d52b05b..a72c90a2 100644 --- a/src/hardware/scpi-pps/profiles.c +++ b/src/hardware/scpi-pps/profiles.c @@ -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 }; diff --git a/src/hardware/scpi-pps/protocol.h b/src/hardware/scpi-pps/protocol.h index 420d5345..3ffe3cb7 100644 --- a/src/hardware/scpi-pps/protocol.h +++ b/src/hardware/scpi-pps/protocol.h @@ -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,