From: James <bjlockie@lockie.ca>
To: linux-media Mailing List <linux-media@vger.kernel.org>
Subject: Re: femon patch for dB
Date: Sat, 29 Oct 2011 01:12:58 -0400 [thread overview]
Message-ID: <4EAB8B5A.5040908@lockie.ca> (raw)
In-Reply-To: <4EAB612A.6010003@xenotime.net>
diff -r d4e8bf5658ce util/femon/femon.c
--- a/util/femon/femon.c Fri Oct 07 01:26:04 2011 +0530
+++ b/util/femon/femon.c Fri Oct 28 18:52:12 2011 -0400
@@ -16,6 +16,9 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * James Lockie: Oct. 2011
+ * modified to add a switch (-2) to show signal/snr in dB
*/
@@ -37,11 +40,16 @@
#include <libdvbapi/dvbfe.h>
+/* the s5h1409 delivers both fields in 0.1dB increments, while
+ * some demods expect signal to be 0-65535 and SNR to be in 1/256
increments
+*/
+
#define FE_STATUS_PARAMS
(DVBFE_INFO_LOCKSTATUS|DVBFE_INFO_SIGNAL_STRENGTH|DVBFE_INFO_BER|DVBFE_INFO_SNR|DVBFE_INFO_UNCORRECTED_BLOCKS)
static char *usage_str =
"\nusage: femon [options]\n"
- " -H : human readable output\n"
+ " -H : human readable output: (signal: 0-65335, snr:
1/256 increments)\n"
+ " -2 : human readable output: (signal and snr in .1 dB
increments)\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"
@@ -62,7 +70,7 @@ static void usage(void)
static
-int check_frontend (struct dvbfe_handle *fe, int human_readable,
unsigned int count)
+int check_frontend (struct dvbfe_handle *fe, int human_readable, int
db_readable, unsigned int count)
{
struct dvbfe_info fe_info;
unsigned int samples = 0;
@@ -93,31 +101,32 @@ int check_frontend (struct dvbfe_handle
fprintf(stderr, "Problem retrieving frontend information:
%m\n");
}
+ // print the status code
+ 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 (db_readable) {
+ printf ("signal %3.0fdB | snr %3.0fdB",
+ (fe_info.signal_strength * 0.1),
+ (fe_info.snr * 0.1) );
+ } else if (human_readable) {
+ printf ("signal %3u%% | snr %3u%%",
+ (fe_info.signal_strength * 100) / 0xffff,
+ (fe_info.snr * 100) / 0xffff );
+ } else {
+ printf ("signal %04x | snr %04x",
+ fe_info.signal_strength,
+ fe_info.snr );
+ }
- if (human_readable) {
- printf ("status %c%c%c%c%c | signal %3u%% | snr
%3u%% | ber %d | unc %d | ",
- fe_info.signal ? 'S' : ' ',
- fe_info.carrier ? 'C' : ' ',
- fe_info.viterbi ? 'V' : ' ',
- fe_info.sync ? 'Y' : ' ',
- fe_info.lock ? 'L' : ' ',
- (fe_info.signal_strength * 100) / 0xffff,
- (fe_info.snr * 100) / 0xffff,
- fe_info.ber,
- fe_info.ucblocks);
- } else {
- printf ("status %c%c%c%c%c | signal %04x | snr %04x | ber
%08x | unc %08x | ",
- fe_info.signal ? 'S' : ' ',
- fe_info.carrier ? 'C' : ' ',
- fe_info.viterbi ? 'V' : ' ',
- fe_info.sync ? 'Y' : ' ',
- fe_info.lock ? 'L' : ' ',
- fe_info.signal_strength,
- fe_info.snr,
- fe_info.ber,
- fe_info.ucblocks);
- }
+ /* always print ber and ucblocks */
+ printf (" | ber %08x | unc %08x | ",
+ fe_info.ber,
+ fe_info.ucblocks);
if (fe_info.lock)
printf("FE_HAS_LOCK");
@@ -145,7 +154,7 @@ int check_frontend (struct dvbfe_handle
static
-int do_mon(unsigned int adapter, unsigned int frontend, int
human_readable, unsigned int count)
+int do_mon(unsigned int adapter, unsigned int frontend, int
human_readable, int db_readable, unsigned int count)
{
int result;
struct dvbfe_handle *fe;
@@ -175,7 +184,7 @@ int do_mon(unsigned int adapter, unsigne
}
printf("FE: %s (%s)\n", fe_info.name, fe_type);
- result = check_frontend (fe, human_readable, count);
+ result = check_frontend (fe, human_readable, db_readable, count);
dvbfe_close(fe);
@@ -186,9 +195,10 @@ int main(int argc, char *argv[])
{
unsigned int adapter = 0, frontend = 0, count = 0;
int human_readable = 0;
+ int db_readable = 0;
int opt;
- while ((opt = getopt(argc, argv, "rAHa:f:c:")) != -1) {
+ while ((opt = getopt(argc, argv, "rAH2a:f:c:")) != -1) {
switch (opt)
{
default:
@@ -206,6 +216,9 @@ int main(int argc, char *argv[])
case 'H':
human_readable = 1;
break;
+ case '2':
+ db_readable = 1;
+ break;
case 'A':
// Acoustical mode: we have to reduce the delay between
// checks in order to hear nice sound
@@ -218,7 +231,7 @@ int main(int argc, char *argv[])
}
}
- do_mon(adapter, frontend, human_readable, count);
+ do_mon(adapter, frontend, human_readable, db_readable, count);
return 0;
}
next prev parent reply other threads:[~2011-10-29 5:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-28 23:01 femon patch for dB James
2011-10-29 0:21 ` Marek Vasut
2011-10-29 2:12 ` Randy Dunlap
2011-10-29 5:12 ` James [this message]
2011-10-29 5:39 ` Randy Dunlap
2011-10-29 6:37 ` Mauro Carvalho Chehab
2011-10-30 13:52 ` Michael Krufky
2011-10-30 14:01 ` Michael Krufky
2011-10-31 16:42 ` James
2011-10-30 16:21 ` VDR User
2011-10-30 15:42 ` Antti Palosaari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EAB8B5A.5040908@lockie.ca \
--to=bjlockie@lockie.ca \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.