Skip to content

Adds IGNOREEMPTY=[0|1] to {P,C}BEACON cmd. #56

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
Adds IGNOREEMPTY=[0|1] to {P,C}BEACON cmd.
When using COMMENTCMD (PBEACON), or INFOCMD (CBEACON), direwolf reports
an error when the command does not produce any stdout, even when the
command exits with status 0.

This commit allows something like:

PBEACON IGNOREEMPTY=1 EVERY=00:30 COMMENTCMD='command_to_print_updates'

Say 'command_to_print_updates' only prints to stdout when its output
would be different from the last time it ran. With the above, direwolf
would run the command as before, but does not print an error when no new
updates are available. An error is still reported if the exit status is
not 0.
  • Loading branch information
btovar committed Sep 13, 2016
commit 51b780f325f1c4fb7e891babb8bc0ebd99004e3f
18 changes: 11 additions & 7 deletions beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,14 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo)
strlcat (super_comment, var_comment, sizeof(super_comment));
}
else {
text_color_set(DW_COLOR_ERROR);
dw_printf ("xBEACON, config file line %d, COMMENTCMD failure.\n", g_misc_config_p->beacon[j].lineno);
}
if (k < 0 || !g_misc_config_p->beacon[j].ignore_empty_cmd_stdout) {
text_color_set(DW_COLOR_ERROR);
dw_printf ("xBEACON, config file line %d, COMMENTCMD failure.\n", g_misc_config_p->beacon[j].lineno);
}
strlcpy (super_comment, "", sizeof(super_comment)); /* abort */
}
}


/*
* Add the info part depending on beacon type.
*/
Expand Down Expand Up @@ -882,9 +884,11 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo)
strlcat (beacon_text, info_part, sizeof(beacon_text));
}
else {
text_color_set(DW_COLOR_ERROR);
dw_printf ("CBEACON, config file line %d, INFOCMD failure.\n", g_misc_config_p->beacon[j].lineno);
strlcpy (beacon_text, "", sizeof(beacon_text)); // abort!
if(k < 0 || !g_misc_config_p->beacon[j].ignore_empty_cmd_stdout) {
text_color_set(DW_COLOR_ERROR);
dw_printf ("CBEACON, config file line %d, INFOCMD failure.\n", g_misc_config_p->beacon[j].lineno);
}
strlcpy (beacon_text, "", sizeof(beacon_text)); // abort!
}
}
else {
Expand Down
3 changes: 3 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -4379,6 +4379,9 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
else if (strcasecmp(keyword, "INFOCMD") == 0) {
b->custom_infocmd = strdup(value);
}
else if (strcasecmp(keyword, "IGNOREEMPTY") == 0) {
b->ignore_empty_cmd_stdout = atoi(value);
}
else if (strcasecmp(keyword, "OBJNAME") == 0) {
strlcpy(b->objname, value, sizeof(b->objname));
}
Expand Down
3 changes: 2 additions & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ struct misc_config_s {
char *comment; /* Comment or NULL. */
char *commentcmd; /* Command to append more to Comment or NULL. */


int ignore_empty_cmd_stdout; /* Do not print an error when infocmd exits
with status 0, and no output is generated. */
} beacon[MAX_BEACONS];

};
Expand Down