X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fscpi-pps%2Fapi.c;h=aa5b945a3349cee0573491709d304efa424ccdc7;hb=deb7615262ac4f9cc0750a08351afa7cbf9c34d5;hp=2ea124a12926e5ca022d854f6b2c7895649ad7a2;hpb=fd2433153a3e2c2681d637f715c19f2b6f40fcc9;p=libsigrok.git diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 2ea124a1..aa5b945a 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -153,7 +153,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi, ch = l->data; pch = ch->priv; /* Add mqflags from channel_group_spec only to voltage - * and current channels + * and current channels. */ if (pch->mq == SR_MQ_VOLTAGE || pch->mq == SR_MQ_CURRENT) pch->mqflags = cgs->mqflags; @@ -173,7 +173,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi, sr_scpi_hw_info_free(hw_info); hw_info = NULL; - /* Don't send SCPI_CMD_LOCAL for HP 66xxB devices using SCPI over GPIB */ + /* Don't send SCPI_CMD_LOCAL for HP 66xxB using SCPI over GPIB. */ if (!(devc->device->dialect == SCPI_DIALECT_HP_66XXB && scpi->transport == SCPI_TRANSPORT_LIBGPIB)) sr_scpi_cmd(sdi, devc->device->commands, 0, NULL, SCPI_CMD_LOCAL); @@ -254,6 +254,17 @@ static GSList *scan_scpi_pps(struct sr_dev_driver *di, GSList *options) static GSList *scan_hpib_pps(struct sr_dev_driver *di, GSList *options) { + const char *conn; + + /* + * Only scan for HP-IB devices when conn= was specified, to not + * break SCPI devices' operation. + */ + conn = NULL; + (void)sr_serial_extract_options(options, &conn, NULL); + if (!conn) + return NULL; + return sr_scpi_scan(di->context, options, probe_hpib_pps_device); } @@ -269,7 +280,7 @@ static int dev_open(struct sr_dev_inst *sdi) devc = sdi->priv; - /* Don't send SCPI_CMD_REMOTE for HP 66xxB devices using SCPI over GPIB */ + /* Don't send SCPI_CMD_REMOTE for HP 66xxB using SCPI over GPIB. */ if (!(devc->device->dialect == SCPI_DIALECT_HP_66XXB && scpi->transport == SCPI_TRANSPORT_LIBGPIB)) sr_scpi_cmd(sdi, devc->device->commands, 0, NULL, SCPI_CMD_REMOTE); @@ -303,7 +314,7 @@ static int dev_close(struct sr_dev_inst *sdi) sr_scpi_cmd(sdi, devc->device->commands, 0, NULL, SCPI_CMD_BEEPER_ENABLE); - /* Don't send SCPI_CMD_LOCAL for HP 66xxB devices using SCPI over GPIB */ + /* Don't send SCPI_CMD_LOCAL for HP 66xxB using SCPI over GPIB. */ if (!(devc->device->dialect == SCPI_DIALECT_HP_66XXB && scpi->transport == SCPI_TRANSPORT_LIBGPIB)) sr_scpi_cmd(sdi, devc->device->commands, 0, NULL, SCPI_CMD_LOCAL); @@ -333,6 +344,7 @@ static int config_get(uint32_t key, GVariant **data, int cmd, ret; const char *s; int reg; + gboolean is_hmp_sqii; if (!sdi) return SR_ERR_ARG; @@ -391,6 +403,11 @@ static int config_get(uint32_t key, GVariant **data, cmd = SCPI_CMD_GET_CURRENT_LIMIT; break; case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED: + if (devc->device->dialect == SCPI_DIALECT_HMP) { + /* OVP is always enabled. */ + *data = g_variant_new_boolean(TRUE); + return 0; + } gvtype = G_VARIANT_TYPE_BOOLEAN; cmd = SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED; break; @@ -423,12 +440,18 @@ static int config_get(uint32_t key, GVariant **data, cmd = SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD; break; case SR_CONF_OVER_TEMPERATURE_PROTECTION: + if (devc->device->dialect == SCPI_DIALECT_HMP) { + /* OTP is always enabled. */ + *data = g_variant_new_boolean(TRUE); + return 0; + } 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 || - devc->device->dialect == SCPI_DIALECT_HP_COMP) + devc->device->dialect == SCPI_DIALECT_HP_COMP || + devc->device->dialect == SCPI_DIALECT_HMP) gvtype = G_VARIANT_TYPE_STRING; else gvtype = G_VARIANT_TYPE_BOOLEAN; @@ -451,8 +474,22 @@ static int config_get(uint32_t key, GVariant **data, channel_group_name = g_strdup(cg->name); } - ret = sr_scpi_cmd_resp(sdi, devc->device->commands, - channel_group_cmd, channel_group_name, data, gvtype, cmd); + is_hmp_sqii = FALSE; + is_hmp_sqii |= cmd == SCPI_CMD_GET_OUTPUT_REGULATION; + is_hmp_sqii |= cmd == SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION_ACTIVE; + is_hmp_sqii &= devc->device->dialect == SCPI_DIALECT_HMP; + if (is_hmp_sqii) { + if (!cg) { + /* STAT:QUES:INST:ISUMx query requires channel spec. */ + sr_err("Need a channel group for regulation or OTP-active query."); + return SR_ERR_NA; + } + ret = sr_scpi_cmd_resp(sdi, devc->device->commands, + 0, NULL, data, gvtype, cmd, channel_group_name); + } else { + ret = sr_scpi_cmd_resp(sdi, devc->device->commands, + channel_group_cmd, channel_group_name, data, gvtype, cmd); + } g_free(channel_group_name); /* @@ -504,6 +541,18 @@ static int config_get(uint32_t key, GVariant **data, else *data = g_variant_new_string("UR"); } + if (devc->device->dialect == SCPI_DIALECT_HMP) { + /* Evaluate Condition Status Register from a HMP series device. */ + s = g_variant_get_string(*data, NULL); + sr_atoi(s, ®); + g_variant_unref(*data); + if (reg & (1 << 0)) + *data = g_variant_new_string("CC"); + else if (reg & (1 << 1)) + *data = g_variant_new_string("CV"); + else + *data = g_variant_new_string("UR"); + } s = g_variant_get_string(*data, NULL); if (g_strcmp0(s, "CV") && g_strcmp0(s, "CC") && g_strcmp0(s, "CC-") && @@ -556,7 +605,8 @@ static int config_get(uint32_t key, GVariant **data, g_variant_unref(*data); *data = g_variant_new_boolean(reg & (1 << 4)); } - if (devc->device->dialect == SCPI_DIALECT_HP_66XXB) { + if (devc->device->dialect == SCPI_DIALECT_HP_66XXB || + devc->device->dialect == SCPI_DIALECT_HMP) { /* Evaluate Questionable Status Register bit 4 from a HP 66xxB. */ s = g_variant_get_string(*data, NULL); sr_atoi(s, ®); @@ -674,6 +724,7 @@ static int config_list(uint32_t key, GVariant **data, { struct dev_context *devc; struct sr_channel *ch; + struct pps_channel *pch; const struct channel_spec *ch_spec; int i; const char *s[16]; @@ -721,9 +772,10 @@ static int config_list(uint32_t key, GVariant **data, * specification for use in series or parallel mode. */ ch = cg->channels->data; + pch = ch->priv; if (!devc || !devc->device) return SR_ERR_ARG; - ch_spec = &(devc->device->channels[ch->index]); + ch_spec = &(devc->device->channels[pch->hw_output_idx]); switch (key) { case SR_CONF_DEVICE_OPTIONS: