Skip to content

Commit b0d875e

Browse files
committed
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 <[email protected]>
1 parent 052621d commit b0d875e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Diff for: osc.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ GtkWidget *main_window;
5757
struct iio_context *ctx = NULL;
5858
static unsigned int num_devices = 0;
5959
bool ctx_destroyed_by_do_quit;
60+
bool ini_capture_timeout_loaded = FALSE;
61+
unsigned int ini_capture_timeout = 0;
6062

6163
static void gfunc_save_plot_data_to_ini(gpointer data, gpointer user_data);
6264
static void plugin_restore_ini_state(const char *plugin_name,
@@ -1514,8 +1516,12 @@ static int capture_setup(void)
15141516
rx_update_device_sampling_freq(iio_device_get_id(dev), freq);
15151517
}
15161518

1517-
if (ctx)
1519+
if (ctx) {
1520+
if (ini_capture_timeout_loaded) {
1521+
min_timeout = ini_capture_timeout;
1522+
}
15181523
iio_context_set_timeout(ctx, min_timeout);
1524+
}
15191525

15201526
return 0;
15211527
}
@@ -2172,6 +2178,9 @@ static void capture_profile_save(const char *filename)
21722178
__func__, iio_context_get_name(ctx));
21732179
}
21742180
}
2181+
if (ini_capture_timeout_loaded) {
2182+
fprintf(fp, "capture_timeout=%d\n", ini_capture_timeout);
2183+
}
21752184

21762185
fclose(fp);
21772186

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

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

2466+
value = read_token_from_ini(filename, OSC_INI_SECTION, "capture_timeout");
2467+
if (value) {
2468+
ini_capture_timeout_loaded = true;
2469+
ini_capture_timeout = atoi(value);
2470+
free(value);
2471+
}
2472+
24572473
foreach_in_ini(filename, capture_profile_handler);
24582474

24592475
for (node = plugin_list; node; node = g_slist_next(node)) {

0 commit comments

Comments
 (0)