1
0
mirror of https://github.com/DigitalDevices/octonet.git synced 2023-10-10 13:36:52 +02:00
reenable NIT scan
command line interface revised
fractional frequencies for dvbc
help
trailing space cleanup
This commit is contained in:
mvoelkel 2016-01-09 21:16:43 +01:00
parent 4680835d46
commit 6396054498

View File

@ -29,6 +29,8 @@
#include <ctype.h>
#include "list.h"
#include <getopt.h>
time_t mtime(time_t *t)
{
struct timespec ts;
@ -41,6 +43,7 @@ time_t mtime(time_t *t)
}
static int done = 0;
static int use_nit = 0;
char *pol2str[] = {"v", "h", "r", "l"};
char *msys2str [] = {"undef", "dvbc", "dvbcb", "dvbt", "dss", "dvbs", "dvbs2", "dvbh",
@ -160,6 +163,7 @@ struct tp_info {
uint16_t id;
uint32_t msys;
uint32_t freq;
uint32_t freq_frac;
uint32_t pol;
uint32_t sr;
uint32_t ro;
@ -167,8 +171,6 @@ struct tp_info {
uint32_t bw;
uint32_t fec;
uint32_t isi;
char* request;
};
struct scantp {
@ -201,7 +203,7 @@ static struct service *get_service(struct tp_info *tpi, uint16_t sid)
}
s = calloc(1, sizeof(struct service));
s->sid = sid;
snprintf(s->name, sizeof(s->name), "SID 0x%04x", sid);
snprintf(s->name, sizeof(s->name), "Service %d", sid);
snprintf(s->pname, sizeof(s->name), "none");
list_add(&s->link, &tpi->services);
return s;
@ -629,8 +631,8 @@ int cmp_tp(struct tp_info *a, struct tp_info *b)
if (a->freq != b->freq + 1 && a->freq != b->freq - 1)
return 0;
}
if (a->mod != b->mod )
return 0;
//~ if (a->mod != b->mod )
//~ return 0;
if (a->pol != b->pol )
return 0;
return 1;
@ -941,6 +943,7 @@ static int nit_cb(struct sfilter *sf)
for (c = tsp + 2; c < slen; c += tdl) {
//dump(buf + c + 6, tdl);
memset(&t, 0, sizeof(struct tp_info));
t.tsid = get16(buf + c);
t.onid = get16(buf + c + 2);
t.nid = nid;
@ -949,8 +952,8 @@ static int nit_cb(struct sfilter *sf)
c += 6;
switch (buf[c]) {
case 0x43:
t.request = NULL;
t.freq = getbcd(buf + c + 2, 8) / 100;
t.freq_frac = 0;
t.pos = getbcd(buf + c + 6, 4);
t.sr = getbcd(buf + c + 9, 7) / 10;
t.east = (buf[c + 8] & 0x80) >> 7;
@ -965,8 +968,12 @@ static int nit_cb(struct sfilter *sf)
add_tp(sip, &t);
break;
case 0x44:
t.request = NULL;
t.freq = getbcd(buf + c + 2, 8) / 10000;
{
uint32_t freq = getbcd(buf + c + 2, 8);
t.freq = freq / 10000;
t.freq_frac = freq % 10000;
}
t.sr = getbcd(buf + c + 9, 7) / 10;
t.mod = buf[c + 8]; // undef 16 32 64 128 256
t.msys = 1;
t.type = 1;
@ -1189,7 +1196,8 @@ static int proc_sec(struct pid_info *p)
break;
case 0x40:
case 0x41:
// res = nit_cb(sf);
if( use_nit )
res = nit_cb(sf);
break;
case 0x42:
case 0x46:
@ -1505,7 +1513,8 @@ static int scan_tp(struct scantp *stp)
n = recvfrom(scon->usock, buf, sizeof(buf), 0, 0, 0);
if (n > 12) {
proc_tsps(&sip->stp.tsi, buf + 12, n - 12);
stp->timeout = mtime(NULL) + 10;
// stp->timeout = mtime(NULL) + 10;
stp->timeout += 60;
}
}
}
@ -1520,26 +1529,26 @@ void tpstring(struct tp_info *tpi, char *s, int slen)
{
int len;
if( tpi->request ) {
strncpy(s,tpi->request,slen);
}
else {
switch (tpi->msys) {
case 1:
if( tpi->freq_frac )
len = snprintf(s, slen,
"freq=%u&msys=dvbc&sr=6900&mtype=%s",
tpi->freq, mtype2str[tpi->mod]);
"freq=%u.%04u&msys=dvbc&sr=%u&mtype=%s",
tpi->freq, tpi->freq_frac, tpi->sr, mtype2str[tpi->mod]);
else
len = snprintf(s, slen,
"freq=%u&msys=dvbc&sr=%u&mtype=%s",
tpi->freq, tpi->sr, mtype2str[tpi->mod]);
break;
case 5:
case 6:
len = snprintf(s, slen,
"freq=%u&pol=%s&msys=%s&sr=%u",
tpi->freq, pol2str[tpi->pol&3],
"src=%u&freq=%u&pol=%s&msys=%s&sr=%u",
tpi->src,tpi->freq, pol2str[tpi->pol&3],
msys2str[tpi->msys], tpi->sr);
break;
}
}
}
static int scanip(struct scanip *sip)
@ -1561,7 +1570,7 @@ static int scanip(struct scanip *sip)
tpi = list_first_entry(&sip->tps, struct tp_info, link);
tpstring(tpi, &stp->scon.tune[0], sizeof(stp->scon.tune));
printf("\nTuning to: %s\n", stp->scon.tune);
printf("\nTUNE:%s\n", stp->scon.tune);
stp->tpi = tpi;
scan_tp(stp);
ts_info_release(tsi);
@ -1615,12 +1624,52 @@ void scan_cable(struct scanip *sip)
}
}
void usage() {
printf("Octoscan"
", Copyright (C) 2016 Digital Devices GmbH\n\n");
printf("octoscan [options] <server ip>\n");
printf(" <server ip> address of SAT>IP server\n");
printf("\n");
printf(" options:\n");
printf(" --use_nit, -n\n");
printf(" Use network information table\n");
printf(" if not specified only a single transponder is scanned\n");
printf(" --freq=<frequency>, -f <frequency>\n");
printf(" frequency in MHz (required)\n");
printf(" --sr=<symbolrate>, -f <symbolrate>\n");
printf(" symbolrate in kSymbols (required for DVB-S/S2 and DVB-C)\n");
printf(" DVB-S/S2 example: --sr=27500\n");
printf(" DVB-C example: --sr=6900\n");
printf(" --pol=<polarisation>, -f <polarisation>\n");
printf(" polarisation = v,h,r,l (required for DVB-S/S2)\n");
printf(" example: --pol=v\n");
printf(" --msys=<modulation system>, -f <modulation system>\n");
printf(" system = dvbs,dvbs2,dvbc (required)\n");
printf(" example: --msys=dvbs\n");
printf(" --mtype=<modulation type>, -f <modulation type>\n");
printf(" modulation type = 16qam,32qam,64qam,128qam,256qam (required for DVB-C)\n");
printf(" --help, -?\n");
printf("\n");
printf(" Notes on NIT scanning:\n");
printf(" NIT scanning is currently not reliable for DVB-S/S2 (to be fixed).\n");
printf(" With some cable providers or inhouse retransmission systems\n");
printf(" it may be not usable, i.e. due to wrong frequencies in the NIT.\n");
printf("\n");
printf(" Notes on hardware depencies:\n");
printf(" Depending on hardware configuration the scan will succeed even if\n");
printf(" some required parameters are wrong. This will result in a channel list\n");
printf(" which is usable only on the same hardware configuration.\n");
}
int main(int argc, char **argv)
{
struct sigaction term;
struct scanip sip;
struct tp_info tpi = {
struct tp_info tpi;
int i;
#if 0
struct tp_info tpi1 = {
.freq = 11836,
.pol = 1,
.msys = 5,
@ -1645,6 +1694,98 @@ int main(int argc, char **argv)
.mod = 5,
.sr = 6900,
};
#endif
if(argc < 2) {
usage();
exit(0);
};
memset(&tpi, 0, sizeof(struct tp_info));
while (1) {
int option_index = 0;
int c;
static struct option long_options[] = {
{"use_nit", no_argument, 0, 'n'},
{"freq", required_argument, 0, 'f'},
{"sr", required_argument, 0, 's'},
{"pol", required_argument, 0, 'p'},
{"msys", required_argument, 0, 'm'},
{"mtype", required_argument, 0, 't'},
{"help", no_argument , 0, '?'},
{0, 0, 0, 0}
};
c = getopt_long(argc, argv,
"nf:s:p:m:t:?",
long_options, &option_index);
if (c==-1)
break;
switch (c) {
case 'n':
use_nit = 1;
break;
case 'f':
tpi.freq = strtoul(optarg, NULL, 10);
break;
case 's':
tpi.sr = strtoul(optarg, NULL, 10);
break;
case 'S':
tpi.src = strtoul(optarg, NULL, 10);
break;
case 'p':
i = 0;
while( i < 4 ) {
if( strcmp(optarg,pol2str[i]) == 0 ) {
tpi.msys = i;
break;
}
i += 1;
}
break;
case 'm':
i = 0;
while( msys2str[i] ) {
if( strcmp(optarg,msys2str[i]) == 0 ) {
tpi.msys = i;
break;
}
i += 1;
}
break;
case 't':
i = 0;
while( mtype2str[i] ) {
if( strcmp(optarg,mtype2str[i]) == 0 ) {
tpi.mod = i;
break;
}
i += 1;
}
break;
case '?':
usage();
exit(0);
default:
break;
}
}
if( optind > argc - 1 ) {
printf("To many arguments\n\n");
usage();
exit(-1);
}
memset(&term, 0, sizeof(term));
term.sa_sigaction = term_action;
@ -1653,14 +1794,10 @@ int main(int argc, char **argv)
sigaction(SIGINT, &term, NULL);
scanip_init(&sip, argv[1]);
if( argc > 1 ) {
tpi.request = argv[2];
scanip_init(&sip, argv[optind]);
add_tp(&sip, &tpi);
}
else
add_tp(&sip, &tpi3);
//scan_cable(&sip);
scanip(&sip);
scanip_release(&sip);
}