diff --git a/datatypes.h b/datatypes.h index f9d46f654..c6e143fcb 100644 --- a/datatypes.h +++ b/datatypes.h @@ -47,6 +47,7 @@ struct extra_info { }; struct extra_dev_info { + bool input_device; struct iio_buffer *buffer; unsigned int sample_count; double adc_freq, lo_freq; diff --git a/osc.c b/osc.c index aab682584..1d71b8649 100644 --- a/osc.c +++ b/osc.c @@ -1313,6 +1313,9 @@ static gboolean capture_process(void) unsigned int nb_channels = iio_device_get_channels_count(dev); unsigned int sample_count = dev_info->sample_count; + if (dev_info->input_device == false) + continue; + if (sample_size == 0) continue; @@ -1541,6 +1544,24 @@ void sigterm (int signum) application_quit(); } +bool is_input_device(const struct iio_device *dev) +{ + struct iio_channel *ch; + int nb_channels, i; + + if (!dev) + return false; + + nb_channels = iio_device_get_channels_count(dev); + for (i = 0; i < nb_channels; i++) { + ch = iio_device_get_channel(dev, i); + if (iio_channel_is_scan_element(ch) && !iio_channel_is_output(ch)) + return true; + } + + return false; +} + static void init_device_list(void) { unsigned int i, j; @@ -1556,6 +1577,7 @@ static void init_device_list(void) unsigned int nb_channels = iio_device_get_channels_count(dev); struct extra_dev_info *dev_info = calloc(1, sizeof(*dev_info)); iio_device_set_data(dev, dev_info); + dev_info->input_device = is_input_device(dev); for (j = 0; j < nb_channels; j++) { struct iio_channel *ch = iio_device_get_channel(dev, j); diff --git a/osc.h b/osc.h index 99eb677f2..aa1958ad1 100644 --- a/osc.h +++ b/osc.h @@ -22,7 +22,6 @@ extern GtkWidget *capture_graph; extern gint capture_function; extern bool str_endswith(const char *str, const char *needle); -extern bool is_input_device(const char *device); #define TMP_INI_FILE "/tmp/.%s.tmp" #ifndef MAX_MARKERS diff --git a/oscplot.c b/oscplot.c index 82d9505d3..a59f131d2 100644 --- a/oscplot.c +++ b/oscplot.c @@ -206,6 +206,8 @@ struct _OscPlotPrivate GtkTextBuffer* tbuf; + unsigned int nb_input_devices; + struct plot_geometry size; int frame_counter; @@ -636,6 +638,11 @@ static gboolean check_valid_setup(OscPlot *plot) for (i = 0; i < num_devices; i++) { struct iio_device *dev = iio_context_get_device(ctx, i); + struct extra_dev_info *dev_info = iio_device_get_data(dev); + + if (dev_info->input_device == false) + continue; + is_valid = check_valid_setup_of_device(plot, dev); if (gtk_combo_box_get_active(GTK_COMBO_BOX(priv->plot_domain)) == TIME_PLOT) { if (!is_valid) @@ -880,6 +887,9 @@ static void collect_parameters_from_plot(OscPlot *plot) struct iio_device *dev = iio_context_get_device(ctx, i); struct extra_dev_info *info = iio_device_get_data(dev); + if (info->input_device == false) + continue; + prms = malloc(sizeof(struct plot_params)); prms->plot_id = priv->object_id; prms->sample_count = plot_sample_count_get(plot); @@ -902,6 +912,9 @@ static void dispose_parameters_from_plot(OscPlot *plot) struct extra_dev_info *info = iio_device_get_data(dev); GSList *list = info->plots_sample_counts; + if (info->input_device == false) + continue; + for (node = list; node; node = g_slist_next(node)) { prms = node->data; if (prms->plot_id == priv->object_id) { @@ -1099,6 +1112,11 @@ static void devices_transform_assignment(OscPlot *plot) for (i = 0; i < num_devices; i++) { struct iio_device *dev = iio_context_get_device(ctx, i); const char *name = iio_device_get_name(dev) ?: iio_device_get_id(dev); + struct extra_dev_info *dev_info = iio_device_get_data(dev); + + if (dev_info->input_device == false) + continue; + prm.enabled_channels = enabled_channels_of_device(treeview, name); foreach_channel_iter_of_device(GTK_TREE_VIEW(priv->channel_list_view), name, *channels_transform_assignment, &prm); @@ -1532,16 +1550,22 @@ static void device_list_treeview_init(OscPlot *plot) treestore = GTK_TREE_STORE(gtk_tree_view_get_model(treeview)); + priv->nb_input_devices = 0; for (i = 0; i < num_devices; i++) { struct iio_device *dev = iio_context_get_device(ctx, i); unsigned int nb_channels = iio_device_get_channels_count(dev); + struct extra_dev_info *dev_info = iio_device_get_data(dev); const char *name = iio_device_get_name(dev) ?: iio_device_get_id(dev); + if (dev_info->input_device == false) + continue; + gtk_tree_store_append(treestore, &iter, NULL); gtk_tree_store_set(treestore, &iter, ELEMENT_NAME, name, - IS_DEVICE, TRUE, DEVICE_ACTIVE, !i, ELEMENT_REFERENCE, - dev, SENSITIVE, true, -1); + IS_DEVICE, TRUE, DEVICE_ACTIVE, !priv->nb_input_devices, + ELEMENT_REFERENCE, dev, SENSITIVE, true, -1); + priv->nb_input_devices++; for (j = 0; j < nb_channels; j++) { struct iio_channel *ch = iio_device_get_channel(dev, j); @@ -1624,6 +1648,11 @@ static void saveas_channels_list_fill(OscPlot *plot) struct iio_device *dev = iio_context_get_device(ctx, i); const char *name = iio_device_get_name(dev) ?: iio_device_get_id(dev); + struct extra_dev_info *dev_info = iio_device_get_data(dev); + + if (dev_info->input_device == false) + continue; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(priv->device_combobox), name); } @@ -3196,7 +3225,7 @@ static void plot_domain_changed_cb(GtkComboBox *box, OscPlot *plot) foreach_device_iter(GTK_TREE_VIEW(plot->priv->channel_list_view), *iter_children_plot_type_update, plot); - if (num_devices < 2) + if (plot->priv->nb_input_devices < 2) return; if (gtk_combo_box_get_active(box) != TIME_PLOT) {