diff options
author | Mark Purcell <msp@debian.org> | 2010-02-25 21:13:46 +1100 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2013-09-03 09:48:46 +0200 |
commit | 665818f1969f893f05edf5b70eb1804c89b2829e (patch) | |
tree | 34ba68cee03c52d769a5a51b456b7e9d63cd091a /util/femon/femon.c | |
parent | 109c7947d6a11a2a54eff1b19615ed80ea2f0602 (diff) | |
parent | 9fe4d4ea9c054e539ab679ed2e9c076c35beb69d (diff) | |
download | linux-dvb-apps-3a4100597b16fb9c0845fab3a54b14f0af8aa62b.tar.gz |
Imported Debian patch 1.1.1+rev1355-1debian/1.1.1+rev1355-1
Diffstat (limited to 'util/femon/femon.c')
-rw-r--r-- | util/femon/femon.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/util/femon/femon.c b/util/femon/femon.c index 46d239d..a50fe17 100644 --- a/util/femon/femon.c +++ b/util/femon/femon.c @@ -42,14 +42,21 @@ static char *usage_str = "\nusage: femon [options]\n" " -H : human readable output\n" + " -A : Acoustical mode. A sound indicates the signal quality.\n" + " -r : If 'Acoustical mode' is active it tells the application\n" + " is called remotely via ssh. The sound is heard on the 'real'\n" + " machine but. The user has to be root.\n" " -a number : use given adapter (default 0)\n" " -f number : use given frontend (default 0)\n" " -c number : samples to take (default 0 = infinite)\n\n"; +int sleep_time=1000000; +int acoustical_mode=0; +int remote=0; static void usage(void) { - fprintf(stderr, usage_str); + fprintf(stderr, "%s", usage_str); exit(1); } @@ -59,6 +66,27 @@ int check_frontend (struct dvbfe_handle *fe, int human_readable, unsigned int co { struct dvbfe_info fe_info; unsigned int samples = 0; + FILE *ttyFile=NULL; + + // We dont write the "beep"-codes to stdout but to /dev/tty1. + // This is neccessary for Thin-Client-Systems or Streaming-Boxes + // where the computer does not have a monitor and femon is called via ssh. + if(acoustical_mode) + { + if(remote) + { + ttyFile=fopen("/dev/tty1","w"); + if(!ttyFile) + { + fprintf(stderr, "Could not open /dev/tty1. No access rights?\n"); + exit(-1); + } + } + else + { + ttyFile=stdout; + } + } do { if (dvbfe_get_info(fe, FE_STATUS_PARAMS, &fe_info, DVBFE_INFO_QUERYTYPE_IMMEDIATE, 0) != FE_STATUS_PARAMS) { @@ -94,12 +122,24 @@ int check_frontend (struct dvbfe_handle *fe, int human_readable, unsigned int co if (fe_info.lock) printf("FE_HAS_LOCK"); + // create beep if acoustical_mode enabled + if(acoustical_mode) + { + int signal=(fe_info.signal_strength * 100) / 0xffff; + fprintf( ttyFile, "\033[10;%d]\a", 500+(signal*2)); + // printf("Variable : %d\n", signal); + fflush(ttyFile); + } + printf("\n"); fflush(stdout); - usleep(1000000); + usleep(sleep_time); samples++; } while ((!count) || (count-samples)); - + + if(ttyFile) + fclose(ttyFile); + return 0; } @@ -148,7 +188,7 @@ int main(int argc, char *argv[]) int human_readable = 0; int opt; - while ((opt = getopt(argc, argv, "Ha:f:c:")) != -1) { + while ((opt = getopt(argc, argv, "rAHa:f:c:")) != -1) { switch (opt) { default: @@ -166,6 +206,15 @@ int main(int argc, char *argv[]) case 'H': human_readable = 1; break; + case 'A': + // Acoustical mode: we have to reduce the delay between + // checks in order to hear nice sound + sleep_time=5000; + acoustical_mode=1; + break; + case 'r': + remote=1; + break; } } |