Пример #1
0
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{
	struct dev_context *devc;
	struct drv_context *drvc = di->priv;

	if (sdi->status != SR_ST_ACTIVE)
		return SR_ERR_DEV_CLOSED;

	devc = sdi->priv;
	devc->cb_data = cb_data;

	if (configure_probes(sdi) != SR_OK) {
		sr_err("Failed to configure probes.");
		return SR_ERR;
	}

	if (dso_init(sdi) != SR_OK)
		return SR_ERR;

	if (dso_capture_start(sdi) != SR_OK)
		return SR_ERR;

	devc->dev_state = CAPTURE;
	usb_source_add(drvc->sr_ctx, TICK, handle_event, (void *)sdi);

	/* Send header packet to the session bus. */
	std_session_send_df_header(cb_data, LOG_PREFIX);

	return SR_OK;
}
Пример #2
0
static int hw_set_configuration(int device_index, int capability, void *value)
{
	struct sr_device_instance *sdi;
	struct fx2_device *fx2;
	int ret;
	uint64_t *tmp_u64;

	if (!(sdi = sr_get_device_instance(device_instances, device_index)))
		return SR_ERR;
	fx2 = sdi->priv;

	if (capability == SR_HWCAP_SAMPLERATE) {
		tmp_u64 = value;
		ret = set_configuration_samplerate(sdi, *tmp_u64);
	} else if (capability == SR_HWCAP_PROBECONFIG) {
		ret = configure_probes(fx2, (GSList *) value);
	} else if (capability == SR_HWCAP_LIMIT_SAMPLES) {
		tmp_u64 = value;
		fx2->limit_samples = *tmp_u64;
		ret = SR_OK;
	} else {
		ret = SR_ERR;
	}

	return ret;
}
Пример #3
0
static int hw_dev_config_set(int dev_index, int hwcap, void *value)
{
	struct sr_dev_inst *sdi;
	struct context *ctx;

	if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
		sr_err("zp: %s: sdi was NULL", __func__);
		return SR_ERR;
	}

	if (!(ctx = sdi->priv)) {
		sr_err("zp: %s: sdi->priv was NULL", __func__);
		return SR_ERR_ARG;
	}

	switch (hwcap) {
	case SR_HWCAP_SAMPLERATE:
		return set_samplerate(sdi, *(uint64_t *)value);
	case SR_HWCAP_PROBECONFIG:
		return configure_probes(sdi, (GSList *)value);
	case SR_HWCAP_LIMIT_SAMPLES:
		ctx->limit_samples = *(uint64_t *)value;
		return SR_OK;
	default:
		return SR_ERR;
	}
}
Пример #4
0
int hw_set_configuration(int device_index, int capability, void *value)
{
	struct usb_device_instance *udi;
	int ret;
	uint64_t *tmp_u64;

	if( !(udi = get_usb_device_instance(usb_devices, device_index)) )
		return SIGROK_NOK;

	if(capability == HWCAP_SAMPLERATE) {
		tmp_u64 = value;
		ret = set_configuration_samplerate(udi, *tmp_u64);
	}
	else if(capability == HWCAP_PROBECONFIG)
		ret = configure_probes( (GSList *) value);
	else if(capability == HWCAP_LIMIT_SAMPLES)
	{
		limit_samples = strtoull(value, NULL, 10);
		ret = SIGROK_OK;
	}
	else
		ret = SIGROK_NOK;

	return ret;
}
Пример #5
0
static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
				    void *cb_data)
{
	const struct libusb_pollfd **lupfd;
	struct sr_datafeed_packet packet;
	struct sr_datafeed_header header;
	struct dev_context *devc;
	struct drv_context *drvc = di->priv;
	int i;

	if (sdi->status != SR_ST_ACTIVE)
		return SR_ERR;

	devc = sdi->priv;
	devc->cb_data = cb_data;

	if (configure_probes(sdi) != SR_OK) {
		sr_err("Failed to configure probes.");
		return SR_ERR;
	}

	if (dso_init(devc) != SR_OK)
		return SR_ERR;

	if (dso_capture_start(devc) != SR_OK)
		return SR_ERR;

	devc->dev_state = CAPTURE;
	lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
	for (i = 0; lupfd[i]; i++)
		sr_source_add(lupfd[i]->fd, lupfd[i]->events, TICK,
			      handle_event, (void *)sdi);
	free(lupfd);

	/* Send header packet to the session bus. */
	packet.type = SR_DF_HEADER;
	packet.payload = (unsigned char *)&header;
	header.feed_version = 1;
	gettimeofday(&header.starttime, NULL);
	sr_session_send(cb_data, &packet);

	return SR_OK;
}
Пример #6
0
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{
	struct dev_context *devc;
	uint8_t buf[4];
	int bytes_written;

	if (sdi->status != SR_ST_ACTIVE)
		return SR_ERR_DEV_CLOSED;

	if (!(devc = sdi->priv)) {
		sr_err("%s: sdi->priv was NULL.", __func__);
		return SR_ERR_BUG;
	}

	if (!devc->ftdic) {
		sr_err("%s: devc->ftdic was NULL.", __func__);
		return SR_ERR_BUG;
	}

	devc->divcount = samplerate_to_divcount(devc->cur_samplerate);
	if (devc->divcount == 0xff) {
		sr_err("%s: Invalid divcount/samplerate.", __func__);
		return SR_ERR;
	}

	if (configure_probes(sdi) != SR_OK) {
		sr_err("Failed to configure probes.");
		return SR_ERR;
	}

	/* Fill acquisition parameters into buf[]. */
	buf[0] = devc->divcount;
	buf[1] = 0xff; /* This byte must always be 0xff. */
	buf[2] = devc->trigger_pattern;
	buf[3] = devc->trigger_mask;

	/* Start acquisition. */
	bytes_written = la8_write(devc, buf, 4);

	if (bytes_written < 0) {
		sr_err("Acquisition failed to start: %d.", bytes_written);
		return SR_ERR;
	} else if (bytes_written != 4) {
		sr_err("Acquisition failed to start: %d.", bytes_written);
		return SR_ERR;
	}

	sr_dbg("Hardware acquisition started successfully.");

	devc->cb_data = cb_data;

	/* Send header packet to the session bus. */
	std_session_send_df_header(cb_data, LOG_PREFIX);

	/* Time when we should be done (for detecting trigger timeouts). */
	devc->done = (devc->divcount + 1) * 0.08388608 + time(NULL)
			+ devc->trigger_timeout;
	devc->block_counter = 0;
	devc->trigger_found = 0;

	/* Hook up a dummy handler to receive data from the LA8. */
	sr_source_add(-1, G_IO_IN, 0, receive_data, (void *)sdi);

	return SR_OK;
}