[linux-dvb] [PATCH] femon: added option for the count of printed lines
Hermann Gausterer
linux-dvb-mailinglist at mrq1.org
Fri Jul 27 13:24:11 CEST 2007
hi
i changed femon to accept an option for the number of printed
lines; there is also a script attached which uses this to
convenient print out the status of all dvb cards in a system! :-)
i think, this script should be added to dvb-apps.
patch is again
http://www.linuxtv.org/downloads/linuxtv-dvb-1.1.1.tar.bz2
please reply in case of problems accepting the patch!
mfg hermann
-------------- next part --------------
--- linuxtv-dvb-apps-1.1.1----REDHAT_COMPILED_BINS_SIND_OK/util/szap/femon.c 2007-07-27 11:49:40.629571000 +0200
+++ linuxtv-dvb-apps-1.1.1/util/szap/femon.c 2007-07-27 13:21:01.044889878 +0200
@@ -50,6 +50,8 @@
static char *usage_str =
"\nusage: femon [options]\n"
" -a number : use given adapter (default 0)\n"
+ " -c number : the number of printed lines before exit (default 0)\n"
+ " : 0 = infinite\n"
" -f number : use given frontend (default 0)\n\n";
@@ -61,13 +63,13 @@ static void usage(void)
static
-int check_frontend (int fe_fd)
+int check_frontend (int fe_fd, int count)
{
fe_status_t status;
uint16_t snr, signal;
uint32_t ber, uncorrected_blocks;
-
- do {
+ /* will stop after 2^32 lines = 2^32 seconds -> that is long enough! */
+ for ( ; count != 0 ; count-- ) {
ioctl(fe_fd, FE_READ_STATUS, &status);
ioctl(fe_fd, FE_READ_SIGNAL_STRENGTH, &signal);
ioctl(fe_fd, FE_READ_SNR, &snr);
@@ -82,14 +84,14 @@ int check_frontend (int fe_fd)
printf("\n");
usleep(1000000);
- } while (1);
+ }
return 0;
}
static
-int do_mon(unsigned int adapter, unsigned int frontend)
+int do_mon(unsigned int adapter, unsigned int frontend, int count)
{
char fedev[128];
int fefd;
@@ -115,7 +117,7 @@ int do_mon(unsigned int adapter, unsigne
printf("FE: %s (%s)\n", fe_info.name, fe_info.type == FE_QPSK ? "SAT" :
fe_info.type == FE_QAM ? "CABLE": "TERRESTRIAL");
- check_frontend (fefd);
+ check_frontend (fefd, count);
close(fefd);
@@ -125,9 +127,8 @@ int do_mon(unsigned int adapter, unsigne
int main(int argc, char *argv[])
{
unsigned int adapter = 0, frontend = 0;
- int opt;
-
- while ((opt = getopt(argc, argv, "hlrn:a:f:d:")) != -1) {
+ int opt, count = -1;
+ while ((opt = getopt(argc, argv, "hlrn:a:c:f:d:")) != -1) {
switch (opt)
{
case '?':
@@ -137,12 +138,18 @@ int main(int argc, char *argv[])
case 'a':
adapter = strtoul(optarg, NULL, 0);
break;
+ case 'c':
+ count = strtol(optarg, NULL, 0);
+ if ( count <= 0 ) {
+ count = -1;
+ }
+ break;
case 'f':
frontend = strtoul(optarg, NULL, 0);
}
}
- do_mon(adapter, frontend);
+ do_mon(adapter, frontend, count);
return FALSE;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: check-frontends.sh
Type: application/x-sh
Size: 233 bytes
Desc: not available
Url : http://www.linuxtv.org/pipermail/linux-dvb/attachments/20070727/e023f269/attachment.sh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.linuxtv.org/pipermail/linux-dvb/attachments/20070727/e023f269/attachment.pgp
More information about the linux-dvb
mailing list