]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-pps/api.c
scpi-pps: Change some floats to doubles.
[libsigrok.git] / src / hardware / scpi-pps / api.c
index 7448796298ddb082a777d123ed75b428e303bb0e..3ac44a3c01a77b16e959a8ce662285d4bf199dd7 100644 (file)
@@ -439,7 +439,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                return SR_ERR_ARG;
 
        if (cg)
-               /* Channel group specified. */
                select_channel(sdi, cg->channels->data);
 
        devc = sdi->priv;
@@ -515,15 +514,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        struct dev_context *devc;
        struct sr_channel *ch;
        const struct channel_spec *ch_spec;
-       GVariant *gvar;
-       GVariantBuilder gvb;
        int i;
        const char *s[16];
 
        devc = (sdi) ? sdi->priv : NULL;
 
        if (!cg) {
-               /* No channel group: global options. */
                switch (key) {
                case SR_CONF_SCAN_OPTIONS:
                case SR_CONF_DEVICE_OPTIONS:
@@ -555,7 +551,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        return SR_ERR_NA;
                }
        } else {
-               /* Channel group specified. */
                /*
                 * Per-channel-group options depending on a channel are actually
                 * done with the first channel. Channel groups in PPS can have
@@ -563,6 +558,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                 * specification for use in series or parallel mode.
                 */
                ch = cg->channels->data;
+               ch_spec = &(devc->device->channels[ch->index]);
 
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
@@ -571,34 +567,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                                        sizeof(uint32_t));
                        break;
                case SR_CONF_VOLTAGE_TARGET:
-                       ch_spec = &(devc->device->channels[ch->index]);
-                       g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
-                       /* Min, max, write resolution. */
-                       for (i = 0; i < 3; i++) {
-                               gvar = g_variant_new_double(ch_spec->voltage[i]);
-                               g_variant_builder_add_value(&gvb, gvar);
-                       }
-                       *data = g_variant_builder_end(&gvb);
+                       *data = std_gvar_min_max_step_array(ch_spec->voltage);
                        break;
                case SR_CONF_OUTPUT_FREQUENCY_TARGET:
-                       ch_spec = &(devc->device->channels[ch->index]);
-                       g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
-                       /* Min, max, write resolution. */
-                       for (i = 0; i < 3; i++) {
-                               gvar = g_variant_new_double(ch_spec->frequency[i]);
-                               g_variant_builder_add_value(&gvb, gvar);
-                       }
-                       *data = g_variant_builder_end(&gvb);
+                       *data = std_gvar_min_max_step_array(ch_spec->frequency);
                        break;
                case SR_CONF_CURRENT_LIMIT:
-                       g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
-                       /* Min, max, step. */
-                       for (i = 0; i < 3; i++) {
-                               ch_spec = &(devc->device->channels[ch->index]);
-                               gvar = g_variant_new_double(ch_spec->current[i]);
-                               g_variant_builder_add_value(&gvb, gvar);
-                       }
-                       *data = g_variant_builder_end(&gvb);
+                       *data = std_gvar_min_max_step_array(ch_spec->current);
                        break;
                default:
                        return SR_ERR_NA;
@@ -647,7 +622,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        struct sr_scpi_dev_inst *scpi;
-       float f;
+       double d;
 
        scpi = sdi->conn;
 
@@ -656,7 +631,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
         * to avoid leaving the device in a state where it's not expecting
         * commands.
         */
-       sr_scpi_get_float(scpi, NULL, &f);
+       sr_scpi_get_double(scpi, NULL, &d);
        sr_scpi_source_remove(sdi->session, scpi);
 
        std_session_send_df_end(sdi);