From b0d875e929341d77694eb67e578f514d51ca45e4 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 5 Mar 2024 10:46:57 +0200 Subject: [PATCH] osc.c: Allow setting the capture timeout via .ini file 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 --- osc.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/osc.c b/osc.c index 45a26c4b..335d27e9 100644 --- a/osc.c +++ b/osc.c @@ -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, @@ -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; } @@ -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); @@ -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)) {