]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-pps/api.c
scpi-pps: Fix broken channel selection code.
[libsigrok.git] / src / hardware / scpi-pps / api.c
index a35052dfebbb71215058ab2810b3640d7c768053..c6d5a73e5e6c8efe9c9505e1224bc0e725cb2746 100644 (file)
@@ -2,6 +2,7 @@
  * This file is part of the libsigrok project.
  *
  * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
+ * Copyright (C) 2017 Frank Stettner <frank-stettner@gmx.net>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -99,6 +100,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi,
 
        devc = g_malloc0(sizeof(struct dev_context));
        devc->device = device;
+       sr_sw_limits_init(&devc->limits);
        sdi->priv = devc;
 
        if (device->num_channels) {
@@ -399,6 +401,8 @@ static int config_get(uint32_t key, GVariant **data,
        case SR_CONF_REGULATION:
                gvtype = G_VARIANT_TYPE_STRING;
                cmd = SCPI_CMD_GET_OUTPUT_REGULATION;
+       default:
+               return sr_sw_limits_config_get(&devc->limits, key, data);
        }
        if (!gvtype)
                return SR_ERR_NA;
@@ -532,7 +536,7 @@ static int config_set(uint32_t key, GVariant *data,
                                        SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE);
                break;
        default:
-               ret = SR_ERR_NA;
+               ret = sr_sw_limits_config_set(&devc->limits, key, data);
        }
 
        g_free(channel_group_name);
@@ -609,6 +613,12 @@ static int config_list(uint32_t key, GVariant **data,
                case SR_CONF_CURRENT_LIMIT:
                        *data = std_gvar_min_max_step_array(ch_spec->current);
                        break;
+               case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
+                       *data = std_gvar_min_max_step_array(ch_spec->ovp);
+                       break;
+               case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
+                       *data = std_gvar_min_max_step_array(ch_spec->ocp);
+                       break;
                default:
                        return SR_ERR_NA;
                }
@@ -633,6 +643,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
                        scpi_pps_receive_data, (void *)sdi)) != SR_OK)
                return ret;
        std_session_send_df_header(sdi);
+       sr_sw_limits_acquisition_start(&devc->limits);
 
        return SR_OK;
 }
@@ -640,18 +651,9 @@ 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;
-       double d;
 
        scpi = sdi->conn;
 
-       /*
-        * A requested value is certainly on the way. Retrieve it now,
-        * to avoid leaving the device in a state where it's not expecting
-        * commands.
-        *
-        * TODO: Doesn't work for (at least) the HP 66XXB models.
-        */
-       sr_scpi_get_double(scpi, NULL, &d);
        sr_scpi_source_remove(sdi->session, scpi);
 
        std_session_send_df_end(sdi);