]> sigrok.org Git - libsigrok.git/commitdiff
rdtech-dps: clear the "acquisition started" condition
authorGerhard Sittig <redacted>
Thu, 28 Sep 2023 10:48:10 +0000 (12:48 +0200)
committerGerhard Sittig <redacted>
Thu, 28 Sep 2023 11:43:50 +0000 (13:43 +0200)
The 'acquisition_started' condition was set when the first acquisition
attempted to start, but was never cleared. Adjust error paths in the
acquisition start and the stop code path to update that variable.

src/hardware/rdtech-dps/api.c
src/hardware/rdtech-dps/protocol.c

index 80290b4d52c5a6a56fabc2e02871b81f2055e842..c55b589655cd579c2e40ca578082f439be6acaac 100644 (file)
@@ -580,16 +580,22 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        modbus = sdi->conn;
        devc = sdi->priv;
 
+       devc->acquisition_started = TRUE;
+
        /* Seed internal state from current data. */
        ret = rdtech_dps_seed_receive(sdi);
-       if (ret != SR_OK)
+       if (ret != SR_OK) {
+               devc->acquisition_started = FALSE;
                return ret;
+       }
 
        /* Register the periodic data reception callback. */
        ret = sr_modbus_source_add(sdi->session, modbus, G_IO_IN, 10,
                        rdtech_dps_receive_data, (void *)sdi);
-       if (ret != SR_OK)
+       if (ret != SR_OK) {
+               devc->acquisition_started = FALSE;
                return ret;
+       }
 
        sr_sw_limits_acquisition_start(&devc->limits);
        std_session_send_df_header(sdi);
@@ -599,9 +605,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
+       struct dev_context *devc;
        struct sr_modbus_dev_inst *modbus;
 
+       devc = sdi->priv;
+
        std_session_send_df_end(sdi);
+       devc->acquisition_started = FALSE;
 
        modbus = sdi->conn;
        sr_modbus_source_remove(sdi->session, modbus);
index f2b492f579ad361d3033702a034fd594d11d238f..da62b1b42cd20a76eb8a12167ec625d00d0f675a 100644 (file)
@@ -694,7 +694,6 @@ SR_PRIV int rdtech_dps_seed_receive(const struct sr_dev_inst *sdi)
        if (!sdi || !sdi->priv)
                return SR_ERR_ARG;
        devc = sdi->priv;
-       devc->acquisition_started = TRUE;
 
        ret = rdtech_dps_get_state(sdi, &state, ST_CTX_PRE_ACQ);
        if (ret != SR_OK)