Skip to content

Commit

Permalink
adrv9002 plugin: fixed bad debug info from CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Popa <andrei.popa@analog.com>
  • Loading branch information
andrei47w committed Nov 21, 2023
1 parent a169083 commit dde1c34
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions plugins/adrv9002.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ static int profile_gen_save_to_file(gchar *filename, struct adrv9002_config *cfg
// run profile gen cli command
FILE *file;
int ret = 0;
char out[BUFSIZ], command[BUFSIZ], *config_filename = "adrv9002_config.json";
char command[BUFSIZ], *config_filename = "adrv9002_config.json";
profile_gen_write_config_to_file(config_filename, cfg);

if (file_type) { // profile
Expand All @@ -2057,17 +2057,14 @@ static int profile_gen_save_to_file(gchar *filename, struct adrv9002_config *cfg
}

// Read the output
fflush(file);
ret = fread(out, sizeof(char), sizeof(out), file);
char out[1024], message[BUFSIZ] = "\0";
while (fgets(out, sizeof(out), file) != NULL) {
strcat(message, out);
}
remove(config_filename);
pclose(file);

if (ret == 0) {
profile_gen_set_debug_info(data, "\nFailed to read the command output!");
ret = 1;
goto err;
}
profile_gen_set_debug_info(data, out);
profile_gen_set_debug_info(data, message);

return 0;
err:
Expand Down Expand Up @@ -2160,7 +2157,7 @@ static void profile_gen_load_config_to_device(GtkButton *self, gpointer data)
{
struct plugin_private *priv = data;
struct adrv9002_config cfg = lte_lvs_3072_MHz_10();
char message[BUFSIZ], fail_message[BUFSIZ];
char message[BUFSIZ] = "\0", fail_message[BUFSIZ];
int ret;

// get config struct
Expand All @@ -2177,10 +2174,8 @@ static void profile_gen_load_config_to_device(GtkButton *self, gpointer data)

// run profile gen cli command
FILE *file;
char out[BUFSIZ], command[BUFSIZ],
*config_filename = "adrv9002_config.json",
*profile_filename = "adrv9002_profile.json",
*stream_filename = "adrv9002_stream.stream";
char command[BUFSIZ], *config_filename = "adrv9002_config.json", *profile_filename = "adrv9002_profile.json",
*stream_filename = "adrv9002_stream.stream";

profile_gen_write_config_to_file(config_filename, &cfg);
sprintf(command, "%s --config %s --profile %s --stream %s",
Expand All @@ -2194,16 +2189,17 @@ static void profile_gen_load_config_to_device(GtkButton *self, gpointer data)
}

// read the output
fflush(file);
ret = fread(out, sizeof(char), sizeof(out), file);
char out[BUFSIZ];
while (fgets(out, sizeof(out), file) != NULL) {
strcat(message, out);
}
remove(config_filename);
pclose(file);

if (ret == 0) {
strcat(message, "\nFailed to read the command output!");
goto err;
}
strcat(message, out);

// load profile and stream to device
char *buf;
Expand Down

0 comments on commit dde1c34

Please sign in to comment.