feature request easy diseqc setup and channelscan for vdr

Message ID 4B6D9196.2000306@tvdr.de
State New
Headers

Commit Message

Klaus Schmidinger Feb. 6, 2010, 3:58 p.m. UTC
  On 06.02.2010 13:38, Klaus Schmidinger wrote:
> On 06.02.2010 13:26, Ian Bates wrote:
>> On 6 Feb 2010, at 11:57, Klaus Schmidinger wrote:
>>
>>> On 02.02.2010 07:35, Ian Bates wrote:
>>>> On 1 Feb 2010, at 22:24, abbe normal wrote:
>>>>> On 2/1/10, VDR User <user.vdr@gmail.com> wrote:
>>>>>> On Mon, Feb 1, 2010 at 7:12 AM, Halim Sahin <halim.sahin@t-online.de> wrote:
>>>>>>> Hi List and Klaus,
>>>>>>>
>>>>>>> It would be really nice if vdr could support diseqc setup directly in
>>>>>>> vdr.
>>>>>>>
>>>>>>> I don't know if this can be done by a plugin but the current solution is
>>>>>>> difficult for endusers.
>>>>>>> Setting a diseqc.conf needs some knowledge in diseqc and it's commands.
>>>>>>> A simple interface for creating a diseqc.conf can improove the
>>>>>>> usability of vdr!
>>>>>> Personally I think adding support for multiple diseqc switches is a
>>>>>> more important feature as I've noticed several users asking how to do
>>>>>> this in VDR -- which it unfortunately doesn't support.  I think this
>>>>>> is actually one of the reasons some guys fumble around trying to
>>>>>> cascade their diseqc switches.  However, not all switches can be
>>>>>> cascaded and so they're left stuck.  Can't cascade, and no support for
>>>>>> multiple switches.
>>>>>>
>>>>>>
>>>>> hey guys
>>>>>
>>>>> i agree multi cards should be able to use mutli diseqc configs... or
>>>>> at least be able to assign them to different switches that could be
>>>>> used... would be nice to add more dishes and lnbs to my setup... would
>>>>> like to do c and ku band dvb as well as have at least 2 to 3 fixed
>>>>> dishes with lnbs on them now im limited to 4 max or use a very costly
>>>>> switch...
>>>>>
>>>>> abby
>>>> Dear all,
>>>>
>>>> I have a diseqc-patch I that hacked together a couple of years ago relating to multi-cards/multi-switches that has served my purpose well.  It may not be the best way, it may even be the wrong way.  I will drag it out of the VDR box for all to see but that will not be for a couple of days.
>>>>
>>>> MOTIVATION
>>>>
>>>> I have three LNBs (28.2/5, 19.2, 13.0) and two cards, each card attached to a 4-way diseqc switch.  Despite the switches being the same model and bought at the same time each one responds to a different set of diseqc commands to change LNB.  IIRC one seemed to behave as a cascade of 2-way switches, the other responded to the more usual commands for a 4-way switch.
>>>>
>>>> DESCRIPTION
>>>>
>>>> Enter my hack.  It allows diseqc commands to be defined on a per-card basis (numbered 1, 2, ...).  How you determine which number corresponds to which card is left as an exercise for the reader (hint: the margin may not be big enough).  These defines are placed in 'diseqc-multi.conf' and start with the card number but are otherwise the same format as those found in 'diseqc.conf'.
>>>>
>>>> CONFIGURATION
>>>>
>>>> Configuration options within VDR are:
>>>>
>>>> - use only the diseqc.conf defines, 
>>>> - use only the diseqc-multi.conf, 
>>>> - use the disqc-multi.conf if a card definition appears otherwise use the diseqc.conf defines.
>>> I don't like the introduction of a separate diseqc-multi.conf file,
>>> and also those additional setup options in VDR.
>>>
>>> What about simply extending the existing diseqc.conf file to
>>> accept device numbers, as in:
>>>
>>> 1 2 4:
>>>
>>> S19.2E  11700 V  9750  t v W15 [E0 10 38 F0] W15 A W15 t
>>> S19.2E  99999 V 10600  t v W15 [E0 10 38 F1] W15 A W15 T
>>> S19.2E  11700 H  9750  t V W15 [E0 10 38 F2] W15 A W15 t
>>> S19.2E  99999 H 10600  t V W15 [E0 10 38 F3] W15 A W15 T
>>>
>>> 3 5:
>>>
>>> S13.0E  11700 V  9750  t v W15 [E0 10 38 F4] W15 B W15 t
>>> S13.0E  99999 V 10600  t v W15 [E0 10 38 F5] W15 B W15 T
>>> S13.0E  11700 H  9750  t V W15 [E0 10 38 F6] W15 B W15 t
>>> S13.0E  99999 H 10600  t V W15 [E0 10 38 F7] W15 B W15 T
>>>
>>>
>>> This could mean that devices 1, 2 and 4 can receive S19.2E,
>>> while devices 3 and 5 can receive S13.0E.
>>>
>>> If no device numbers (followed by a ':') are given, a setup
>>> where every device can receive every satellite is assumed.
>>>
>>> Once a line with device numbers (followed by a ':') appears,
>>> these apply to all following diseqc lines, until the next
>>> line with device numbers is seen.
>>> If a diseqc line is parsed without a previous device line,
>>> that diseqc line applies to all devices.
>>>
>>> Klaus
>>
>> Dear Klaus, all,
>>
>> That sounds good.  Using this proposal I would configure my system with the following diseqc.conf:
>>
>> # diseqc.conf
>>
>> S28.2E a1...
>> S28.2E a2...
>> S28.2E a3...
>> S28.2E a4...
>>
>> S19.2E b1...
>> S19.2E b2...
>> S19.2E b3...
>> S19.2E b4...
>>
>> S13.0E c1...
>> S13.0E c2...
>> S13.0E c3...
>> S13.0E c4...
>>
>> 2:
>>
>> S28.2E A1...
>> S28.2E A2...
>> S28.2E A3...
>> S28.2E A4...
>>
>> S19.2E B1...
>> S19.2E B2...
>> S19.2E B3...
>> S19.2E B4...
>>
>> S13.0E B1...
>> S13.0E B2...
>> S13.0E B3...
>> S13.0E B4...
>>
>> # EOF
>>
>> where [a-cA-C][1-4]... are diseqc command sequences.
>>
>> If I understand correctly, with Klaus' proposal my 'normal' switch (card 1) would use the [a-c][1-4]... commands, and my problem switch (attached to card 2) would use the [A-C][1-4]... commands.  Any additional cards would also use the [a-c][1-4]... commands.
> 
> You would have to put
> 
> 1:
> 
> at the beginning of that file, because otherwise everything before the
> 
> 2:
> 
> would be applicable to *all* devices, including #2. The first entry that fits
> will be used.
> 
>> Unless I have understood incorrectly this gets my vote, if someone implements!
> 
> Don't worry, I'll do that.

