Project

General

Profile

Bug #4440 » dvb-apps-femon.c-patch.patch

Petar Ivanov, 2017-06-23 20:19

View differences:

util/femon/femon.c Fri Oct 07 01:26:04 2011 +0530 → util/femon/femon.c Fri Oct 28 18:52:12 2011 -0400
16 16
  * You should have received a copy of the GNU General Public License
17 17
  * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
 *
20
 * James Lockie: Oct. 2011
21
 * modified to add a switch (-2) to show signal/snr in dB
19 22
  */
20 23
 
21 24
 
......
37 40
 
38 41
 #include <libdvbapi/dvbfe.h>
39 42
 
43
/* the s5h1409 delivers both fields in 0.1dB increments, while
44
 * some demods expect signal to be 0-65535 and SNR to be in 1/256 increments
45
*/
46

  
40 47
 #define FE_STATUS_PARAMS (DVBFE_INFO_LOCKSTATUS|DVBFE_INFO_SIGNAL_STRENGTH|DVBFE_INFO_BER|DVBFE_INFO_SNR|DVBFE_INFO_UNCORRECTED_BLOCKS)
41 48
 
42 49
 static char *usage_str =
43 50
     "\nusage: femon [options]\n"
44
    "     -H        : human readable output\n"
51
    "     -H        : human readable output: (signal: 0-65335, snr: 1/256 increments)\n"
52
    "     -2        : human readable output: (signal and snr in .1 dB increments)\n"
45 53
     "     -A        : Acoustical mode. A sound indicates the signal quality.\n"
46 54
     "     -r        : If 'Acoustical mode' is active it tells the application\n"
47 55
     "                 is called remotely via ssh. The sound is heard on the 'real'\n"
......
62 70
 
63 71
 
64 72
 static
65
int check_frontend (struct dvbfe_handle *fe, int human_readable, unsigned int count)
73
int check_frontend (struct dvbfe_handle *fe, int human_readable, int db_readable, unsigned int count)
66 74
 {
67 75
 	struct dvbfe_info fe_info;
68 76
 	unsigned int samples = 0;
......
93 101
 			fprintf(stderr, "Problem retrieving frontend information: %m\n");
94 102
 		}
95 103
 
104
		//  print the status code
105
		printf ("status %c%c%c%c%c | ",
106
			fe_info.signal ? 'S' : ' ',
107
			fe_info.carrier ? 'C' : ' ',
108
			fe_info.viterbi ? 'V' : ' ',
109
			fe_info.sync ? 'Y' : ' ',
110
			fe_info.lock ? 'L' : ' ' );
96 111
 
112
		if (db_readable) {
113
                       printf ("signal %3.0fdB | snr %3.0fdB",
114
				(fe_info.signal_strength * 0.1),
115
				(fe_info.snr * 0.1) );
116
		} else if (human_readable) {
117
                       printf ("signal %3u%% | snr %3u%%",
118
				(fe_info.signal_strength * 100) / 0xffff,
119
				(fe_info.snr * 100) / 0xffff );
120
		} else {
121
			printf ("signal %04x | snr %04x",
122
				fe_info.signal_strength,
123
				fe_info.snr );
124
		}
97 125
 
98
		if (human_readable) {
99
                       printf ("status %c%c%c%c%c | signal %3u%% | snr %3u%% | ber %d | unc %d | ",
100
				fe_info.signal ? 'S' : ' ',
101
				fe_info.carrier ? 'C' : ' ',
102
				fe_info.viterbi ? 'V' : ' ',
103
				fe_info.sync ? 'Y' : ' ',
104
				fe_info.lock ? 'L' : ' ',
105
				(fe_info.signal_strength * 100) / 0xffff,
106
				(fe_info.snr * 100) / 0xffff,
107
				fe_info.ber,
108
				fe_info.ucblocks);
109
		} else {
110
			printf ("status %c%c%c%c%c | signal %04x | snr %04x | ber %08x | unc %08x | ",
111
				fe_info.signal ? 'S' : ' ',
112
				fe_info.carrier ? 'C' : ' ',
113
				fe_info.viterbi ? 'V' : ' ',
114
				fe_info.sync ? 'Y' : ' ',
115
				fe_info.lock ? 'L' : ' ',
116
				fe_info.signal_strength,
117
				fe_info.snr,
118
				fe_info.ber,
119
				fe_info.ucblocks);
120
		}
126
		/* always print ber and ucblocks */
127
		printf (" | ber %08x | unc %08x | ",
128
			fe_info.ber,
129
			fe_info.ucblocks);
121 130
 
122 131
 		if (fe_info.lock)
123 132
 			printf("FE_HAS_LOCK");
......
145 154
 
146 155
 
147 156
 static
148
int do_mon(unsigned int adapter, unsigned int frontend, int human_readable, unsigned int count)
157
int do_mon(unsigned int adapter, unsigned int frontend, int human_readable, int db_readable, unsigned int count)
149 158
 {
150 159
 	int result;
151 160
 	struct dvbfe_handle *fe;
......
175 184
 	}
176 185
 	printf("FE: %s (%s)\n", fe_info.name, fe_type);
177 186
 
178
	result = check_frontend (fe, human_readable, count);
187
	result = check_frontend (fe, human_readable, db_readable, count);
179 188
 
180 189
 	dvbfe_close(fe);
181 190
 
......
186 195
 {
187 196
 	unsigned int adapter = 0, frontend = 0, count = 0;
188 197
 	int human_readable = 0;
198
	int db_readable = 0;
189 199
 	int opt;
190 200
 
191
       while ((opt = getopt(argc, argv, "rAHa:f:c:")) != -1) {
201
       while ((opt = getopt(argc, argv, "rAH2a:f:c:")) != -1) {
192 202
 		switch (opt)
193 203
 		{
194 204
 		default:
......
206 216
 		case 'H':
207 217
 			human_readable = 1;
208 218
 			break;
219
		case '2':
220
			db_readable = 1;
221
			break;
209 222
 		case 'A':
210 223
 			// Acoustical mode: we have to reduce the delay between
211 224
 			// checks in order to hear nice sound
......
218 231
 		}
219 232
 	}
220 233
 
221
	do_mon(adapter, frontend, human_readable, count);
234
	do_mon(adapter, frontend, human_readable, db_readable, count);
222 235
 
223 236
 	return 0;
224 237
 }
(3-3/3)