From 8b43cdc634748d7426e83a89768a7af9e310362e Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Tue, 17 Mar 2015 21:25:15 +0200 Subject: [PATCH] Added initial support for detaching and attaching SAT>IP servers. --- config.c | 1 + config.h | 3 +++ device.c | 4 ++++ satip.c | 21 ++++++++++++++++++++- setup.c | 20 ++++++++++++-------- setup.h | 1 + 6 files changed, 41 insertions(+), 9 deletions(-) diff --git a/config.c b/config.c index a0688cc..050453c 100644 --- a/config.c +++ b/config.c @@ -17,6 +17,7 @@ cSatipConfig::cSatipConfig(void) ciExtensionM(0), eitScanM(1), useBytesM(1), + detachedModeM(false), disableServerQuirksM(false), useSingleModelServersM(false) { diff --git a/config.h b/config.h index 5b11614..b7745cf 100644 --- a/config.h +++ b/config.h @@ -19,6 +19,7 @@ private: unsigned int ciExtensionM; unsigned int eitScanM; unsigned int useBytesM; + bool detachedModeM; bool disableServerQuirksM; bool useSingleModelServersM; int cicamsM[MAX_CICAM_COUNT]; @@ -66,6 +67,7 @@ public: int GetCICAM(unsigned int indexP) const; unsigned int GetEITScan(void) const { return eitScanM; } unsigned int GetUseBytes(void) const { return useBytesM; } + bool GetDetachedMode(void) const { return detachedModeM; } bool GetDisableServerQuirks(void) const { return disableServerQuirksM; } bool GetUseSingleModelServers(void) const { return useSingleModelServersM; } unsigned int GetDisabledSourcesCount(void) const; @@ -79,6 +81,7 @@ public: void SetCICAM(unsigned int indexP, int cicamP); void SetEITScan(unsigned int onOffP) { eitScanM = onOffP; } void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; } + void SetDetachedMode(bool onOffP) { detachedModeM = onOffP; } void SetDisableServerQuirks(bool onOffP) { disableServerQuirksM = onOffP; } void SetUseSingleModelServers(bool onOffP) { useSingleModelServersM = onOffP; } void SetDisabledSources(unsigned int indexP, int sourceP); diff --git a/device.c b/device.c index 6eb25cf..1535c3f 100644 --- a/device.c +++ b/device.c @@ -219,6 +219,8 @@ bool cSatipDevice::ProvidesSource(int sourceP) const { cSource *s = Sources.Get(sourceP); debug9("%s (%c) desc='%s' [device %u]", __PRETTY_FUNCTION__, cSource::ToChar(sourceP), s ? s->Description() : "", deviceIndexM); + if (SatipConfig.GetDetachedMode()) + return false; // source descriptions starting with '0' are disabled if (s && s->Description() && (*(s->Description()) == '0')) return false; @@ -501,6 +503,8 @@ void cSatipDevice::SkipData(int countP) bool cSatipDevice::GetTSPacket(uchar *&dataP) { debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM); + if (SatipConfig.GetDetachedMode()) + return false; if (tsBufferM) { if (cCamSlot *cs = CamSlot()) { if (cs->WantsTsData()) { diff --git a/satip.c b/satip.c index 11ea6cf..29836f1 100644 --- a/satip.c +++ b/satip.c @@ -85,6 +85,7 @@ const char *cPluginSatip::CommandLineHelp(void) " -t , --trace= set the tracing mode\n" " -s ||, --server=||;||\n" " define hard-coded SAT>IP server(s)\n" + " -D, --detach set the detached mode on\n" " -S, --single set the single model server mode on\n" " -n, --noquirks disable all the server quirks\n"; } @@ -97,6 +98,7 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[]) { "devices", required_argument, NULL, 'd' }, { "trace", required_argument, NULL, 't' }, { "server", required_argument, NULL, 's' }, + { "detach", no_argument, NULL, 'D' }, { "single", no_argument, NULL, 'S' }, { "noquirks", no_argument, NULL, 'n' }, { NULL, no_argument, NULL, 0 } @@ -104,7 +106,7 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[]) cString server; int c; - while ((c = getopt_long(argc, argv, "d:t:s:Sn", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "d:t:s:DSn", long_options, NULL)) != -1) { switch (c) { case 'd': deviceCountM = strtol(optarg, NULL, 0); @@ -115,6 +117,9 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[]) case 's': server = optarg; break; + case 'D': + SatipConfig.SetDetachedMode(true); + break; case 'S': SatipConfig.SetUseSingleModelServers(true); break; @@ -368,6 +373,10 @@ const char **cPluginSatip::SVDRPHelpPages(void) " Shows SAT>IP device count.\n", "OPER [ off | low | normal | high ]\n" " Gets and(or sets operating mode of SAT>IP devices.\n", + "ATTA\n" + " Attach active SAT>IP servers.\n", + "DETA\n" + " Detachs active SAT>IP servers.\n", "TRAC [ ]\n" " Gets and/or sets used tracing mode.\n", NULL @@ -465,6 +474,16 @@ cString cPluginSatip::SVDRPCommand(const char *commandP, const char *optionP, in } return cString::sprintf("SATIP operating mode: %s\n", *mode); } + else if (strcasecmp(commandP, "ATTA") == 0) { + SatipConfig.SetDetachedMode(false); + info("SATIP servers attached"); + return cString("SATIP servers attached"); + } + else if (strcasecmp(commandP, "DETA") == 0) { + SatipConfig.SetDetachedMode(true); + info("SATIP servers detached"); + return cString("SATIP servers detached"); + } else if (strcasecmp(commandP, "TRAC") == 0) { if (optionP && *optionP) SatipConfig.SetTraceMode(strtol(optionP, NULL, 0)); diff --git a/setup.c b/setup.c index 1319eb8..e3eeeab 100644 --- a/setup.c +++ b/setup.c @@ -330,7 +330,8 @@ eOSState cSatipMenuInfo::ProcessKey(eKeys keyP) // --- cSatipPluginSetup ------------------------------------------------------ cSatipPluginSetup::cSatipPluginSetup() -: deviceCountM(0), +: detachedModeM(SatipConfig.GetDetachedMode()), + deviceCountM(0), operatingModeM(SatipConfig.GetOperatingMode()), ciExtensionM(SatipConfig.GetCIExtension()), eitScanM(SatipConfig.GetEITScan()), @@ -402,12 +403,15 @@ void cSatipPluginSetup::Setup(void) Add(new cOsdItem(tr("Active SAT>IP servers:"), osUnknown, false)); helpM.Append(""); - cSatipServers *servers = cSatipDiscover::GetInstance()->GetServers(); - deviceCountM = servers->Count(); - for (cSatipServer *s = servers->First(); s; s = servers->Next(s)) { - Add(new cSatipServerItem(s)); - helpM.Append(""); - } + detachedModeM = SatipConfig.GetDetachedMode(); + if (!detachedModeM) { + cSatipServers *servers = cSatipDiscover::GetInstance()->GetServers(); + deviceCountM = servers->Count(); + for (cSatipServer *s = servers->First(); s; s = servers->Next(s)) { + Add(new cSatipServerItem(s)); + helpM.Append(""); + } + } SetCurrent(Get(current)); Display(); @@ -480,7 +484,7 @@ eOSState cSatipPluginSetup::ProcessKey(eKeys keyP) if ((keyP == kNone) && (cSatipDiscover::GetInstance()->GetServers()->Count() != deviceCountM)) Setup(); - if ((keyP != kNone) && ((numDisabledSourcesM != oldNumDisabledSources) || (numDisabledFiltersM != oldNumDisabledFilters) || (operatingModeM != oldOperatingMode) || (ciExtensionM != oldCiExtension))) { + if ((keyP != kNone) && ((numDisabledSourcesM != oldNumDisabledSources) || (numDisabledFiltersM != oldNumDisabledFilters) || (operatingModeM != oldOperatingMode) || (ciExtensionM != oldCiExtension) || (detachedModeM != SatipConfig.GetDetachedMode()))) { while ((numDisabledSourcesM < oldNumDisabledSources) && (oldNumDisabledSources > 0)) disabledSourcesM[--oldNumDisabledSources] = cSource::stNone; while ((numDisabledFiltersM < oldNumDisabledFilters) && (oldNumDisabledFilters > 0)) diff --git a/setup.h b/setup.h index f2489da..d8dcd66 100644 --- a/setup.h +++ b/setup.h @@ -15,6 +15,7 @@ class cSatipPluginSetup : public cMenuSetupPage { private: + bool detachedModeM; int deviceCountM; int operatingModeM; const char *operatingModeTextsM[cSatipConfig::eOperatingModeCount];