Mercurial > pt1
diff recpt1/recpt1.c @ 81:6e3bb2c0c5b6
add an option to specify LNB voltage
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 12 Dec 2009 22:30:43 +0900 |
parents | 5a0126d8af17 |
children | 1b61fd7c6fde |
line wrap: on
line diff
--- a/recpt1/recpt1.c Sat Dec 12 22:29:30 2009 +0900 +++ b/recpt1/recpt1.c Sat Dec 12 22:30:43 2009 +0900 @@ -50,15 +50,16 @@ decoder *decoder; decoder_options *dopt; int ch; + int lnb; /* LNB voltage */ int tfd; /* tuner fd */ int wfd; /* output file fd */ ISDB_T_FREQ_CONV_TABLE *table; sock_data *sock_data; pthread_t signal_thread; int recsec; + time_t start_time; boolean indefinite; int msqid; - time_t start_time; } thread_data; typedef struct msgbuf { @@ -400,7 +401,7 @@ time_t cur_time; time(&cur_time); - fprintf(stderr, "Recorded %d sec\n", + fprintf(stderr, "Recorded %dsec\n", (int)(cur_time - data->start_time)); return NULL; @@ -410,9 +411,9 @@ show_usage(char *cmd) { #ifdef HAVE_LIBARIB25 - fprintf(stderr, "Usage: \n%s [--b25 [--round N] [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] channel rectime destfile\n", cmd); + fprintf(stderr, "Usage: \n%s [--b25 [--round N] [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] channel rectime destfile\n", cmd); #else - fprintf(stderr, "Usage: \n%s [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] channel rectime destfile\n", cmd); + fprintf(stderr, "Usage: \n%s [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] channel rectime destfile\n", cmd); #endif fprintf(stderr, "\n"); fprintf(stderr, "Remarks:\n"); @@ -434,6 +435,7 @@ fprintf(stderr, " --addr hostname: Hostname or address to connect\n"); fprintf(stderr, " --port portnumber: Port number to connect\n"); fprintf(stderr, "--device devicefile: Specify devicefile to use\n"); + fprintf(stderr, "--lnb voltage: Specify LNB voltage (0, 11, 15)\n"); fprintf(stderr, "--help: Show this help\n"); fprintf(stderr, "--version: Show version\n"); fprintf(stderr, "--list: Show channel list\n"); @@ -535,11 +537,11 @@ P = log10(5505024/(double)rc) * 10; CNR = (0.000024 * P * P * P * P) - (0.0016 * P * P * P) + (0.0398 * P * P) + (0.5491 * P)+3.0965; - fprintf(stderr, "Signal = %f dB\n", CNR); + fprintf(stderr, "C/N = %fdB\n", CNR); } else { CNR = getsignal_isdb_s(rc); - fprintf(stderr, "Signal = %f dB\n", CNR); + fprintf(stderr, "C/N = %fdB\n", CNR); } } @@ -549,14 +551,6 @@ /* stop recording */ ioctl(tdata->tfd, STOP_REC, 0); - /* restore LNB state */ -#if 0 - if(ptr->type == CHTYPE_SATELLITE) { - if(ioctl(tfd, LNB_DISABLE, 0) < 0) { - return 0 ; - } - } -#endif /* xxx need mutex? */ f_exit = TRUE; @@ -653,7 +647,7 @@ /* power on LNB */ if(tdata->table->type == CHTYPE_SATELLITE) { - if(ioctl(tdata->tfd, LNB_ENABLE, 0) < 0) { + if(ioctl(tdata->tfd, LNB_ENABLE, tdata->lnb) < 0) { close(tdata->tfd); fprintf(stderr, "Power on LNB failed: %s\n", device); return 1; @@ -686,7 +680,7 @@ if(tdata->tfd >= 0) { /* power on LNB */ if(tdata->table->type == CHTYPE_SATELLITE) { - if(ioctl(tdata->tfd, LNB_ENABLE, 0) < 0) { + if(ioctl(tdata->tfd, LNB_ENABLE, tdata->lnb) < 0) { close(tdata->tfd); tdata->tfd = -1; continue; @@ -803,6 +797,7 @@ 0 /* emm */ }; tdata.dopt = &dopt; + tdata.lnb = 0; int result; int option_index; @@ -810,11 +805,13 @@ #ifdef HAVE_LIBARIB25 { "b25", 0, NULL, 'b'}, { "B25", 0, NULL, 'b'}, -#endif { "round", 1, NULL, 'r'}, { "strip", 0, NULL, 's'}, { "emm", 0, NULL, 'm'}, { "EMM", 0, NULL, 'm'}, +#endif + { "LNB", 1, NULL, 'n'}, + { "lnb", 1, NULL, 'n'}, { "udp", 0, NULL, 'u'}, { "addr", 1, NULL, 'a'}, { "port", 1, NULL, 'p'}, @@ -833,8 +830,10 @@ int port_to = 1234; sock_data *sockdata = NULL; char *device = NULL; + int val; + char *voltage[] = {"0V", "11V", "15V"}; - while((result = getopt_long(argc, argv, "br:smua:p:d:hvl", + while((result = getopt_long(argc, argv, "br:smn:ua:p:d:hvl", long_options, &option_index)) != -1) { switch(result) { case 'b': @@ -874,6 +873,21 @@ exit(0); break; /* following options require argument */ + case 'n': + val = atoi(optarg); + switch(val) { + case 11: + tdata.lnb = 1; + break; + case 15: + tdata.lnb = 2; + break; + default: + tdata.lnb = 0; + break; + } + fprintf(stderr, "LNB = %s\n", voltage[tdata.lnb]); + break; case 'r': dopt.round = atoi(optarg); fprintf(stderr, "set round %d\n", dopt.round);