From ae8c622c7d0d8874cfcd6466ba8df454f0e07794 Mon Sep 17 00:00:00 2001 From: Lars Hanisch Date: Thu, 10 Feb 2011 01:15:50 +0100 Subject: add parsing of watchdog timeout set by udev rule --- README | 5 +++++ dynamicdevice.c | 16 ++++++++++++++++ dynamicdevice.h | 3 +++ dynamite.c | 3 ++- monitor.c | 3 +++ patches/vdr-1.7.16-dynamite-subdevice.patch | 4 ++-- 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README b/README index f684617..22018ac 100644 --- a/README +++ b/README @@ -155,6 +155,11 @@ no data for this period of time. WARNING: You have to attach this device manually again! For now there's no automatism to reload the driver (or whatever is needed) to reanimate the device. +If you want to add a timeout only to specific devices you can do this with udev. +Add a rule which sets with ENV{dynamite_timeout}="10" the needed timeout value. +The udev-monitor in dynamite will evaluate this device-property. +For now this only works for attaching via udev-monitor! + Known issues ------------ If a device managed by this plugin is the primary device it cannot be diff --git a/dynamicdevice.c b/dynamicdevice.c index f918b22..c7841f0 100644 --- a/dynamicdevice.c +++ b/dynamicdevice.c @@ -2,6 +2,7 @@ #include #include +cPlugin *cDynamicDevice::dynamite = NULL; int cDynamicDevice::defaultGetTSTimeout = 0; cDvbDeviceProbe *cDynamicDevice::dvbprobe = NULL; int cDynamicDevice::numDynamicDevices = 0; @@ -40,6 +41,21 @@ bool cDynamicDevice::ProcessQueuedCommands(void) DetachDevice(*dev->devpath); break; } + case ddpcService: + { + if (dynamite && (dev->devpath != NULL) && (**dev->devpath != NULL)) { + int len = strlen(*dev->devpath); + if (len > 0) { + char *data = strchr(const_cast(**dev->devpath), ' '); + if (data != NULL) { + data[0] = '\0'; + data++; + dynamite->Service(*dev->devpath, data); + } + } + } + break; + } } } cDynamicDeviceProbe::commandQueue.Clear(); diff --git a/dynamicdevice.h b/dynamicdevice.h index 1fe9831..e499774 100644 --- a/dynamicdevice.h +++ b/dynamicdevice.h @@ -2,6 +2,7 @@ #define __DYNAMITEDEVICE_H #include +#include enum eDynamicDeviceReturnCode { ddrcSuccess, ddrcNoFreeDynDev, @@ -14,7 +15,9 @@ enum eDynamicDeviceReturnCode { ddrcSuccess, }; class cDynamicDevice : public cDevice { + friend class cPluginDynamite; private: + static cPlugin *dynamite; static int defaultGetTSTimeout; static int numDynamicDevices; diff --git a/dynamite.c b/dynamite.c index 1941456..cad44cb 100644 --- a/dynamite.c +++ b/dynamite.c @@ -8,7 +8,7 @@ #include "dynamicdevice.h" #include "monitor.h" -static const char *VERSION = "0.0.5e"; +static const char *VERSION = "0.0.5f"; static const char *DESCRIPTION = "attach/detach devices on the fly"; static const char *MAINMENUENTRY = NULL; @@ -76,6 +76,7 @@ public: cPluginDynamite::cPluginDynamite(void) { + cDynamicDevice::dynamite = this; cDynamicDevice::dvbprobe = new cDynamiteDvbDeviceProbe; // make sure we're the first one you cares for dvbdevices cDvbDeviceProbe *firstDvbProbe = DvbDeviceProbes.First(); diff --git a/monitor.c b/monitor.c index e603c30..601a3bb 100644 --- a/monitor.c +++ b/monitor.c @@ -216,6 +216,9 @@ void cUdevDvbFilter::Process(cUdevDevice &Device) if (!devname || cDynamicDevice::IsAttached(devname)) return; cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcAttach, devname); + const char *timeout = Device.GetPropertyValue("dynamite_timeout"); + if (timeout) + cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcService, *cString::sprintf("dynamite-SetGetTSTimeout-v0.1 %s %s", devname, timeout)); } } diff --git a/patches/vdr-1.7.16-dynamite-subdevice.patch b/patches/vdr-1.7.16-dynamite-subdevice.patch index 16e7264..60b023b 100644 --- a/patches/vdr-1.7.16-dynamite-subdevice.patch +++ b/patches/vdr-1.7.16-dynamite-subdevice.patch @@ -154,7 +154,7 @@ index 681049b..c758390 100644 + DynamicDeviceProbes.Del(this, false); +} diff --git a/device.h b/device.h -index cb3bc2c..8364e73 100644 +index cb3bc2c..fc0e5c5 100644 --- a/device.h +++ b/device.h @@ -163,7 +163,6 @@ private: @@ -241,7 +241,7 @@ index cb3bc2c..8364e73 100644 + +#define __DYNAMIC_DEVICE_PROBE + -+enum eDynamicDeviceProbeCommand { ddpcAttach, ddpcDetach }; ++enum eDynamicDeviceProbeCommand { ddpcAttach, ddpcDetach, ddpcService }; + +class cDynamicDeviceProbe : public cListObject { + friend class cDynamicDevice; -- cgit v1.2.3