Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adrv9002: API version mismatch fix #492

Merged
merged 2 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions plugins/adrv9002.c
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,25 @@ static char *profile_gen_cli_get_api(void)
return version;
}

static char *strip_leading_and_trailing_nonnumeric_chars(char *string)
{
int i;
char *str = (char *)malloc(strlen(string) * sizeof(char));
sprintf(str, "%s", string);

while((str[0] < '0' || str[0] > '9') && str[0] != '\0') {
str++;
}

i = strlen(str) - 1;
while((str[i] < '0' || str[i] > '9') && i > 0) {
str[i] = '\0';
i--;
}

return str;
}

static bool profile_gen_check_api(gpointer data)
{
struct plugin_private *priv = data;
Expand All @@ -2281,11 +2300,25 @@ static bool profile_gen_check_api(gpointer data)
goto err;
}

if(strcmp(version, supported_version) != 0) {
sprintf(message, "\nOnly API version %s is supported, the device uses %s!", supported_version, version);
profile_gen_set_debug_info(data, message);
free(supported_version);
goto err;
if(strcmp(strip_leading_and_trailing_nonnumeric_chars(supported_version),
strip_leading_and_trailing_nonnumeric_chars(version)) != 0) {
sprintf(message,
"\nDriver API - Profile generator API version mismatch\nDriver (%s)"
"\nProfile Generator (%s)",
supported_version, version);
GtkWidget *adrv9002_panel = GTK_WIDGET(gtk_builder_get_object(priv->builder, "adrv9002_panel"));
GtkWidget *dialog = gtk_message_dialog_new(
GTK_WINDOW(gtk_widget_get_toplevel(adrv9002_panel)),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO,
"%s\n\nAre you sure you want to load the profile?", message);
gint response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);

if(response != GTK_RESPONSE_YES) {
profile_gen_set_debug_info(data, message);
free(supported_version);
goto err;
}
}

free(supported_version);
Expand Down
Loading