]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-pps/api.c
Factor out std_session_send_df_end() helper.
[libsigrok.git] / src / hardware / scpi-pps / api.c
index 294c5a0e8e4617c8cb4f15715169347b7bcccf51..475cdca3eb9064bbb8cfac3b90b2d8c1b07a3196 100644 (file)
@@ -91,7 +91,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        }
 
        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);
@@ -168,7 +167,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        hw_info = NULL;
 
        scpi_cmd(sdi, devc->device->commands, SCPI_CMD_LOCAL);
-       sr_scpi_close(scpi);
 
        return sdi;
 }
@@ -262,7 +260,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
        const GVariantType *gvtype;
        unsigned int i;
        int cmd, ret;
-       char *s;
+       const char *s;
 
        if (!sdi)
                return SR_ERR_ARG;
@@ -366,17 +364,19 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                 * the Rigol notation.
                 */
                s = g_variant_get_string(*data, NULL);
-               if (!strcmp(s, "CV") || !strcmp(s, "VOLT")) {
+               if (!strcmp(s, "VOLT")) {
+                       g_variant_unref(*data);
                        *data = g_variant_new_string("CV");
-               } else if (!strcmp(s, "CC") || !strcmp(s, "CURR")) {
+               } else if (!strcmp(s, "CURR")) {
+                       g_variant_unref(*data);
                        *data = g_variant_new_string("CC");
-               } else if (!strcmp(s, "UR")) {
-                       *data = g_variant_new_string("UR");
-               } else {
+               }
+
+               s = g_variant_get_string(*data, NULL);
+               if (strcmp(s, "CV") && strcmp(s, "CC") && strcmp(s, "UR")) {
                        sr_dbg("Unknown response to SCPI_CMD_GET_OUTPUT_REGULATION: %s", s);
                        ret = SR_ERR_DATA;
                }
-               g_free(s);
        }
 
        return ret;
@@ -400,7 +400,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                select_channel(sdi, cg->channels->data);
 
        devc = sdi->priv;
-       ret = SR_OK;
+
        switch (key) {
        case SR_CONF_ENABLED:
                if (g_variant_get_boolean(data))
@@ -618,7 +618,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
-       struct sr_datafeed_packet packet;
        struct sr_scpi_dev_inst *scpi;
        float f;
 
@@ -637,8 +636,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
        sr_scpi_get_float(scpi, NULL, &f);
        sr_scpi_source_remove(sdi->session, scpi);
 
-       packet.type = SR_DF_END;
-       sr_session_send(sdi, &packet);
+       std_session_send_df_end(sdi, LOG_PREFIX);
 
        return SR_OK;
 }