mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Added device number selection to scr.conf
This commit is contained in:
parent
b40cd95dcc
commit
b1f6b586d4
59
diseqc.c
59
diseqc.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: diseqc.c 2.8 2011/09/17 10:41:00 kls Exp $
|
* $Id: diseqc.c 2.9 2011/09/17 14:13:31 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "diseqc.h"
|
#include "diseqc.h"
|
||||||
@ -12,10 +12,30 @@
|
|||||||
#include "sources.h"
|
#include "sources.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
|
static bool ParseDeviceNumbers(const char *s, int &Devices)
|
||||||
|
{
|
||||||
|
if (*s && s[strlen(s) - 1] == ':') {
|
||||||
|
const char *p = s;
|
||||||
|
while (*p && *p != ':') {
|
||||||
|
char *t = NULL;
|
||||||
|
int d = strtol(p, &t, 10);
|
||||||
|
p = t;
|
||||||
|
if (0 < d && d < 31)
|
||||||
|
Devices |= (1 << d - 1);
|
||||||
|
else {
|
||||||
|
esyslog("ERROR: invalid device number %d in '%s'", d, s);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// --- cScr ------------------------------------------------------------------
|
// --- cScr ------------------------------------------------------------------
|
||||||
|
|
||||||
cScr::cScr(void)
|
cScr::cScr(void)
|
||||||
{
|
{
|
||||||
|
devices = 0;
|
||||||
channel = -1;
|
channel = -1;
|
||||||
userBand = 0;
|
userBand = 0;
|
||||||
pin = -1;
|
pin = -1;
|
||||||
@ -24,6 +44,10 @@ cScr::cScr(void)
|
|||||||
|
|
||||||
bool cScr::Parse(const char *s)
|
bool cScr::Parse(const char *s)
|
||||||
{
|
{
|
||||||
|
if (!ParseDeviceNumbers(s, devices))
|
||||||
|
return false;
|
||||||
|
if (devices)
|
||||||
|
return true;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int fields = sscanf(s, "%d %u %d", &channel, &userBand, &pin);
|
int fields = sscanf(s, "%d %u %d", &channel, &userBand, &pin);
|
||||||
if (fields == 2 || fields == 3) {
|
if (fields == 2 || fields == 3) {
|
||||||
@ -40,15 +64,21 @@ bool cScr::Parse(const char *s)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- cScrs -----------------------------------------------------------------
|
// --- cScrs -----------------------------------------------------------------
|
||||||
|
|
||||||
cScrs Scrs;
|
cScrs Scrs;
|
||||||
|
|
||||||
cScr *cScrs::GetUnused(void)
|
cScr *cScrs::GetUnused(int Device)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutex);
|
||||||
|
int Devices = 0;
|
||||||
for (cScr *p = First(); p; p = Next(p)) {
|
for (cScr *p = First(); p; p = Next(p)) {
|
||||||
|
if (p->Devices()) {
|
||||||
|
Devices = p->Devices();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Devices && !(Devices & (1 << Device - 1)))
|
||||||
|
continue;
|
||||||
if (!p->Used()) {
|
if (!p->Used()) {
|
||||||
p->SetUsed(true);
|
p->SetUsed(true);
|
||||||
return p;
|
return p;
|
||||||
@ -78,23 +108,12 @@ cDiseqc::~cDiseqc()
|
|||||||
|
|
||||||
bool cDiseqc::Parse(const char *s)
|
bool cDiseqc::Parse(const char *s)
|
||||||
{
|
{
|
||||||
|
if (!ParseDeviceNumbers(s, devices))
|
||||||
|
return false;
|
||||||
|
if (devices)
|
||||||
|
return true;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
char *sourcebuf = NULL;
|
char *sourcebuf = NULL;
|
||||||
if (*s && s[strlen(s) - 1] == ':') {
|
|
||||||
const char *p = s;
|
|
||||||
while (*p && *p != ':') {
|
|
||||||
char *t = NULL;
|
|
||||||
int d = strtol(p, &t, 10);
|
|
||||||
p = t;
|
|
||||||
if (0 < d && d < 32)
|
|
||||||
devices |= (1 << d - 1);
|
|
||||||
else {
|
|
||||||
esyslog("ERROR: invalid device number %d in '%s'", d, s);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
int fields = sscanf(s, "%a[^ ] %d %c %d %a[^\n]", &sourcebuf, &slof, &polarization, &lof, &commands);
|
int fields = sscanf(s, "%a[^ ] %d %c %d %a[^\n]", &sourcebuf, &slof, &polarization, &lof, &commands);
|
||||||
if (fields == 4)
|
if (fields == 4)
|
||||||
commands = NULL; //XXX Apparently sscanf() doesn't work correctly if the last %a argument results in an empty string
|
commands = NULL; //XXX Apparently sscanf() doesn't work correctly if the last %a argument results in an empty string
|
||||||
@ -264,9 +283,9 @@ const cDiseqc *cDiseqcs::Get(int Device, int Source, int Frequency, char Polariz
|
|||||||
continue;
|
continue;
|
||||||
if (p->Source() == Source && p->Slof() > Frequency && p->Polarization() == toupper(Polarization)) {
|
if (p->Source() == Source && p->Slof() > Frequency && p->Polarization() == toupper(Polarization)) {
|
||||||
if (p->IsScr() && Scr && !*Scr) {
|
if (p->IsScr() && Scr && !*Scr) {
|
||||||
*Scr = Scrs.GetUnused();
|
*Scr = Scrs.GetUnused(Device);
|
||||||
if (*Scr)
|
if (*Scr)
|
||||||
dsyslog("SCR %d assigned to device %d", (*Scr)->Index(), Device);
|
dsyslog("SCR %d assigned to device %d", (*Scr)->Channel(), Device);
|
||||||
else
|
else
|
||||||
esyslog("ERROR: no free SCR entry available for device %d", Device);
|
esyslog("ERROR: no free SCR entry available for device %d", Device);
|
||||||
}
|
}
|
||||||
|
6
diseqc.h
6
diseqc.h
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: diseqc.h 2.4 2011/09/11 13:40:16 kls Exp $
|
* $Id: diseqc.h 2.5 2011/09/17 13:15:17 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __DISEQC_H
|
#ifndef __DISEQC_H
|
||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
class cScr : public cListObject {
|
class cScr : public cListObject {
|
||||||
private:
|
private:
|
||||||
|
int devices;
|
||||||
int channel;
|
int channel;
|
||||||
uint userBand;
|
uint userBand;
|
||||||
int pin;
|
int pin;
|
||||||
@ -22,6 +23,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
cScr(void);
|
cScr(void);
|
||||||
bool Parse(const char *s);
|
bool Parse(const char *s);
|
||||||
|
int Devices(void) const { return devices; }
|
||||||
int Channel(void) const { return channel; }
|
int Channel(void) const { return channel; }
|
||||||
uint UserBand(void) const { return userBand; }
|
uint UserBand(void) const { return userBand; }
|
||||||
int Pin(void) const { return pin; }
|
int Pin(void) const { return pin; }
|
||||||
@ -33,7 +35,7 @@ class cScrs : public cConfig<cScr> {
|
|||||||
private:
|
private:
|
||||||
cMutex mutex;
|
cMutex mutex;
|
||||||
public:
|
public:
|
||||||
cScr *GetUnused(void);
|
cScr *GetUnused(int Device);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern cScrs Scrs;
|
extern cScrs Scrs;
|
||||||
|
4
scr.conf
4
scr.conf
@ -8,6 +8,10 @@
|
|||||||
# frequency: frequency of the SCR channel ("user band")
|
# frequency: frequency of the SCR channel ("user band")
|
||||||
# pin: optional pin of the SCR channel (0-255)
|
# pin: optional pin of the SCR channel (0-255)
|
||||||
#
|
#
|
||||||
|
# A line containing space separated integer numbers, terminated with a ':',
|
||||||
|
# defines that any following lines apply only to the given list
|
||||||
|
# of device numbers.
|
||||||
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
|
|
||||||
# 0 1284
|
# 0 1284
|
||||||
|
15
vdr.5
15
vdr.5
@ -8,7 +8,7 @@
|
|||||||
.\" License as specified in the file COPYING that comes with the
|
.\" License as specified in the file COPYING that comes with the
|
||||||
.\" vdr distribution.
|
.\" vdr distribution.
|
||||||
.\"
|
.\"
|
||||||
.\" $Id: vdr.5 2.24 2011/09/10 14:45:00 kls Exp $
|
.\" $Id: vdr.5 2.25 2011/09/17 13:27:42 kls Exp $
|
||||||
.\"
|
.\"
|
||||||
.TH vdr 5 "10 Feb 2008" "1.6" "Video Disk Recorder Files"
|
.TH vdr 5 "10 Feb 2008" "1.6" "Video Disk Recorder Files"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
@ -512,6 +512,19 @@ Examples:
|
|||||||
6 1980
|
6 1980
|
||||||
.br
|
.br
|
||||||
7 2096
|
7 2096
|
||||||
|
|
||||||
|
By default it is assumed that the SCR configurations apply to all devices, and
|
||||||
|
each device will pick one. If you have several SCR sat cables connected to one
|
||||||
|
VDR machine, or if you want to explicitly assign the SCR channels to your devices,
|
||||||
|
lines of the form
|
||||||
|
|
||||||
|
\fB1 2 4:\fR
|
||||||
|
|
||||||
|
may be inserted in the \fIscr.conf\fR file, defining the devices that are allowed
|
||||||
|
to use the SCR channels thereafter. In this case, only the devices
|
||||||
|
1, 2 and 4 would be allowed to use the SCR channels following this line and up
|
||||||
|
to the next such line, or the end of the file. If a device is listed more than
|
||||||
|
once, only its first appearance counts.
|
||||||
.SS REMOTE CONTROL KEYS
|
.SS REMOTE CONTROL KEYS
|
||||||
The file \fIremote.conf\fR contains the key assignments for all remote control
|
The file \fIremote.conf\fR contains the key assignments for all remote control
|
||||||
units. Each line consists of one key assignment in the following format:
|
units. Each line consists of one key assignment in the following format:
|
||||||
|
Loading…
Reference in New Issue
Block a user