acquisition working a bit more now?
This commit is contained in:
parent
acad3c2123
commit
2a815b8a5f
|
@ -358,23 +358,37 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||
{
|
||||
struct dev_context *dc;
|
||||
int rv;
|
||||
|
||||
dc = sdi->priv;
|
||||
|
||||
if (!dc || !dc->ft) return SR_ERR_BUG;
|
||||
|
||||
return scanaquad_acquisition_start(dc);
|
||||
rv = scanaquad_acquisition_start(dc);
|
||||
CHECK_SQ_RETVAL(rv, "Failed to start acquisition");
|
||||
|
||||
std_session_send_df_header(sdi);
|
||||
sr_session_source_add(sdi->session, -1, 0, 0, scanaquad_receive_data, (void *)sdi);
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||
{
|
||||
struct dev_context *dc;
|
||||
int rv;
|
||||
|
||||
dc = sdi->priv;
|
||||
|
||||
if (!dc || !dc->ft) return SR_ERR_BUG;
|
||||
|
||||
return scanaquad_acquisition_stop(sdi, dc);
|
||||
rv = scanaquad_acquisition_stop(sdi, dc);
|
||||
CHECK_SQ_RETVAL(rv, "Failed to stop acquisition");
|
||||
|
||||
sr_session_source_remove(sdi->session, -1);
|
||||
std_session_send_df_end(sdi);
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
static struct sr_dev_driver ikalogic_scanaquad_driver_info = {
|
||||
|
|
|
@ -84,6 +84,7 @@ SR_PRIV void sq_destroy(struct dev_context *dc)
|
|||
do { \
|
||||
__rv = ftdi_read_data(ft, (uint8_t *)(data)+__i, (s)-__i); \
|
||||
CHECK_FTDI_RETVAL(FALSE, ft, __rv, (s)-__i, FALSE); \
|
||||
sr_spew("read_blocking: read %d\n", __rv); \
|
||||
__i += __rv; \
|
||||
} while (__i < s); \
|
||||
__rv;}) \
|
||||
|
@ -260,25 +261,23 @@ SR_PRIV struct ftdi_transfer_control *sq_app_start_capture(struct dev_context *d
|
|||
|
||||
return ftdi_read_data_submit(dc->ft, (uint8_t *)resbuf, 4);
|
||||
}
|
||||
SR_PRIV int sq_app_get_capture_result(struct dev_context *dc, struct ftdi_transfer_control *tc, uint32_t *trig_instant)
|
||||
SR_PRIV int sq_app_get_capture_result(struct dev_context *dc, struct ftdi_transfer_control *tc, const uint8_t *tcbuf, uint32_t *trig_instant)
|
||||
{
|
||||
uint8_t result[4];
|
||||
uint32_t ti;
|
||||
int rv;
|
||||
|
||||
if (!dc || !tc) return SR_ERR;
|
||||
|
||||
if (!tc->completed) return SR_ERR_ARG;
|
||||
//if (!tc->completed) return SR_ERR_ARG;
|
||||
rv = ftdi_transfer_data_done(tc);
|
||||
CHECK_FTDI_RETVAL(FALSE, dc->ft, rv, (size_t)4);
|
||||
|
||||
rv = read_ftdi_blocking(dc->ft, result, sizeof result);
|
||||
CHECK_FTDI_RETVAL(FALSE, dc->ft, rv, sizeof result);
|
||||
|
||||
ti = (uint32_t)result[0] | ((uint32_t)result[1] << 8) | ((uint32_t)result[2] << 16);
|
||||
ti = (uint32_t)tcbuf[0] | ((uint32_t)tcbuf[1] << 8) | ((uint32_t)tcbuf[2] << 16);
|
||||
if (trig_instant) *trig_instant = ti;
|
||||
|
||||
sr_spew("sc/wft -> %06x %02x", ti, result[3]);
|
||||
sr_spew("sc/wft -> %06x %02x", ti, tcbuf[3]);
|
||||
|
||||
return result[3];
|
||||
return tcbuf[3];
|
||||
}
|
||||
SR_PRIV int sq_app_start_generate_inf(struct dev_context *dc)
|
||||
{
|
||||
|
@ -541,6 +540,8 @@ SR_PRIV int scanaquad_cancel_all(struct dev_context *dc)
|
|||
{
|
||||
int rv;
|
||||
|
||||
sr_spew("cancel everything");
|
||||
|
||||
if (dc->tc) {
|
||||
/* TODO: timeout? */
|
||||
ftdi_transfer_data_cancel(dc->tc, NULL);
|
||||
|
@ -639,6 +640,8 @@ SR_PRIV int scanaquad_acquisition_start(struct dev_context *dc)
|
|||
|
||||
if (dc->tc || dc->tcbuf || dc->acq_started) return SR_ERR_BUG;
|
||||
|
||||
sr_spew("data acquisition start");
|
||||
|
||||
rv = scanaquad_cancel_all(dc);
|
||||
CHECK_SQ_RETVAL(rv, "Failed to cancel ongoing ScanaQuad transfers");
|
||||
|
||||
|
@ -706,7 +709,10 @@ SR_PRIV int scanaquad_acquisition_finish(struct sr_dev_inst *sdi, struct dev_con
|
|||
|
||||
if (!dc || !dc->tc) return SR_ERR_BUG;
|
||||
|
||||
rv = ftdi_transfer_data_done(dc->tc);
|
||||
sr_spew("gracefully finish acquisition");
|
||||
|
||||
/* FIXME: handle this in a better way wrt. sq_app_get_capture_result */
|
||||
/*rv = ftdi_transfer_data_done(dc->tc);
|
||||
dc->tc = NULL;
|
||||
if (rv < 0) {
|
||||
sr_err("Coudln't read async FTDI device status (%d): %s",
|
||||
|
@ -724,12 +730,13 @@ SR_PRIV int scanaquad_acquisition_finish(struct sr_dev_inst *sdi, struct dev_con
|
|||
dc->tcbuf = 0;
|
||||
dc->tcsize = 0;
|
||||
return SR_ERR;
|
||||
}
|
||||
}*/
|
||||
|
||||
trig_instant = *(uint32_t *)dc->tcbuf;
|
||||
trig_instant = dc->trig_instant;
|
||||
g_free(dc->tcbuf);
|
||||
dc->tcbuf = 0;
|
||||
dc->tcsize = 0;
|
||||
dc->tc = NULL; /* FIXME */
|
||||
|
||||
sr_spew("trig_instant = %u", trig_instant);
|
||||
|
||||
|
@ -750,6 +757,9 @@ SR_PRIV int scanaquad_acquisition_finish(struct sr_dev_inst *sdi, struct dev_con
|
|||
/* convert from trig_instant units (MS1*16) to bytes */
|
||||
trig_instant = (trig_instant * 2) / 8;
|
||||
|
||||
rv = sq_app_cancel_capture(dc);
|
||||
CHECK_SQ_RETVAL(rv, "Failed to cancel ongoing ScanaQuad transfers");
|
||||
|
||||
rv = sq_app_download_capture(dc, rdata, nbytes);
|
||||
CHECK_SQ_RETVAL(rv, "Failed to download captured samples");
|
||||
|
||||
|
@ -776,6 +786,8 @@ SR_PRIV int scanaquad_acquisition_finish(struct sr_dev_inst *sdi, struct dev_con
|
|||
packet3.type = SR_DF_LOGIC;
|
||||
packet3.payload = &logic3;
|
||||
|
||||
sr_spew("data sendoff!");
|
||||
|
||||
sr_session_send(sdi, &packet1);
|
||||
sr_session_send(sdi, &packet2);
|
||||
sr_session_send(sdi, &packet3);
|
||||
|
@ -789,10 +801,14 @@ SR_PRIV int scanaquad_acquisition_stop(struct sr_dev_inst *sdi, struct dev_conte
|
|||
{
|
||||
int rv;
|
||||
|
||||
rv = sq_app_get_capture_result(dc, dc->tc, (uint32_t *)dc->tcbuf);
|
||||
sr_spew("force-stop acquisition");
|
||||
/* FIXME: stuff below errors. */
|
||||
|
||||
rv = sq_app_get_capture_result(dc, dc->tc, dc->tcbuf, &dc->trig_instant);
|
||||
if (rv == SR_ERR_ARG) { /* still busy */
|
||||
return scanaquad_acquisition_stop(sdi, dc);
|
||||
} else if (rv < SR_OK) {
|
||||
/* FIXME: stuff below errors. */
|
||||
sr_err("Cannot get device state / capture result");
|
||||
return SR_ERR;
|
||||
} else if (rv == SQ_APP_START_CAPTURE_SUCCESS) {
|
||||
|
@ -811,13 +827,15 @@ SR_PRIV int scanaquad_receive_data(int fd, int revents, void *cb_data)
|
|||
|
||||
(void)fd;
|
||||
|
||||
/*sr_spew("receive data");*/
|
||||
|
||||
if (!(sdi = cb_data)) return TRUE;
|
||||
if (!(dc = sdi->priv)) return TRUE;
|
||||
if (!dc->ft) return TRUE;
|
||||
|
||||
if (revents != G_IO_IN) return TRUE;
|
||||
/*if (revents != G_IO_IN) return TRUE;*/
|
||||
|
||||
rv = sq_app_get_capture_result(dc, dc->tc, (uint32_t *)dc->tcbuf);
|
||||
rv = sq_app_get_capture_result(dc, dc->tc, dc->tcbuf, &dc->trig_instant);
|
||||
if (rv == SR_ERR_ARG) { /* still busy */
|
||||
sr_spew("Acquisition still busy...");
|
||||
return TRUE;
|
||||
|
@ -833,6 +851,7 @@ SR_PRIV int scanaquad_receive_data(int fd, int revents, void *cb_data)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
sr_spew("acquisition finished!");
|
||||
sr_dev_acquisition_stop(sdi);
|
||||
return TRUE;
|
||||
} else {
|
||||
|
|
|
@ -43,6 +43,7 @@ struct dev_context {
|
|||
struct ftdi_transfer_control *tc;
|
||||
uint8_t *tcbuf;
|
||||
size_t tcsize;
|
||||
uint32_t trig_instant;
|
||||
|
||||
/* settings for next capture */
|
||||
uint64_t samplerate;
|
||||
|
@ -127,11 +128,11 @@ static inline int sq_bl_spi_xfer_read(struct dev_context *dc)
|
|||
/* 0xf0 0x0X commands */
|
||||
SR_PRIV int sq_app_cancel_capture(struct dev_context *dc);
|
||||
SR_PRIV struct ftdi_transfer_control *sq_app_start_capture(struct dev_context *dc, uint32_t *resbuf);
|
||||
SR_PRIV int sq_app_get_capture_result(struct dev_context *dc, struct ftdi_transfer_control *tc, uint32_t *trig_instant);
|
||||
SR_PRIV int sq_app_get_capture_result(struct dev_context *dc, struct ftdi_transfer_control *tc, const uint8_t *tcbuf, uint32_t *trig_instant);
|
||||
SR_PRIV int sq_app_start_generate_inf(struct dev_context *dc);
|
||||
SR_PRIV struct ftdi_transfer_control *sq_app_start_capgenmix(struct dev_context *dc, uint32_t *resbuf);
|
||||
static inline int sq_app_get_capgenmix_result(struct dev_context *dc, struct ftdi_transfer_control *tc, uint32_t *trig_instant) {
|
||||
return sq_app_get_capture_result(dc, tc, trig_instant);
|
||||
static inline int sq_app_get_capgenmix_result(struct dev_context *dc, struct ftdi_transfer_control *tc, const uint8_t *tcbuf, uint32_t *trig_instant) {
|
||||
return sq_app_get_capture_result(dc, tc, tcbuf, trig_instant);
|
||||
}
|
||||
/* NOTE: at this point, no checks are done whether the length of the data is
|
||||
* consistent with the current capture/genpattern memory size in the
|
||||
|
|
Loading…
Reference in New Issue