[PATCH 3/3] femon: Handle -EOPNOTSUPP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Frontend drivers don't have to implement all monitoring callbacks. So
expect -EOPNOTSUPP and handle it properly.
---
 util/femon/femon.c |   75 +++++++++++++++++++++++++++++++++--------------------
 1 file changed, 48 insertions(+), 27 deletions(-)

--- dvb-apps-3ee111da5b3a.orig/util/femon/femon.c	2013-06-03 17:22:56.923398598 +0200
+++ dvb-apps-3ee111da5b3a/util/femon/femon.c	2013-06-03 17:23:16.946398895 +0200
@@ -67,6 +67,7 @@ int check_frontend (struct dvbfe_handle
 	struct dvbfe_info fe_info;
 	unsigned int samples = 0;
 	FILE *ttyFile=NULL;
+	int got_info;
 	
 	// We dont write the "beep"-codes to stdout but to /dev/tty1.
 	// This is neccessary for Thin-Client-Systems or Streaming-Boxes
@@ -89,39 +90,59 @@ int check_frontend (struct dvbfe_handle
 	}
 
 	do {
-		if (dvbfe_get_info(fe, FE_STATUS_PARAMS, &fe_info, DVBFE_INFO_QUERYTYPE_IMMEDIATE, 0) != FE_STATUS_PARAMS) {
+		got_info = dvbfe_get_info(fe, FE_STATUS_PARAMS, &fe_info, DVBFE_INFO_QUERYTYPE_IMMEDIATE, 0);
+		if (got_info & DVBFE_INFO_LOCKSTATUS) {
+			printf ("status %c%c%c%c%c | ",
+				fe_info.signal ? 'S' : ' ',
+				fe_info.carrier ? 'C' : ' ',
+				fe_info.viterbi ? 'V' : ' ',
+				fe_info.sync ? 'Y' : ' ',
+				fe_info.lock ? 'L' : ' ');
+		} else {
 			fprintf(stderr, "Problem retrieving frontend information: %m\n");
+			printf ("status ----- | ");
 		}
 
 
-		printf ("status %c%c%c%c%c | ",
-			fe_info.signal ? 'S' : ' ',
-			fe_info.carrier ? 'C' : ' ',
-			fe_info.viterbi ? 'V' : ' ',
-			fe_info.sync ? 'Y' : ' ',
-			fe_info.lock ? 'L' : ' ');
-
 		if (human_readable) {
-			// SNR should be in units of 0.1 dB but some drivers do
-			// not follow that rule, thus this heuristic.
-			if (fe_info.snr < 1000)
-				printf ("signal %3u%% | snr %4.1fdB | ber %d | unc %d | ",
-					(fe_info.signal_strength * 100) / 0xffff,
-					fe_info.snr / 10.,
-					fe_info.ber,
-					fe_info.ucblocks);
-			else
-				printf ("signal %3u%% | snr %3u%% | ber %d | unc %d | ",
-					(fe_info.signal_strength * 100) / 0xffff,
-					(fe_info.snr * 100) / 0xffff,
-					fe_info.ber,
-					fe_info.ucblocks);
+			if (got_info & DVBFE_INFO_SIGNAL_STRENGTH)
+				printf ("signal %3u%% | ", (fe_info.signal_strength * 100) / 0xffff);
+			else
+				printf ("signal ---%% | ");
+			if (got_info & DVBFE_INFO_SNR) {
+				// SNR should be in units of 0.1 dB but some drivers do
+				// not follow that rule, thus this heuristic.
+				if (fe_info.snr < 1000)
+					printf ("snr %4.1fdB | ", fe_info.snr / 10.);
+				else
+					printf ("snr %3u%% | ", (fe_info.snr * 100) / 0xffff);
+			} else
+				printf ("snr ---- | ");
+			if (got_info & DVBFE_INFO_BER)
+				printf ("ber %d | ", fe_info.ber);
+			else
+				printf ("ber - | ");
+			if (got_info & DVBFE_INFO_UNCORRECTED_BLOCKS)
+				printf ("unc %d | ", fe_info.ucblocks);
+			else
+				printf ("unc - | ");
 		} else {
-			printf ("signal %04x | snr %04x | ber %08x | unc %08x | ",
-				fe_info.signal_strength,
-				fe_info.snr,
-				fe_info.ber,
-				fe_info.ucblocks);
+			if (got_info & DVBFE_INFO_SIGNAL_STRENGTH)
+				printf ("signal %04x | ", fe_info.signal_strength);
+			else
+				printf ("signal ---- | ");
+			if (got_info & DVBFE_INFO_SNR)
+				printf ("snr %04x | ", fe_info.snr);
+			else
+				printf ("snr ---- | ");
+			if (got_info & DVBFE_INFO_BER)
+				printf ("ber %08x | ", fe_info.ber);
+			else
+				printf ("ber -------- | ");
+			if (got_info & DVBFE_INFO_UNCORRECTED_BLOCKS)
+				printf ("unc %08x | ", fe_info.ucblocks);
+			else
+				printf ("unc -------- | ");
 		}
 
 		if (fe_info.lock)

-- 
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux