]> git.gir.st - ttxd.git/blob - src/szap-s2/lnb.c
update to dvb-t2 (new hardware, software)
[ttxd.git] / src / szap-s2 / lnb.c
1 #include <stdlib.h>
2 #include <string.h>
3 #include <ctype.h>
4 #include "lnb.h"
5
6 static char *univ_desc[] = {
7 "Europe",
8 "10800 to 11800 MHz and 11600 to 12700 Mhz",
9 "Dual LO, loband 9750, hiband 10600 MHz",
10 (char *)NULL };
11
12 static char *dbs_desc[] = {
13 "Expressvu, North America",
14 "12200 to 12700 MHz",
15 "Single LO, 11250 MHz",
16 (char *)NULL };
17
18 static char *standard_desc[] = {
19 "10945 to 11450 Mhz",
20 "Single LO, 10000 Mhz",
21 (char *)NULL };
22
23 static char *enhan_desc[] = {
24 "Astra",
25 "10700 to 11700 MHz",
26 "Single LO, 9750 MHz",
27 (char *)NULL };
28
29 static char *cband_desc[] = {
30 "Big Dish",
31 "3700 to 4200 MHz",
32 "Single LO, 5150 Mhz",
33 (char *)NULL };
34
35 static struct lnb_types_st lnbs[] = {
36 {"UNIVERSAL", univ_desc, 9750, 10600, 11700 },
37 {"DBS", dbs_desc, 11250, 0, 0 },
38 {"STANDARD", standard_desc, 10000, 0, 0 },
39 {"ENHANCED", enhan_desc, 9750, 0, 0 },
40 {"C-BAND", cband_desc, 5150, 0, 0 }
41 };
42
43 /* Enumerate through standard types of LNB's until NULL returned.
44 * Increment curno each time
45 */
46
47 struct lnb_types_st *
48 lnb_enum(int curno)
49 {
50 if (curno >= (int) (sizeof(lnbs) / sizeof(lnbs[0])))
51 return (struct lnb_types_st *)NULL;
52 return &lnbs[curno];
53 }
54
55 /* Decode an lnb type, for example given on a command line
56 * If alpha and standard type, e.g. "Universal" then match that
57 * otherwise low[,high[,switch]]
58 */
59
60 int
61 lnb_decode(char *str, struct lnb_types_st *lnbp)
62 {
63 int i;
64 char *cp, *np;
65
66 memset(lnbp, 0, sizeof(*lnbp));
67 cp = str;
68 while(*cp && isspace(*cp))
69 cp++;
70 if (isalpha(*cp)) {
71 for (i = 0; i < (int)(sizeof(lnbs) / sizeof(lnbs[0])); i++) {
72 if (!strcasecmp(lnbs[i].name, cp)) {
73 *lnbp = lnbs[i];
74 return 1;
75 }
76 }
77 return -1;
78 }
79 if (*cp == '\0' || !isdigit(*cp))
80 return -1;
81 lnbp->low_val = strtoul(cp, &np, 0);
82 if (lnbp->low_val == 0)
83 return -1;
84 cp = np;
85 while(*cp && (isspace(*cp) || *cp == ','))
86 cp++;
87 if (*cp == '\0')
88 return 1;
89 if (!isdigit(*cp))
90 return -1;
91 lnbp->high_val = strtoul(cp, &np, 0);
92 cp = np;
93 while(*cp && (isspace(*cp) || *cp == ','))
94 cp++;
95 if (*cp == '\0')
96 return 1;
97 if (!isdigit(*cp))
98 return -1;
99 lnbp->switch_val = strtoul(cp, NULL, 0);
100 return 1;
101 }
Imprint / Impressum