Skip to content

Commit

Permalink
osc.c: Allow setting the capture timeout via .ini file
Browse files Browse the repository at this point in the history
There are scenarios where a larger timeout is needed. For example, when using the UART interface, the bandwith is significantly lower than USB or Ethernet.
When "capture_timeout" is read from a .ini file, the assigned value (e.g. "capture_timeout=5000") will overwrite the value that osc computes internally.

Signed-off-by: Dan <[email protected]>
  • Loading branch information
dNechita authored and cristina-suteu committed Mar 13, 2024
1 parent 052621d commit 8fa73f9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion osc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ GtkWidget *main_window;
struct iio_context *ctx = NULL;
static unsigned int num_devices = 0;
bool ctx_destroyed_by_do_quit;
bool ini_capture_timeout_loaded = FALSE;
unsigned int ini_capture_timeout = 0;

static void gfunc_save_plot_data_to_ini(gpointer data, gpointer user_data);
static void plugin_restore_ini_state(const char *plugin_name,
Expand Down Expand Up @@ -1514,8 +1516,12 @@ static int capture_setup(void)
rx_update_device_sampling_freq(iio_device_get_id(dev), freq);
}

if (ctx)
if (ctx) {
if (ini_capture_timeout_loaded) {
min_timeout = ini_capture_timeout;
}
iio_context_set_timeout(ctx, min_timeout);
}

return 0;
}
Expand Down Expand Up @@ -2172,6 +2178,9 @@ static void capture_profile_save(const char *filename)
__func__, iio_context_get_name(ctx));
}
}
if (ini_capture_timeout_loaded) {
fprintf(fp, "capture_timeout=%d\n", ini_capture_timeout);
}

fclose(fp);

Expand Down Expand Up @@ -2454,6 +2463,13 @@ static int load_profile(const char *filename, bool load_plugins)

move_gtk_window_on_screen(GTK_WINDOW(main_window), x_pos, y_pos);

value = read_token_from_ini(filename, OSC_INI_SECTION, "capture_timeout");
if (value) {
ini_capture_timeout_loaded = true;
ini_capture_timeout = atoi(value);
free(value);
}

foreach_in_ini(filename, capture_profile_handler);

for (node = plugin_list; node; node = g_slist_next(node)) {
Expand Down

0 comments on commit 8fa73f9

Please sign in to comment.