Skip to content

Commit d96a240

Browse files
oscplot: fix math
ensure that channels whose names end in _i and _q are properly read and added to math expression Signed-off-by: Cristina Suteu <[email protected]>
1 parent b26771d commit d96a240

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Diff for: oscplot.c

+19-3
Original file line numberDiff line numberDiff line change
@@ -6108,19 +6108,33 @@ static gint channel_compare(gconstpointer a, gconstpointer b)
61086108

61096109
static GSList * math_expression_get_iio_channel_list(const char *expression, struct iio_context *ctx, const char *device, bool *has_invalid_ch)
61106110
{
6111+
61116112
GSList *chn_list = NULL;
6112-
GRegex *regex;
6113+
GRegex *regex, *regex_i, *regex_q;
61136114
GMatchInfo *info;
61146115
gchar *chn_name;
61156116
struct iio_device *iio_dev;
61166117
struct iio_channel *iio_chn;
6117-
gboolean invalid_list = false, is_match;
6118+
gboolean invalid_list = false, is_match = true, match_q, match_i, match;
61186119

61196120
if (!device || !(iio_dev = iio_context_find_device(ctx, device)))
61206121
return NULL;
61216122

61226123
regex = g_regex_new("voltage[0-9]+", 0, 0, NULL);
6123-
is_match = g_regex_match(regex, expression, 0, &info);
6124+
regex_i = g_regex_new("voltage[0-9]+_i", 0, 0, NULL);
6125+
regex_q = g_regex_new("voltage[0-9]+_q", 0, 0, NULL);
6126+
6127+
match_i = g_regex_match(regex_i, expression, 0, &info);
6128+
6129+
if (!match_i) {
6130+
match_q = g_regex_match(regex_q, expression, 0, &info);
6131+
if (!match_q) {
6132+
match = g_regex_match(regex, expression, 0, &info);
6133+
if (!match)
6134+
is_match = false;
6135+
}
6136+
}
6137+
61246138
if (!is_match) {
61256139
invalid_list = true;
61266140
} else {
@@ -6138,6 +6152,8 @@ static GSList * math_expression_get_iio_channel_list(const char *expression, str
61386152
}
61396153
g_match_info_free(info);
61406154
g_regex_unref(regex);
6155+
g_regex_unref(regex_i);
6156+
g_regex_unref(regex_q);
61416157

61426158
if (invalid_list) {
61436159
if (chn_list)

0 commit comments

Comments
 (0)