asix-sigma: download sample data upon user initiated stop, too
When the acquisition was stopped before a configured limit was reached, no sample data was retrieved. This is because the api.c stop routine did unregister the receive callback. Pass the stop request to the receive routine instead when stop is called while the acquisition is still running. Have sample data downloaded very much like it's done for reached limits, and existing logic will run the stop routine again after state was advanced to "idle". Extend the 'state' tracking while we are here, mark sample download as well (that was omitted in the previous implementation). Though the omission was non-fatal. Move the release of 'dram_line' to some earlier location (as soon as the resource is not needed any longer), before some rather complex calls to other routines will execute. Reported-By: Michael Kaplan <M.KAPLAN@evva.com>
This commit is contained in:
parent
379e95c587
commit
dde0175d19
|
@ -363,9 +363,20 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
|||
struct dev_context *devc;
|
||||
|
||||
devc = sdi->priv;
|
||||
devc->state.state = SIGMA_IDLE;
|
||||
|
||||
sr_session_source_remove(sdi->session, -1);
|
||||
/*
|
||||
* When acquisition is currently running, keep the receive
|
||||
* routine registered and have it stop the acquisition upon the
|
||||
* next invocation. Else unregister the receive routine here
|
||||
* already. The detour is required to have sample data retrieved
|
||||
* for forced acquisition stops.
|
||||
*/
|
||||
if (devc->state.state == SIGMA_CAPTURE) {
|
||||
devc->state.state = SIGMA_STOPPING;
|
||||
} else {
|
||||
devc->state.state = SIGMA_IDLE;
|
||||
sr_session_source_remove(sdi->session, -1);
|
||||
}
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
|
|
@ -1017,6 +1017,7 @@ static int download_capture(struct sr_dev_inst *sdi)
|
|||
return FALSE;
|
||||
|
||||
sr_info("Downloading sample data.");
|
||||
devc->state.state = SIGMA_DOWNLOAD;
|
||||
|
||||
/*
|
||||
* Ask the hardware to stop data acquisition. Reception of the
|
||||
|
@ -1097,13 +1098,13 @@ static int download_capture(struct sr_dev_inst *sdi)
|
|||
|
||||
dl_lines_done += dl_lines_curr;
|
||||
}
|
||||
g_free(dram_line);
|
||||
|
||||
std_session_send_df_end(sdi);
|
||||
|
||||
devc->state.state = SIGMA_IDLE;
|
||||
sr_dev_acquisition_stop(sdi);
|
||||
|
||||
g_free(dram_line);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1146,6 +1147,14 @@ SR_PRIV int sigma_receive_data(int fd, int revents, void *cb_data)
|
|||
if (devc->state.state == SIGMA_IDLE)
|
||||
return TRUE;
|
||||
|
||||
/*
|
||||
* When the application has requested to stop the acquisition,
|
||||
* then immediately start downloading sample data. Otherwise
|
||||
* keep checking configured limits which will terminate the
|
||||
* acquisition and initiate download.
|
||||
*/
|
||||
if (devc->state.state == SIGMA_STOPPING)
|
||||
return download_capture(sdi);
|
||||
if (devc->state.state == SIGMA_CAPTURE)
|
||||
return sigma_capture_mode(sdi);
|
||||
|
||||
|
|
|
@ -246,9 +246,9 @@ struct sigma_state {
|
|||
SIGMA_UNINITIALIZED = 0,
|
||||
SIGMA_IDLE,
|
||||
SIGMA_CAPTURE,
|
||||
SIGMA_STOPPING,
|
||||
SIGMA_DOWNLOAD,
|
||||
} state;
|
||||
|
||||
uint16_t lastts;
|
||||
uint16_t lastsample;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue