From 28cd8c6d77e5f1365be8746201e95c0d7162d9c0 Mon Sep 17 00:00:00 2001 From: horchi Date: Mon, 29 Jan 2018 19:57:05 +0100 Subject: Improved recover handling --- HISTORY | 10 ---------- HISTORY.h | 34 +++++++++++++++++++++++++++++++ Makefile.since-1.7.35 | 43 ++++++++++++++++++++++++++++++++++++++++ seduatmo.c | 55 ++++++++++++++++++++++++++------------------------- seduthread.c | 15 ++++++++++++++ 5 files changed, 120 insertions(+), 37 deletions(-) delete mode 100644 HISTORY create mode 100644 HISTORY.h diff --git a/HISTORY b/HISTORY deleted file mode 100644 index a83b5ef..0000000 --- a/HISTORY +++ /dev/null @@ -1,10 +0,0 @@ -VDR Plugin 'seduatmo' Revision History --------------------------------------- - -2015-10-11: Version 0.0.3 - Fixed menu handling - -2012-11-26: Version 0.0.2 - -2012-11-07: Version 0.0.1 - - Initial revision. diff --git a/HISTORY.h b/HISTORY.h new file mode 100644 index 0000000..738e4ca --- /dev/null +++ b/HISTORY.h @@ -0,0 +1,34 @@ +/* + * ---------------------------------------------- + * seduatmo Plugin - Revision History + * ---------------------------------------------- + * + * (c) 2012-2018 Jörg Wendel + * + */ + +#define _VERSION "0.0.4" +#define VERSION_DATE "29.01.2018" + +#ifdef GIT_REV +# define VERSION _VERSION "-GIT" GIT_REV +#else +# define VERSION _VERSION +#endif + +/* + * ------------------------------------ + +2018-02-29: Version 0.0.4 + Improved recover handling + +2015-10-11: Version 0.0.3 + Fixed menu handling + +2012-11-26: Version 0.0.2 + +2012-11-07: Version 0.0.1 + - Initial revision. + + * ------------------------------------ + */ diff --git a/Makefile.since-1.7.35 b/Makefile.since-1.7.35 index 49fe38d..b025e5e 100644 --- a/Makefile.since-1.7.35 +++ b/Makefile.since-1.7.35 @@ -8,6 +8,12 @@ PLUGIN = seduatmo VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g') +LASTHIST = $(shell grep '^20[0-3][0-9]' $(HISTFILE) | head -1) +LASTCOMMENT = $(subst |,\n,$(shell sed -n '/$(LASTHIST)/,/^ *$$/p' $(HISTFILE) | tr '\n' '|')) +LASTTAG = $(shell git describe --tags --abbrev=0) +BRANCH = $(shell git rev-parse --abbrev-ref HEAD) +GIT_REV = $(shell git describe --always 2>/dev/null) + ### The directory environment: # Use package data if installed...otherwise assume we're under the VDR source directory: @@ -121,3 +127,40 @@ dist: $(I18Npo) clean clean: @-rm -f $(PODIR)/*.mo $(PODIR)/*.pot @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ + +cppchk: + cppcheck --language=c++ --template="{file}:{line}:{severity}:{message}" --quiet --force *.c *.h + +# ------------------------------------------------------ +# Git / Versioning / Tagging +# ------------------------------------------------------ + +vcheck: + git fetch + if test "$(LASTTAG)" = "$(VERSION)"; then \ + echo "Warning: tag/version '$(VERSION)' already exists, update HISTORY first. Aborting!"; \ + exit 1; \ + fi + +push: vcheck + echo "tagging git with $(VERSION)" + git push + git tag $(VERSION) + git push --tags + +commit: vcheck + git commit -m "$(LASTCOMMENT)" -a + +git: commit push + +showv: + @echo "Git ($(BRANCH)):\\n Version: $(LASTTAG) (tag)" + @echo "Local:" + @echo " Version: $(VERSION)" + @echo " Change:" + @echo -n " $(LASTCOMMENT)" + +update: + git pull + @make clean install + restart vdr diff --git a/seduatmo.c b/seduatmo.c index 2764603..770f787 100644 --- a/seduatmo.c +++ b/seduatmo.c @@ -8,15 +8,16 @@ #include +#include "HISTORY.h" + #include "seduthread.h" #include "config.h" #include "ledsconf.h" //*************************************************************************** -// +// //*************************************************************************** -static const char *VERSION = "0.0.3"; static const char *DESCRIPTION = "sedu ambi light control with data from softhddevice"; static const char *MAINMENUENTRY = "Seduatmo"; @@ -48,10 +49,10 @@ class cSeduSetup : public cMenuSetupPage, public cSeduService // Plugin //*************************************************************************** -class cPluginSeduatmo : public cPlugin +class cPluginSeduatmo : public cPlugin { public: - + cPluginSeduatmo(void); virtual ~cPluginSeduatmo(); virtual const char* Version(void) { return VERSION; } @@ -100,7 +101,7 @@ class cSeduPluginMenu : public cMenuSetupPage cSeduPluginMenu(const char* title, cPluginSeduatmo* aPlugin); virtual ~cSeduPluginMenu() { }; - + virtual eOSState ProcessKey(eKeys key); protected: @@ -115,11 +116,11 @@ cSeduPluginMenu::cSeduPluginMenu(const char* title, cPluginSeduatmo* aPlugin) SetTitle(title ? title : ""); plugin = aPlugin; effectSpeed = cfg.effectSpeed; - + Clear(); - cOsdMenu::Add(new cMenuEditStraItem(tr("View Mode"), - (int*)&cfg.viewMode, + cOsdMenu::Add(new cMenuEditStraItem(tr("View Mode"), + (int*)&cfg.viewMode, (int)cSeduService::vmCount, cSeduService::viewModes)); @@ -141,7 +142,7 @@ cSeduPluginMenu::cSeduPluginMenu(const char* title, cPluginSeduatmo* aPlugin) eOSState cSeduPluginMenu::ProcessKey(eKeys key) { eOSState state = cOsdMenu::ProcessKey(key); - + if (key == kLeft || key == kRight) { if (cfg.viewMode == cSeduService::vmDetached && plugin->isRunning()) @@ -164,7 +165,7 @@ eOSState cSeduPluginMenu::ProcessKey(eKeys key) } void cSeduPluginMenu::Store() -{ +{ plugin->SetupStore("FixedColorRed", cfg.fixedR); plugin->SetupStore("FixedColorGreen", cfg.fixedG); plugin->SetupStore("FixedColorBlue", cfg.fixedB); @@ -175,7 +176,7 @@ void cSeduPluginMenu::Store() } //*************************************************************************** -// Plugin +// Plugin //*************************************************************************** cPluginSeduatmo::cPluginSeduatmo(void) @@ -310,56 +311,56 @@ bool cPluginSeduatmo::Service(const char* Id, void* Data) cString cPluginSeduatmo::SVDRPCommand(const char* Command, const char* Option, int &ReplyCode) { - if (!strcasecmp(Command, "MODE")) + if (!strcasecmp(Command, "MODE")) { - if (Option && strcasecmp(Option, "atmo") == 0) + if (Option && strcasecmp(Option, "atmo") == 0) { cfg.viewMode = cSeduService::vmAtmo; startAtmo(); ReplyCode = 550; return "atmo mode activated"; } - else if (Option && strcasecmp(Option, "fixed") == 0) + else if (Option && strcasecmp(Option, "fixed") == 0) { cfg.viewMode = cSeduService::vmFixedCol; startAtmo(); ReplyCode = 550; return "fixed color activated"; } - else if (Option && strcasecmp(Option, "rainbow") == 0) + else if (Option && strcasecmp(Option, "rainbow") == 0) { cfg.viewMode = cSeduService::vmRainbow; startAtmo(); ReplyCode = 550; return "rainbow effect activated"; } - else if (Option && strcasecmp(Option, "wheel") == 0) + else if (Option && strcasecmp(Option, "wheel") == 0) { cfg.viewMode = cSeduService::vmColorWheel; startAtmo(); ReplyCode = 550; return "color wheel effect activated"; } - else if (Option && strcasecmp(Option, "wheelstatic") == 0) + else if (Option && strcasecmp(Option, "wheelstatic") == 0) { cfg.viewMode = cSeduService::vmColorWheelStatic; startAtmo(); ReplyCode = 550; return "static color wheel activated"; } - else if (Option && strcasecmp(Option, "black") == 0) + else if (Option && strcasecmp(Option, "black") == 0) { cfg.viewMode = cSeduService::vmBlack; startAtmo(); - + ReplyCode = 550; return "stripes black"; } - else if (Option && strcasecmp(Option, "detach") == 0) + else if (Option && strcasecmp(Option, "detach") == 0) { cfg.viewMode = cSeduService::vmDetached; stopAtmo(); - + ReplyCode = 550; return "stripes detached"; } @@ -373,9 +374,9 @@ cString cPluginSeduatmo::SVDRPCommand(const char* Command, const char* Option, i return 0; } -const char** cPluginSeduatmo::SVDRPHelpPages(void) -{ - static const char* HelpPages[] = +const char** cPluginSeduatmo::SVDRPHelpPages(void) +{ + static const char* HelpPages[] = { "MODE \n" " Set mode {atmo|fixed|rainbow|wheel|wheelstatic|black|detach}\n", @@ -419,7 +420,7 @@ cSeduSetup::cSeduSetup() if (rgbOrderIndex >= 6) rgbOrderIndex = 0; - + // Cinema Bars cineBars[0] = "Horizontal"; @@ -433,7 +434,7 @@ cSeduSetup::cSeduSetup() // Setup //*************************************************************************** -void cSeduSetup::Setup() +void cSeduSetup::Setup() { Clear(); @@ -459,7 +460,7 @@ void cSeduSetup::Setup() Add(new cMenuEditStraItem(tr("SEDU RGB order"), &rgbOrderIndex, 6, seduRGBOrders)); } -eOSState cSeduSetup::ProcessKey(eKeys Key) +eOSState cSeduSetup::ProcessKey(eKeys Key) { eOSState state = cMenuSetupPage::ProcessKey(Key); diff --git a/seduthread.c b/seduthread.c index ae9b1ec..2ba7bfb 100644 --- a/seduthread.c +++ b/seduthread.c @@ -58,6 +58,7 @@ void cSeduThread::Stop() void cSeduThread::Action() { + time_t last = 0; MsTime wait = 0; cMutexLock lock(&mutex); @@ -70,6 +71,20 @@ void cSeduThread::Action() while (loopActive && Running()) { + if (!sedu.isOpen()) + { + if (last > time(0)-30) + { + waitCondition.TimedWait(mutex, 1000); // wait time in ms + continue; + } + + last = time(0); + + if (sedu.open() != success) + continue; + } + MsTime start = msNow(); // work ... -- cgit v1.2.3