]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-pps/api.c
scpi-pps: Add profile for Rigol DP821A.
[libsigrok.git] / src / hardware / scpi-pps / api.c
index c8502fc5591474e7a1d7d65dd27590a9c5a42e81..0539e81aaacfc158d3a9e1cd83f52909349f843f 100644 (file)
@@ -30,9 +30,8 @@ static const uint32_t scanopts[] = {
        SR_CONF_SERIALCOMM,
 };
 
-static const uint32_t devopts_driver[] = {
+static const uint32_t drvopts[] = {
        SR_CONF_POWER_SUPPLY,
-       SR_CONF_CONTINUOUS,
 };
 
 static struct pps_channel_instance pci[] = {
@@ -90,8 +89,11 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                return NULL;
        }
 
-       sdi = sr_dev_inst_new(SR_ST_ACTIVE, vendor, hw_info->model,
-                       hw_info->firmware_version);
+       sdi = g_malloc0(sizeof(struct sr_dev_inst));
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(vendor);
+       sdi->model = g_strdup(hw_info->model);
+       sdi->version = g_strdup(hw_info->firmware_version);
        sdi->conn = scpi;
        sdi->driver = di;
        sdi->inst_type = SR_INST_SCPI;
@@ -131,13 +133,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                                continue;
                        g_snprintf(ch_name, 16, "%s%s", pci[i].prefix,
                                        channels[ch_num].name);
-                       ch = sr_channel_new(ch_idx++, SR_CHANNEL_ANALOG, TRUE, ch_name);
+                       ch = sr_channel_new(sdi, ch_idx++, SR_CHANNEL_ANALOG, TRUE,
+                                       ch_name);
                        pch = g_malloc0(sizeof(struct pps_channel));
                        pch->hw_output_idx = ch_num;
                        pch->hwname = channels[ch_num].name;
                        pch->mq = pci[i].mq;
                        ch->priv = pch;
-                       sdi->channels = g_slist_append(sdi->channels, ch);
                }
        }
 
@@ -191,7 +193,7 @@ static int dev_open(struct sr_dev_inst *sdi)
        struct sr_scpi_dev_inst *scpi;
        GVariant *beeper;
 
-       if (sdi->status != SR_ST_ACTIVE)
+       if (sdi->status != SR_ST_INACTIVE)
                return SR_ERR;
 
        scpi = sdi->conn;
@@ -431,7 +433,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_OK;
        } else if (key == SR_CONF_DEVICE_OPTIONS && !sdi) {
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               devopts_driver, ARRAY_SIZE(devopts_driver), sizeof(uint32_t));
+                               drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
                return SR_OK;
        }