You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.5 KiB
118 lines
3.5 KiB
2 years ago
|
diff -r 3d43b280298c util/femon/femon.c
|
||
|
--- a/util/femon/femon.c Fri Mar 21 20:26:36 2014 +0100
|
||
2 years ago
|
+++ b/util/femon/femon.c Thu Jan 05 20:05:33 2023 +0100
|
||
2 years ago
|
@@ -42,16 +42,20 @@
|
||
2 years ago
|
static char *usage_str =
|
||
|
"\nusage: femon [options]\n"
|
||
|
" -H : human readable output\n"
|
||
|
+ " -M : minimalized 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"
|
||
2 years ago
|
" machine but. The user has to be root.\n"
|
||
|
+ " -t number : use given cycle time (default 1.00)\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";
|
||
2 years ago
|
|
||
|
int sleep_time=1000000;
|
||
2 years ago
|
+float fl_sleep_time=1;
|
||
2 years ago
|
int acoustical_mode=0;
|
||
|
+int minimalized=0;
|
||
|
int remote=0;
|
||
|
|
||
|
static void usage(void)
|
||
2 years ago
|
@@ -68,6 +72,8 @@
|
||
2 years ago
|
unsigned int samples = 0;
|
||
|
FILE *ttyFile=NULL;
|
||
2 years ago
|
|
||
2 years ago
|
+ struct timeval now;
|
||
2 years ago
|
+
|
||
2 years ago
|
// We dont write the "beep"-codes to stdout but to /dev/tty1.
|
||
|
// This is neccessary for Thin-Client-Systems or Streaming-Boxes
|
||
2 years ago
|
// where the computer does not have a monitor and femon is called via ssh.
|
||
2 years ago
|
@@ -90,12 +96,26 @@
|
||
2 years ago
|
|
||
|
do {
|
||
|
if (dvbfe_get_info(fe, FE_STATUS_PARAMS, &fe_info, DVBFE_INFO_QUERYTYPE_IMMEDIATE, 0) != FE_STATUS_PARAMS) {
|
||
|
+ if (!minimalized)
|
||
|
fprintf(stderr, "Problem retrieving frontend information: %m\n");
|
||
|
}
|
||
|
|
||
|
|
||
2 years ago
|
+ gettimeofday(&now, NULL);
|
||
|
+ char ltime[80] = "";
|
||
|
+ strftime(ltime, 80, "%a %b %d %Y - %H:%M:%S", localtime(&now.tv_sec));
|
||
|
+ int ms = now.tv_usec / 1000;
|
||
|
+ char ntime[84] = "";
|
||
|
+ sprintf(ntime, "%s.%03d", ltime, ms);
|
||
2 years ago
|
|
||
|
if (human_readable) {
|
||
|
+ if (minimalized) {
|
||
|
+ printf ("%s | sig %3u%% | snr %3u%% | ber %d",
|
||
|
+ ntime,
|
||
|
+ (fe_info.signal_strength * 100) / 0xffff,
|
||
|
+ (fe_info.snr * 100) / 0xffff,
|
||
|
+ fe_info.ber);
|
||
|
+ } else {
|
||
|
printf ("status %c%c%c%c%c | signal %3u%% | snr %3u%% | ber %d | unc %d | ",
|
||
|
fe_info.signal ? 'S' : ' ',
|
||
|
fe_info.carrier ? 'C' : ' ',
|
||
2 years ago
|
@@ -106,7 +126,15 @@
|
||
2 years ago
|
(fe_info.snr * 100) / 0xffff,
|
||
|
fe_info.ber,
|
||
|
fe_info.ucblocks);
|
||
|
+ }
|
||
|
} else {
|
||
|
+ if (minimalized) {
|
||
|
+ printf ("%s | sig %04x | snr %04x | ber %08x",
|
||
|
+ ntime,
|
||
|
+ fe_info.signal_strength,
|
||
|
+ fe_info.snr,
|
||
|
+ fe_info.ber);
|
||
|
+ } else {
|
||
|
printf ("status %c%c%c%c%c | signal %04x | snr %04x | ber %08x | unc %08x | ",
|
||
|
fe_info.signal ? 'S' : ' ',
|
||
|
fe_info.carrier ? 'C' : ' ',
|
||
2 years ago
|
@@ -117,9 +145,11 @@
|
||
2 years ago
|
fe_info.snr,
|
||
|
fe_info.ber,
|
||
|
fe_info.ucblocks);
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
if (fe_info.lock)
|
||
|
+ if (!minimalized)
|
||
|
printf("FE_HAS_LOCK");
|
||
|
|
||
|
// create beep if acoustical_mode enabled
|
||
2 years ago
|
@@ -188,7 +218,7 @@
|
||
2 years ago
|
int human_readable = 0;
|
||
|
int opt;
|
||
|
|
||
|
- while ((opt = getopt(argc, argv, "rAHa:f:c:")) != -1) {
|
||
2 years ago
|
+ while ((opt = getopt(argc, argv, "rAMHa:f:c:t:")) != -1) {
|
||
2 years ago
|
switch (opt)
|
||
|
{
|
||
|
default:
|
||
2 years ago
|
@@ -200,12 +230,19 @@
|
||
2 years ago
|
case 'c':
|
||
|
count = strtoul(optarg, NULL, 0);
|
||
|
break;
|
||
|
+ case 't':
|
||
|
+ fl_sleep_time = strtof(optarg, NULL);
|
||
|
+ sleep_time=fl_sleep_time*1000000;
|
||
|
+ break;
|
||
|
case 'f':
|
||
|
frontend = strtoul(optarg, NULL, 0);
|
||
|
break;
|
||
2 years ago
|
case 'H':
|
||
|
human_readable = 1;
|
||
|
break;
|
||
|
+ case 'M':
|
||
|
+ minimalized = 1;
|
||
|
+ break;
|
||
|
case 'A':
|
||
|
// Acoustical mode: we have to reduce the delay between
|
||
|
// checks in order to hear nice sound
|