for (i = 0; i < num_channel_groups; i++) {
cgs = &channel_groups[i];
- cg = g_malloc0(sizeof(struct sr_channel_group));
- cg->name = g_strdup(cgs->name);
+ cg = sr_channel_group_new(sdi, cgs->name, NULL);
for (j = 0, mask = 1; j < 64; j++, mask <<= 1) {
if (cgs->channel_index_mask & mask) {
for (l = sdi->channels; l; l = l->next) {
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;
pcg = g_malloc0(sizeof(struct pps_channel_group));
pcg->features = cgs->features;
cg->priv = pcg;
- sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
}
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);
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);
}
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);
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);
int cmd, ret;
const char *s;
int reg;
+ gboolean is_hmp_sqii;
if (!sdi)
return SR_ERR_ARG;
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;
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;
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);
/*
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-") &&
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, ®);
{
struct dev_context *devc;
struct sr_channel *ch;
+ struct pps_channel *pch;
const struct channel_spec *ch_spec;
int i;
const char *s[16];
* 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:
/* Prime the pipe with the first channel. */
devc->cur_acquisition_channel = sr_next_enabled_channel(sdi, NULL);
- /* Device specific initialization before aquisition starts. */
- if (devc->device->init_aquisition)
- devc->device->init_aquisition(sdi);
+ /* Device specific initialization before acquisition starts. */
+ if (devc->device->init_acquisition)
+ devc->device->init_acquisition(sdi);
if ((ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 10,
scpi_pps_receive_data, (void *)sdi)) != SR_OK)