Skip to content

Commit fddb64d

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 fddb64d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Diff for: osc.c

+18-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,13 @@ 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+
fprintf(stderr, "Setting libiio timeout to: %d\n", min_timeout);
1525+
}
15191526

15201527
return 0;
15211528
}
@@ -2172,6 +2179,9 @@ static void capture_profile_save(const char *filename)
21722179
__func__, iio_context_get_name(ctx));
21732180
}
21742181
}
2182+
if (ini_capture_timeout_loaded) {
2183+
fprintf(fp, "capture_timeout=%d\n", ini_capture_timeout);
2184+
}
21752185

21762186
fclose(fp);
21772187

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

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

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

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

0 commit comments

Comments
 (0)