Skip to content

Commit

Permalink
oscplot.c: use libiio v1 API
Browse files Browse the repository at this point in the history
Signed-off-by: Cristina Suteu <[email protected]>
  • Loading branch information
cristina-suteu committed Jan 9, 2025
1 parent bf5e9f3 commit a3ffdd4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions oscplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@ static gboolean check_valid_setup_of_device(OscPlot *plot, const char *name)
struct iio_device *dev;
unsigned int nb_channels = num_of_channels_of_device(treeview, name);
unsigned enabled_channels_mask;
const struct iio_channels_mask *mask = NULL;

GtkTreeModel *model;
GtkTreeIter iter;
Expand All @@ -2128,7 +2129,13 @@ static gboolean check_valid_setup_of_device(OscPlot *plot, const char *name)
if (!device_enabled && plot_type != TIME_PLOT)
return true;

/* No additional checking is needed for non iio devices */
if (!dev)
return TRUE;
num_enabled = enabled_channels_of_device(treeview, name, &enabled_channels_mask);
mask = iio_create_channels_mask(iio_device_get_channels_count(dev));



/* Basic validation rules */
if (plot_type == FFT_PLOT) {
Expand All @@ -2148,7 +2155,8 @@ static gboolean check_valid_setup_of_device(OscPlot *plot, const char *name)
gtk_widget_set_tooltip_text(priv->capture_button,
"Time Domain needs at least one channel");
return false;
} else if (dev && !dma_valid_selection(name, enabled_channels_mask | global_enabled_channels_mask(dev), nb_channels)) {
} else if (dev && !dma_valid_selection(name, enabled_channels_mask |
global_enabled_channels_mask(dev, (struct iio_channels_mask *) mask), nb_channels)) {
gtk_widget_set_tooltip_text(priv->capture_button,
"Channel selection not supported");
return false;
Expand All @@ -2161,17 +2169,17 @@ static gboolean check_valid_setup_of_device(OscPlot *plot, const char *name)
}
}

/* No additional checking is needed for non iio devices */
if (!dev)
return TRUE;



char warning_text[100];

/* Check if devices that need a trigger have one and it's configured */
const struct iio_device *trigger;
int ret;

ret = iio_device_get_trigger(dev, &trigger);
trigger = iio_device_get_trigger(dev);
ret = iio_err(trigger);
if (ret == 0 && trigger == NULL && num_enabled > 0) {
snprintf(warning_text, sizeof(warning_text),
"Device %s needs an impulse generator", name);
Expand Down Expand Up @@ -6755,7 +6763,8 @@ static gboolean right_click_menu_show(OscPlot *plot, GdkEvent *event)
bool needs_trigger;
int ret;

ret = iio_device_get_trigger(dev, &trigger);
trigger = iio_device_get_trigger(dev);
ret = iio_err(trigger);
needs_trigger = false;
if (ret == 0) {
needs_trigger = true;
Expand Down

0 comments on commit a3ffdd4

Please sign in to comment.