Please give the attached patch a try.

Klaus
  

Comments

Klaus Schmidinger Feb. 7, 2010, 1:23 p.m. UTC | #1
On 06.02.2010 16:58, Klaus Schmidinger wrote:
> ...
> Please give the attached patch a try.

Correction: it needs to be "CardIndex() + 1" instead of DeviceNumber():

  dvbTuner = new cDvbTuner(CardIndex() + 1, fd_frontend, adapter, frontend, frontendType);

  if (!Setup.DiSEqC || Diseqcs.Get(CardIndex() + 1, Channel->Source(), Channel->Frequency(), Channel->Polarization()))

Klaus
  

Patch

--- ./diseqc.c	2009/12/05 15:57:02	2.1
+++ ./diseqc.c	2010/02/06 15:43:31
@@ -16,6 +16,11 @@ 
 
 cDiseqc::cDiseqc(void)
 {
+  devices = 0;
+  source = 0;
+  slof = 0;
+  polarization = 0;
+  lof = 0;
   commands = NULL;
   parsing = false;
   numCodes = 0;
@@ -30,6 +35,21 @@ 
 {
   bool result = false;
   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);
   if (fields == 4)
      commands = NULL; //XXX Apparently sscanf() doesn't work correctly if the last %a argument results in an empty string
@@ -126,9 +146,16 @@ 
 
 cDiseqcs Diseqcs;
 
-cDiseqc *cDiseqcs::Get(int Source, int Frequency, char Polarization)
+cDiseqc *cDiseqcs::Get(int Device, int Source, int Frequency, char Polarization)
 {
+  int Devices = 0;
   for (cDiseqc *p = First(); p; p = Next(p)) {
+      if (p->Devices()) {
+         Devices = p->Devices();
+         continue;
+         }
+      if (Devices && !(Devices & (1 << Device - 1)))
+         continue;
       if (p->Source() == Source && p->Slof() > Frequency && p->Polarization() == toupper(Polarization))
         return p;
       }
--- ./diseqc.conf	2006/03/31 14:05:52	2.0
+++ ./diseqc.conf	2010/02/06 15:54:04
@@ -23,6 +23,10 @@ 
 #
 # The 'command...' part is optional.
 #
+# A line containing space separated integer numbers, terminated with a ':',
+# defines that any following DiSEqC sequences apply only to the given list
+# of device numbers.
+#
 # Examples:
 
 # Full DiSEqC sequence:
--- ./diseqc.h	2002/12/07 13:54:02	2.0
+++ ./diseqc.h	2010/02/06 15:14:42
@@ -26,6 +26,7 @@ 
     };
   enum { MaxDiseqcCodes = 6 };
 private:
+  int devices;
   int source;
   int slof;
   char polarization;
@@ -48,6 +49,7 @@ 
       // it. Call Execute() repeatedly (always providing the same CurrentAction pointer)
       // until it returns daNone. After a successful execution of all commands
       // *CurrentAction points to the value 0x00.
+  int Devices(void) const { return devices; }
   int Source(void) const { return source; }
   int Slof(void) const { return slof; }
   char Polarization(void) const { return polarization; }
@@ -58,7 +60,7 @@ 
 
 class cDiseqcs : public cConfig<cDiseqc> {
 public:
-  cDiseqc *Get(int Source, int Frequency, char Polarization);
+  cDiseqc *Get(int Device, int Source, int Frequency, char Polarization);
   };
 
 extern cDiseqcs Diseqcs;
--- ./dvbdevice.c	2010/02/06 14:38:44	2.26
+++ ./dvbdevice.c	2010/02/06 15:34:14
@@ -30,6 +30,7 @@ 
 class cDvbTuner : public cThread {
 private:
   enum eTunerStatus { tsIdle, tsSet, tsTuned, tsLocked };
+  int device;
   int fd_frontend;
   int adapter, frontend;
   int tuneTimeout;
@@ -46,7 +47,7 @@ 
   bool SetFrontend(void);
   virtual void Action(void);
 public:
-  cDvbTuner(int Fd_Frontend, int Adapter, int Frontend, fe_delivery_system FrontendType);
+  cDvbTuner(int Device, int Fd_Frontend, int Adapter, int Frontend, fe_delivery_system FrontendType);
   virtual ~cDvbTuner();
   const cChannel *GetTransponder(void) const { return &channel; }
   bool IsTunedTo(const cChannel *Channel) const;
@@ -54,8 +55,9 @@ 
   bool Locked(int TimeoutMs = 0);
   };
 
-cDvbTuner::cDvbTuner(int Fd_Frontend, int Adapter, int Frontend, fe_delivery_system FrontendType)
+cDvbTuner::cDvbTuner(int Device, int Fd_Frontend, int Adapter, int Frontend, fe_delivery_system FrontendType)
 {
+  device = Device;
   fd_frontend = Fd_Frontend;
   adapter = Adapter;
   frontend = Frontend;
@@ -175,7 +177,7 @@ 
   if (frontendType == SYS_DVBS || frontendType == SYS_DVBS2) {
      unsigned int frequency = channel.Frequency();
      if (Setup.DiSEqC) {
-        cDiseqc *diseqc = Diseqcs.Get(channel.Source(), channel.Frequency(), channel.Polarization());
+        cDiseqc *diseqc = Diseqcs.Get(device, channel.Source(), channel.Frequency(), channel.Polarization());
         if (diseqc) {
            if (diseqc->Commands() && (!diseqcCommands || strcmp(diseqcCommands, diseqc->Commands()) != 0)) {
               cDiseqc::eDiseqcActions da;
@@ -420,7 +422,7 @@ 
         if (frontendType == SYS_DVBS2)
            numProvidedSystems++;
         isyslog("frontend %d/%d provides %s (\"%s\")", adapter, frontend, DeliverySystems[frontendType], frontendInfo.name);
-        dvbTuner = new cDvbTuner(fd_frontend, adapter, frontend, frontendType);
+        dvbTuner = new cDvbTuner(DeviceNumber(), fd_frontend, adapter, frontend, frontendType);
         }
      }
   else
@@ -612,7 +614,7 @@ 
      return DeviceHooksProvidesTransponder(Channel); // source is sufficient for non sat
   if (frontendType == SYS_DVBS && Channel->System() == SYS_DVBS2)
      return false; // requires modulation system which frontend doesn't provide
-  if (!Setup.DiSEqC || Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization()))
+  if (!Setup.DiSEqC || Diseqcs.Get(DeviceNumber(), Channel->Source(), Channel->Frequency(), Channel->Polarization()))
      return DeviceHooksProvidesTransponder(Channel);
   return false;
 }
--- ./vdr.5	2010/01/31 12:59:50	2.13
+++ ./vdr.5	2010/02/06 15:52:38
@@ -452,6 +452,15 @@ 
 There can be any number of actions in a line, including none at all - in which case
 the entry would be used only to set the LOF to use for the given frequency range
 and polarization.
+
+By default it is assumed that every DVB-S device can receive every satellite.
+If this is not the case in a particular setup, lines of the form
+
+\fB1 2 4:\fR
+
+may be inserted in the \fIdiseqc.conf\fR file, defining the devices that are able
+to receive the satellites following thereafter. In this case, only the devices
+1, 2 and 4 would be able to receive any satellites following this line.
 .SS REMOTE CONTROL KEYS
 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: