]> sigrok.org Git - libsigrok.git/blobdiff - hardware/nexus-osciprime/api.c
Enforce open device before config_set()/dev_acquisition_start()
[libsigrok.git] / hardware / nexus-osciprime / api.c
index c1de7b7762c0dc9d0bfb86fa1770205b872ba70f..b81b9e88c5f440d79246c35fc1ba6473069c8e69 100644 (file)
@@ -223,7 +223,7 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
 {
 
        /* TODO */
-       (void)sdi;
+       sdi->status = SR_ST_ACTIVE;
 
        return SR_OK;
 }
@@ -232,7 +232,7 @@ static int hw_dev_close(struct sr_dev_inst *sdi)
 {
 
        /* TODO */
-       (void)sdi;
+    sdi->status = SR_ST_INACTIVE;
 
        return SR_OK;
 }
@@ -253,17 +253,14 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
        /* TODO */
        (void)data;
 
-       if (sdi->status != SR_ST_ACTIVE) {
-               sr_err("Device inactive, can't set config options.");
-               return SR_ERR;
-       }
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
 
        ret = SR_OK;
        switch (id) {
 
        default:
-               sr_err("Unknown hardware capability: %d.", id);
-               ret = SR_ERR_ARG;
+               ret = SR_ERR_NA;
        }
 
        return ret;
@@ -271,12 +268,12 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
 
 static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
 {
-
        (void)sdi;
+       (void)data;
 
        switch (key) {
        default:
-               return SR_ERR_ARG;
+               return SR_ERR_NA;
        }
 
        return SR_OK;
@@ -286,9 +283,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
                                    void *cb_data)
 {
        /* TODO */
-       (void)sdi;
        (void)cb_data;
 
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
+
        return SR_OK;
 }