]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/rohde-schwarz-sme-0x/api.c
sr_dev_open(): Set status to SR_ST_ACTIVE upon success.
[libsigrok.git] / src / hardware / rohde-schwarz-sme-0x / api.c
index 58a636d039cf0b0330ee13cc12b0e5e7178bcab6..3ca5441ad2fb2ad6d91e2f500a47220033f23171 100644 (file)
@@ -71,6 +71,10 @@ static const uint32_t scanopts[] = {
        SR_CONF_SERIALCOMM,
 };
 
+static const uint32_t drvopts[] = {
+        SR_CONF_SIGNAL_GENERATOR,
+};
+
 static const uint32_t devopts[] = {
        SR_CONF_OUTPUT_FREQUENCY | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_AMPLITUDE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
@@ -140,12 +144,8 @@ static struct sr_dev_inst *rs_probe_serial_device(struct sr_scpi_dev_inst *scpi)
        return sdi;
 
 fail:
-       if (hw_info)
-               sr_scpi_hw_info_free(hw_info);
-
-       if (sdi)
-               sr_dev_inst_free(sdi);
-
+       sr_scpi_hw_info_free(hw_info);
+       sr_dev_inst_free(sdi);
        g_free(devc);
        return NULL;
 }
@@ -162,19 +162,11 @@ static int dev_clear(const struct sr_dev_driver *di)
 
 static int dev_open(struct sr_dev_inst *sdi)
 {
-       if ((sdi->status != SR_ST_ACTIVE) && (sr_scpi_open(sdi->conn) != SR_OK))
-               return SR_ERR;
-
-       sdi->status = SR_ST_ACTIVE;
-
-       return SR_OK;
+       return sr_scpi_open(sdi->conn);
 }
 
 static int dev_close(struct sr_dev_inst *sdi)
 {
-       if (sdi->status == SR_ST_INACTIVE)
-               return SR_OK;
-
        sr_scpi_close(sdi->conn);
 
        sdi->status = SR_ST_INACTIVE;
@@ -215,9 +207,6 @@ static int config_set(uint32_t key, GVariant *data,
        if (!sdi)
                return SR_ERR_ARG;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        switch (key) {
        case SR_CONF_OUTPUT_FREQUENCY:
                value_f = g_variant_get_double(data);
@@ -240,6 +229,13 @@ static int config_list(uint32_t key, GVariant **data,
        (void)sdi;
        (void)cg;
 
+       /* Return drvopts without sdi (and devopts with sdi, see below). */
+       if (key == SR_CONF_DEVICE_OPTIONS && !sdi) {
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+                               drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
+               return SR_OK;
+       }
+
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -258,8 +254,7 @@ static int config_list(uint32_t key, GVariant **data,
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
+       (void)sdi;
 
        return SR_OK;
 }