From: lelazary Date: Sun, 6 Jan 2013 02:12:45 +0000 (-0800) Subject: Eveything seems to work now except for triggers. X-Git-Tag: dsupstream~368 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5a24e89ca463ba7acb465f4bc9953e2da9c09e45;p=libsigrok.git Eveything seems to work now except for triggers. --- diff --git a/hardware/link-mso19/api.c b/hardware/link-mso19/api.c index c6d92fd1..9e599c61 100644 --- a/hardware/link-mso19/api.c +++ b/hardware/link-mso19/api.c @@ -41,27 +41,7 @@ SR_PRIV const char *mso19_probe_names[NUM_PROBES + 1] = { static const struct sr_samplerates samplerates = { SR_HZ(100), SR_MHZ(200), - SR_HZ(1), - //SR_HZ(100), - //SR_HZ(200), - //SR_HZ(500), - //SR_KHZ(1), - //SR_KHZ(2), - //SR_KHZ(5), - //SR_KHZ(10), - //SR_KHZ(20), - //SR_KHZ(50), - //SR_KHZ(100), - //SR_KHZ(200), - //SR_KHZ(500), - //SR_MHZ(1), - //SR_MHZ(2), - //SR_MHZ(5), - //SR_MHZ(10), - //SR_MHZ(20), - //SR_MHZ(50), - //SR_MHZ(100), - //SR_MHZ(200), + SR_HZ(100), NULL, }; @@ -70,8 +50,6 @@ static struct sr_dev_driver *di = &link_mso19_driver_info; static int hw_init(struct sr_context *sr_ctx) { - printf("Init driver\n"); - struct drv_context *drvc; if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) { @@ -86,18 +64,10 @@ static int hw_init(struct sr_context *sr_ctx) static GSList *hw_scan(GSList *options) { - //struct sr_hwopt *opt; - //struct sr_probe *probe; - //GPollFD probefd; - //int ret, i; - //char buf[8]; - //struct udev *udev; int i; (void)options; GSList *devices = NULL; - - sr_info("Checking for link mso19\n"); const char* conn = NULL; const char* serialcomm = NULL; @@ -154,6 +124,7 @@ static GSList *hw_scan(GSList *options) char path[32]; snprintf(path, sizeof(path), "/dev/%s", sysname); + conn = path; size_t s = strcspn(iProduct, " "); char product[32]; @@ -217,21 +188,17 @@ static GSList *hw_scan(GSList *options) sdi->probes = g_slist_append(sdi->probes, probe); } - - printf("Add the context\n"); //Add the driver struct drv_context *drvc = di->priv; drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); } - - printf("Return devices\n"); + return devices; } static GSList *hw_dev_list(void) { - printf("Dev list\n"); struct drv_context *drvc; drvc = di->priv; @@ -241,7 +208,6 @@ static GSList *hw_dev_list(void) static int hw_dev_open(struct sr_dev_inst *sdi) { - printf("Dev opewn\n"); struct dev_context *devc; devc = sdi->priv; @@ -287,7 +253,6 @@ static int hw_dev_close(struct sr_dev_inst *sdi) static int hw_cleanup(void) { - printf("*Dev clearup\n"); GSList *l; struct sr_dev_inst *sdi; struct drv_context *drvc; @@ -326,8 +291,6 @@ static int hw_info_get(int info_id, const void **data, { struct dev_context *devc; - printf("Get info\n"); - switch (info_id) { case SR_DI_HWCAPS: *data = hwcaps; @@ -403,10 +366,10 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, if (sdi->status != SR_ST_ACTIVE) return SR_ERR; - //TODO if (ols_configure_probes(sdi) != SR_OK) { - //TODO sr_err("Failed to configure probes."); - //TODO return SR_ERR; - //TODO } + if (mso_configure_probes(sdi) != SR_OK) { + sr_err("Failed to configure probes."); + return SR_ERR; + } /* * Enable/disable channel groups in the flag register according to the @@ -511,7 +474,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, /* TODO: This stops acquisition on ALL devices, ignoring dev_index. */ static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) { - printf("Accuqstion stop\n"); /* Avoid compiler warnings. */ (void)cb_data; diff --git a/hardware/link-mso19/protocol.c b/hardware/link-mso19/protocol.c index 1b20ac9b..f8936ae7 100644 --- a/hardware/link-mso19/protocol.c +++ b/hardware/link-mso19/protocol.c @@ -335,11 +335,13 @@ SR_PRIV int mso_check_trigger(struct sr_serial_dev_inst *serial, uint8_t *info) int ret; sr_dbg("Requesting trigger state."); + printf("Send Controll message\n"); ret = mso_send_control_message(serial, ARRAY_AND_SIZE(ops)); if (info == NULL || ret != SR_OK) return ret; + printf("REad buffer\n"); uint8_t buf = 0; if (serial_read(serial, &buf, 1) != 1) /* FIXME: Need timeout */ ret = SR_ERR; @@ -377,19 +379,23 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data) uint8_t in[1024]; size_t s = serial_read(devc->serial, in, sizeof(in)); + if (s <= 0) return FALSE; - /* No samples */ + /* Check if we triggered, then send a command that we are ready + * to read the data */ if (devc->trigger_state != MSO_TRIGGER_DATAREADY) { devc->trigger_state = in[0]; + printf("Got %c for trigger \n", in[0]); if (devc->trigger_state == MSO_TRIGGER_DATAREADY) { + printf("Trigger is ready %c\n", MSO_TRIGGER_DATAREADY); mso_read_buffer(sdi); devc->buffer_n = 0; } else { mso_check_trigger(devc->serial, NULL); } - return FALSE; + return TRUE; } /* the hardware always dumps 1024 samples, 24bits each */ @@ -398,8 +404,9 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data) devc->buffer_n += s; } if (devc->buffer_n < 3072) - return FALSE; + return TRUE; + printf("Got samples, write out the data\n"); /* do the conversion */ uint8_t logic_out[1024]; double analog_out[1024]; @@ -416,6 +423,7 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data) logic.length = 1024; logic.unitsize = 1; logic.data = logic_out; + printf("Send Data\n"); sr_session_send(cb_data, &packet); // Dont bother fixing this yet, keep it "old style" @@ -427,8 +435,75 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data) sr_session_send(ctx->session_dev_id, &packet); */ - packet.type = SR_DF_END; - sr_session_send(devc->session_dev_id, &packet); + //printf("Send END\n"); + //packet.type = SR_DF_END; + //sr_session_send(devc->session_dev_id, &packet); + // serial_flush(devc->serial); + // abort_acquisition(sdi); + // serial_close(devc->serial); + + return FALSE; + printf("REturn \n"); return TRUE; } + +SR_PRIV int mso_configure_probes(const struct sr_dev_inst *sdi) +{ + + struct dev_context *devc; + struct sr_probe *probe; + GSList *l; + int probe_bit, stage, i; + char *tc; + + /* + devc = sdi->priv; + for (i = 0; i < NUM_TRIGGER_STAGES; i++) { + devc->la_trigger_mask[i] = 0; + devc->la_trigger[i] = 0; + } + + stage = -1; + for (l = sdi->probes; l; l = l->next) { + probe = (struct sr_probe *)l->data; + if (probe->enabled == FALSE) + continue; + + //if (probe->index > 7) + // devc->sample_wide = TRUE; + + probe_bit = 1 << (probe->index); + if (!(probe->trigger)) + continue; + + //Configure trigger mask and value. + stage = 0; + for (tc = probe->trigger; *tc; tc++) { + devc->trigger_mask[stage] |= probe_bit; + if (*tc == '1') + devc->trigger_value[stage] |= probe_bit; + stage++; + if (stage > NUM_TRIGGER_STAGES) + return SR_ERR; + } + } + + */ + + //if (stage == -1) + // /* + // * We didn't configure any triggers, make sure acquisition + // * doesn't wait for any. + // */ + // devc->trigger_stage = TRIGGER_FIRED; + //else + // devc->trigger_stage = 0; + + return SR_OK; + + +} + + + diff --git a/hardware/link-mso19/protocol.h b/hardware/link-mso19/protocol.h index 9ce1de3b..38514404 100644 --- a/hardware/link-mso19/protocol.h +++ b/hardware/link-mso19/protocol.h @@ -133,6 +133,7 @@ SR_PRIV inline uint16_t mso_calc_raw_from_mv(struct dev_context *devc); SR_PRIV int mso_reset_fsm(struct sr_dev_inst *sdi); SR_PRIV int mso_toggle_led(struct sr_dev_inst *sdi, int state); +SR_PRIV int mso_configure_probes(const struct sr_dev_inst *sdi); SR_PRIV void stop_acquisition(const struct sr_dev_inst *sdi); ///////////////////////