From: Gerhard Sittig Date: Thu, 28 Sep 2023 10:48:10 +0000 (+0200) Subject: rdtech-dps: clear the "acquisition started" condition X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=caf54ad394a7bd1baa9b4b134cf279e845df8f45;p=libsigrok.git rdtech-dps: clear the "acquisition started" condition 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. --- diff --git a/src/hardware/rdtech-dps/api.c b/src/hardware/rdtech-dps/api.c index 80290b4d..c55b5896 100644 --- a/src/hardware/rdtech-dps/api.c +++ b/src/hardware/rdtech-dps/api.c @@ -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); diff --git a/src/hardware/rdtech-dps/protocol.c b/src/hardware/rdtech-dps/protocol.c index f2b492f5..da62b1b4 100644 --- a/src/hardware/rdtech-dps/protocol.c +++ b/src/hardware/rdtech-dps/protocol.c @@ -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)