Пример #1
0
int select_channels(struct sr_dev_inst *sdi)
{
	struct sr_channel *ch;
	gboolean enabled;
	GSList *selected_channels, *l, *channels;

	channels = sr_dev_inst_channels_get(sdi);

	if (opt_channels) {
		if (!(selected_channels = parse_channelstring(sdi, opt_channels)))
			return SR_ERR;

		for (l = channels; l; l = l->next) {
			ch = l->data;
			enabled = (g_slist_find(selected_channels, ch) != NULL);
			if (sr_dev_channel_enable(ch, enabled) != SR_OK)
				return SR_ERR;
		}
		g_slist_free(selected_channels);
	}
#ifdef HAVE_SRD
	map_pd_channels(sdi);
#endif
	return SR_OK;
}
Пример #2
0
END_TEST

START_TEST(test_channel_add)
{
	int ret;
	struct sr_dev_inst *sdi;
	GSList *channels;

	sdi = sr_dev_inst_user_new("Vendor", "Model", "Version");
	fail_unless(sdi != NULL, "sr_dev_inst_user_new() failed.");

	channels = sr_dev_inst_channels_get(sdi);
	fail_unless(g_slist_length(channels) == 0, "More than 0 channels.");

	ret = sr_dev_inst_channel_add(sdi, 0, SR_CHANNEL_LOGIC, "D1");
	channels = sr_dev_inst_channels_get(sdi);
	fail_unless(ret == SR_OK);
	fail_unless(g_slist_length(channels) == 1);

	ret = sr_dev_inst_channel_add(sdi, 1, SR_CHANNEL_ANALOG, "A1");
	channels = sr_dev_inst_channels_get(sdi);
	fail_unless(ret == SR_OK);
	fail_unless(g_slist_length(channels) == 2);
}
Пример #3
0
GArray *srtest_get_enabled_logic_channels(const struct sr_dev_inst *sdi)
{
	struct sr_channel *ch;
	GArray *channels;
	GSList *l;

	channels = g_array_new(FALSE, FALSE, sizeof(int));
	for (l = sr_dev_inst_channels_get(sdi); l; l = l->next) {
		ch = l->data;
		if (ch->type != SR_CHANNEL_LOGIC)
			continue;
		if (ch->enabled != TRUE)
			continue;
		g_array_append_val(channels, ch->index);
	}

	return channels;
}