aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-09-14 10:59:39 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-09-14 13:01:26 -0300
commit3fe49323862b95f928ef5b5542d570b6828886e2 (patch)
treedd0d74cf0a88cd907d739d73b3075391a9cb7057
parentb7e528a347f4cb8bbeb68cda0e8216d26b875169 (diff)
dvb-fe-tool: add femon parameter
Add a parameter to do frontend monitoring. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--utils/dvb/dvb-fe-tool.c88
1 files changed, 87 insertions, 1 deletions
diff --git a/utils/dvb/dvb-fe-tool.c b/utils/dvb/dvb-fe-tool.c
index 6a19820d..4d20fc6b 100644
--- a/utils/dvb/dvb-fe-tool.c
+++ b/utils/dvb/dvb-fe-tool.c
@@ -23,6 +23,7 @@
#include <argp.h>
#include <stdlib.h>
#include <stdio.h>
+#include <unistd.h>
#define PROGRAM_NAME "dvb-fe-tool"
@@ -39,6 +40,7 @@ static const struct argp_option options[] = {
{"adapter", 'a', "ADAPTER", 0, "dvb adapter", 0},
{"frontend", 'f', "FRONTEND", 0, "dvb frontend", 0},
{"set-delsys", 'd', "PARAMS", 0, "set delivery system", 0},
+ {"femon", 'm', 0, 0, "monitors frontend stats on an streaming frontend", 0},
#if 0 /* Currently not implemented */
{"set", 's', "PARAMS", 0, "set frontend", 0},
#endif
@@ -54,6 +56,14 @@ static char *set_params = NULL;
static int verbose = 0;
static int dvbv3 = 0;
static int delsys = 0;
+static int femon = 0;
+
+#define PERROR(x...) \
+ do { \
+ fprintf(stderr, "ERROR: "); \
+ fprintf(stderr, x); \
+ fprintf(stderr, " (%s)\n", strerror(errno)); \
+ } while (0)
static error_t parse_opt(int k, char *arg, struct argp_state *state)
{
@@ -69,6 +79,9 @@ static error_t parse_opt(int k, char *arg, struct argp_state *state)
if (delsys < 0)
return ARGP_ERR_UNKNOWN;
break;
+ case 'm':
+ femon++;
+ break;
#if 0
case 's':
set_params = arg;
@@ -95,6 +108,76 @@ static struct argp argp = {
.doc = doc,
};
+static int print_frontend_stats(FILE *fd,
+ struct dvb_v5_fe_parms *parms)
+{
+ char buf[512], *p;
+ int rc, i, len, show, n_status_lines = 0;
+
+ rc = dvb_fe_get_stats(parms);
+ if (rc) {
+ PERROR("dvb_fe_get_stats failed");
+ return -1;
+ }
+
+ p = buf;
+ len = sizeof(buf);
+ dvb_fe_snprintf_stat(parms, DTV_STATUS, NULL, 0, &p, &len, &show);
+
+ for (i = 0; i < MAX_DTV_STATS; i++) {
+ show = 1;
+
+ dvb_fe_snprintf_stat(parms, DTV_QUALITY, "Quality",
+ i, &p, &len, &show);
+
+ dvb_fe_snprintf_stat(parms, DTV_STAT_SIGNAL_STRENGTH, "Signal",
+ i, &p, &len, &show);
+
+ dvb_fe_snprintf_stat(parms, DTV_STAT_CNR, "C/N",
+ i, &p, &len, &show);
+
+ dvb_fe_snprintf_stat(parms, DTV_STAT_ERROR_BLOCK_COUNT, "UCB",
+ i, &p, &len, &show);
+
+ dvb_fe_snprintf_stat(parms, DTV_BER, "postBER",
+ i, &p, &len, &show);
+
+ dvb_fe_snprintf_stat(parms, DTV_PRE_BER, "preBER",
+ i, &p, &len, &show);
+
+ dvb_fe_snprintf_stat(parms, DTV_PER, "PER",
+ i, &p, &len, &show);
+
+ if (p != buf) {
+ if (n_status_lines)
+ fprintf(fd, "\t%s\n", buf);
+ else
+ fprintf(fd, "%s\n", buf);
+
+ n_status_lines++;
+
+ p = buf;
+ len = sizeof(buf);
+ }
+ }
+
+ fflush(fd);
+
+ return 0;
+}
+
+static void get_show_stats(struct dvb_v5_fe_parms *parms)
+{
+ int rc;
+
+ do {
+ rc = dvb_fe_get_stats(parms);
+ if (!rc)
+ print_frontend_stats(stderr, parms);
+ usleep(1000000);
+ } while (1);
+}
+
int main(int argc, char *argv[])
{
struct dvb_v5_fe_parms *parms;
@@ -106,7 +189,7 @@ int main(int argc, char *argv[])
* If called without any option, be verbose, to print the
* DVB frontend information.
*/
- if (!get && !delsys && !set_params)
+ if (!get && !delsys && !set_params && !femon)
verbose++;
if (!delsys && !set_params)
@@ -133,6 +216,9 @@ int main(int argc, char *argv[])
dvb_fe_prt_parms(parms);
}
+ if (femon)
+ get_show_stats(parms);
+
ret:
dvb_fe_close(parms);

Privacy Policy