Patch to scan utility that allows giving data for initial tuning (DVB-S) from the command line instead of a file only

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

 



Hello.

Here is my patch to scan utility that allows giving data for initial tuning (DVB-S) from the command line instead of a file only.

It is useful for me and maybe it will be useful for someone else.

18a19,21
>  *
>  * 2008-05-31 - Added -F-S-z-E console parameters for initial tuning
>  *    Added by Wmn
1691c1694
< static int tune_initial (int frontend_fd, const char *initial)
---
> static int tune_initial (int frontend_fd, const char *initial, unsigned int freq, unsigned int srate, char polar, char *_fec)
1699,1702c1702,1801
<  inif = fopen(initial, "r");
<  if (!inif) {
<   error("cannot open '%s': %d %m\n", initial, errno);
<   return -1;
---
>     if (!freq || !srate)
>     {
>         inif = fopen(initial, "r");
>         if (!inif) {
>             error("cannot open '%s': %d %m\n", initial, errno);
>             return -1;
>         }
>         while (fgets(buf, sizeof(buf), inif)) {
>             if (buf[0] == '#' || buf[0] == '\n')
>                 ;
>             else if (sscanf(buf, "S %u %1[HVLR] %u %4s\n", &f, pol, &sr, fec) == 4) {
>                 t = alloc_transponder(f);
>                 t->type = FE_QPSK;
>                 switch(pol[0]) {
>                     case 'H':
>                     case 'L':
>                         t->polarisation = POLARISATION_HORIZONTAL;
>                         break;
>                     default:
>                         t->polarisation = POLARISATION_VERTICAL;;
>                         break;
>                 }
>                 t->param.inversion = spectral_inversion;
>                 t->param.u.qpsk.symbol_rate = sr;
>                 t->param.u.qpsk.fec_inner = str2fec(fec);
>                 info("initial transponder %u %c %u %d\n",
>                         t->param.frequency,
>                         pol[0], sr,
>                         t->param.u.qpsk.fec_inner);
>             }
>             else if (sscanf(buf, "C %u %u %4s %6s\n", &f, &sr, fec, qam) == 4) {
>                 t = alloc_transponder(f);
>                 t->type = FE_QAM;
>                 t->param.inversion = spectral_inversion;
>                 t->param.u.qam.symbol_rate = sr;
>                 t->param.u.qam.fec_inner = str2fec(fec);
>                 t->param.u.qam.modulation = str2qam(qam);
>                 info("initial transponder %u %u %d %d\n",
>                         t->param.frequency,
>                         sr,
>                         t->param.u.qam.fec_inner,
>                         t->param.u.qam.modulation);
>             }
>             else if (sscanf(buf, "T %u %4s %4s %4s %7s %4s %4s %4s\n",
>                         &f, bw, fec, fec2, qam, mode, guard, hier) == 8) {
>                 t = alloc_transponder(f);
>                 t->type = FE_OFDM;
>                 t->param.inversion = spectral_inversion;
>                 t->param.u.ofdm.bandwidth = str2bandwidth(bw);
>                 t->param.u.ofdm.code_rate_HP = str2fec(fec);
>                 if (t->param.u.ofdm.code_rate_HP == FEC_NONE)
>                     t->param.u.ofdm.code_rate_HP = FEC_AUTO;
>                 t->param.u.ofdm.code_rate_LP = str2fec(fec2);
>                 if (t->param.u.ofdm.code_rate_LP == FEC_NONE)
>                     t->param.u.ofdm.code_rate_LP = FEC_AUTO;
>                 t->param.u.ofdm.constellation = str2qam(qam);
>                 t->param.u.ofdm.transmission_mode = str2mode(mode);
>                 t->param.u.ofdm.guard_interval = str2guard(guard);
>                 t->param.u.ofdm.hierarchy_information = str2hier(hier);
>                 info("initial transponder %u %d %d %d %d %d %d %d\n",
>                         t->param.frequency,
>                         t->param.u.ofdm.bandwidth,
>                         t->param.u.ofdm.code_rate_HP,
>                         t->param.u.ofdm.code_rate_LP,
>                         t->param.u.ofdm.constellation,
>                         t->param.u.ofdm.transmission_mode,
>                         t->param.u.ofdm.guard_interval,
>                         t->param.u.ofdm.hierarchy_information);
>             }
>             else if (sscanf(buf, "A %u %7s\n",
>                         &f,qam) == 2) {
>                 t = alloc_transponder(f);
>                 t->type = FE_ATSC;
>                 t->param.u.vsb.modulation = str2qam(qam);
>             } else
>                 error("cannot parse'%s'\n", buf);
>         }
>
>         fclose(inif);
>     }
>     else
>     {
>         t = alloc_transponder(freq);
>         t->type = FE_QPSK;
>         switch(polar) {
>             case 'H':
>             case 'L':
>                 t->polarisation = POLARISATION_HORIZONTAL;
>                 break;
>             default:
>                 t->polarisation = POLARISATION_VERTICAL;;
>                 break;
>         }
>         t->param.inversion = spectral_inversion;
>         t->param.u.qpsk.symbol_rate = srate;
>         t->param.u.qpsk.fec_inner = str2fec(_fec);
>         info("initial transponder %u %c %u %d\n",
>                 t->param.frequency,
>                 polar, srate,
>                 t->param.u.qpsk.fec_inner);
1704,1775d1802
<  while (fgets(buf, sizeof(buf), inif)) {
<   if (buf[0] == '#' || buf[0] == '\n')
<    ;
<   else if (sscanf(buf, "S %u %1[HVLR] %u %4s\n", &f, pol, &sr, fec) == 4) {
<    t = alloc_transponder(f);
<    t->type = FE_QPSK;
<    switch(pol[0]) {
<     case 'H':
<     case 'L':
<      t->polarisation = POLARISATION_HORIZONTAL;
<      break;
<     default:
<      t->polarisation = POLARISATION_VERTICAL;;
<      break;
<    }
<    t->param.inversion = spectral_inversion;
<    t->param.u.qpsk.symbol_rate = sr;
<    t->param.u.qpsk.fec_inner = str2fec(fec);
<    info("initial transponder %u %c %u %d\n",
<      t->param.frequency,
<      pol[0], sr,
<      t->param.u.qpsk.fec_inner);
<   }
<   else if (sscanf(buf, "C %u %u %4s %6s\n", &f, &sr, fec, qam) == 4) {
<    t = alloc_transponder(f);
<    t->type = FE_QAM;
<    t->param.inversion = spectral_inversion;
<    t->param.u.qam.symbol_rate = sr;
<    t->param.u.qam.fec_inner = str2fec(fec);
<    t->param.u.qam.modulation = str2qam(qam);
<    info("initial transponder %u %u %d %d\n",
<      t->param.frequency,
<      sr,
<      t->param.u.qam.fec_inner,
<      t->param.u.qam.modulation);
<   }
<   else if (sscanf(buf, "T %u %4s %4s %4s %7s %4s %4s %4s\n",
<      &f, bw, fec, fec2, qam, mode, guard, hier) == 8) {
<    t = alloc_transponder(f);
<    t->type = FE_OFDM;
<    t->param.inversion = spectral_inversion;
<    t->param.u.ofdm.bandwidth = str2bandwidth(bw);
<    t->param.u.ofdm.code_rate_HP = str2fec(fec);
<    if (t->param.u.ofdm.code_rate_HP == FEC_NONE)
<     t->param.u.ofdm.code_rate_HP = FEC_AUTO;
<    t->param.u.ofdm.code_rate_LP = str2fec(fec2);
<    if (t->param.u.ofdm.code_rate_LP == FEC_NONE)
<     t->param.u.ofdm.code_rate_LP = FEC_AUTO;
<    t->param.u.ofdm.constellation = str2qam(qam);
<    t->param.u.ofdm.transmission_mode = str2mode(mode);
<    t->param.u.ofdm.guard_interval = str2guard(guard);
<    t->param.u.ofdm.hierarchy_information = str2hier(hier);
<    info("initial transponder %u %d %d %d %d %d %d %d\n",
<      t->param.frequency,
<      t->param.u.ofdm.bandwidth,
<      t->param.u.ofdm.code_rate_HP,
<      t->param.u.ofdm.code_rate_LP,
<      t->param.u.ofdm.constellation,
<      t->param.u.ofdm.transmission_mode,
<      t->param.u.ofdm.guard_interval,
<      t->param.u.ofdm.hierarchy_information);
<   }
<   else if (sscanf(buf, "A %u %7s\n",
<      &f,qam) == 2) {
<    t = alloc_transponder(f);
<    t->type = FE_ATSC;
<    t->param.u.vsb.modulation = str2qam(qam);
<   } else
<    error("cannot parse'%s'\n", buf);
<  }
<
<  fclose(inif);
1858c1885
< static void scan_network (int frontend_fd, const char *initial)
---
> static void scan_network (int frontend_fd, const char *initial, unsigned int freq, unsigned int srate, char polar, char *fec)
1860c1887
<  if (tune_initial (frontend_fd, initial) < 0) {
---
>  if (tune_initial (frontend_fd, initial, freq, srate, polar, fec) < 0) {
2054c2081
<  "usage: %s [options...] [-c | initial-tuning-data-file]\n"
---
>  "usage: %s [options...] [-c | -F-S[-z-E] | initial-tuning-data-file]\n"
2084c2111,2117
<  " -U Uniquely name unknown services\n";
---
>  " -U Uniquely name unknown services\n"
>  "\n"
>  " Initial tune data:\n"
>  " -F N Frequency for initial tune\n"
>  " -S N Symbol-rate for initial tune\n"
>  " -z <V=default|H|R|L> Polarization for initial tune\n"
>  " -E <NONE|1/2|2/3|3/4|4/5|5/6|6/7|7/8|8/9|AUTO=default> FEC for initial tune\n";
2122a2156,2158
>     unsigned int srate = 0, freq = 0;
>     char polar = 'V';
>     char fec[] = "AUTO";
2132c2168
<  while ((opt = getopt(argc, argv, "5cnpa:f:d:s:o:x:e:t:i:l:vquPA:U")) != -1) {
---
>  while ((opt = getopt(argc, argv, "5cnpa:f:d:s:o:x:e:t:i:l:vquPA:US:F:z:E:")) != -1) {
2207d2242
<
2211a2247,2259
>   case 'S':
>             srate = strtoul(optarg, NULL, 0);
>    break;
>   case 'F':
>             freq = strtoul(optarg, NULL, 0);
>    break;
>   case 'z':
>             polar = optarg[0];
>             break;
>   case 'E':
>             strncpy (fec, optarg, 4);
>             fec[4] = '\0';
>             break;
2220c2268
<  if ((!initial && !current_tp_only) || (initial && current_tp_only) ||
---
>  if ((((!freq || !srate) && !initial) && !current_tp_only) || (((freq && srate) || initial) && current_tp_only) ||
2269c2317
<   scan_network (frontend_fd, initial);
---
>   scan_network (frontend_fd, initial, freq, srate, polar, fec);

_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux