17 if (*s && s[strlen(s) - 1] ==
':') {
19 while (*p && *p !=
':') {
21 int d = strtol(p, &t, 10);
24 Devices |= (1 << d - 1);
26 esyslog(
"ERROR: invalid device number %d in '%s'", d, s);
53 if (fields == 2 || fields == 3) {
56 if (fields == 3 && (pin < 0 || pin > 255)) {
77 Devices = p->Devices();
80 if (Devices && !(Devices & (1 << Device - 1)))
116 char *sourcebuf = NULL;
120 if (4 <= fields && fields <= 5) {
126 const char *CurrentAction = NULL;
127 while (
Execute(&CurrentAction, NULL, NULL, NULL, NULL) !=
daNone)
130 result = !
commands || !*CurrentAction;
136 esyslog(
"ERROR: unknown source '%s'", sourcebuf);
144 uint t = SatFrequency == 0 ? 0 : (SatFrequency + Scr->
UserBand() + 2) / 4 - 350;
145 if (t < 1024 && Scr->Channel() >= 0 && Scr->
Channel() < 8) {
146 Codes[3] = t >> 8 | (t == 0 ? 0 :
scrBank << 2) | Scr->
Channel() << 5;
149 return (t + 350) * 4 - SatFrequency;
156 if (Scr->
Pin() >= 0 && Scr->
Pin() <= 255) {
158 Codes[5] = Scr->
Pin();
171 int n = strtol(s, &p, 10);
172 if (!errno && p != s && n >= 0) {
177 esyslog(
"ERROR: invalid value for wait time in '%s'", s - 1);
185 int n = strtol(s, &p, 10);
186 if (!errno && p != s && n >= 0 && n < 8) {
191 esyslog(
"ERROR: more than one scr bank in '%s'", s - 1);
195 esyslog(
"ERROR: more than one scr bank in '%s'", s - 1);
201 const char *e = strchr(s,
']');
209 int n = strtol(t, &p, 16);
210 if (!errno && p != t && 0 <= n && n <= 255) {
212 if (NumCodes < *MaxCodes)
213 Codes[NumCodes++] =
uchar(n);
215 esyslog(
"ERROR: too many codes in code sequence '%s'", s - 1);
222 esyslog(
"ERROR: invalid code at '%s'", t);
227 esyslog(
"ERROR: too many codes in code sequence '%s'", s - 1);
232 *MaxCodes = NumCodes;
236 esyslog(
"ERROR: missing closing ']' in code sequence '%s'", s - 1);
244 while (*CurrentAction && **CurrentAction) {
245 switch (*(*CurrentAction)++) {
253 case 'W': *CurrentAction =
Wait(*CurrentAction);
break;
254 case 'S': *CurrentAction =
GetScrBank(*CurrentAction);
break;
255 case '[': *CurrentAction =
GetCodes(*CurrentAction, Codes, MaxCodes);
256 if (*CurrentAction) {
257 if (Scr && Frequency) {
282 if (Devices && !(Devices & (1 << Device - 1)))
284 if (p->Source() == Source && p->Slof() > Frequency && p->Polarization() == toupper(Polarization)) {
285 if (p->IsScr() && Scr && !*Scr) {
288 dsyslog(
"SCR %d assigned to device %d", (*Scr)->Channel(), Device);
290 esyslog(
"ERROR: no free SCR entry available for device %d", Device);