summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter.cpp28
-rw-r--r--global.cpp13
-rw-r--r--global.h38
-rw-r--r--infosatepg.cpp86
-rw-r--r--infosatepg.h2
-rw-r--r--process.cpp23
-rw-r--r--setup.cpp5
7 files changed, 133 insertions, 62 deletions
diff --git a/filter.cpp b/filter.cpp
index a12c368..9b85efa 100644
--- a/filter.cpp
+++ b/filter.cpp
@@ -92,6 +92,7 @@ void cFilterInfosatepg::Process(u_short Pid, u_char Tid, const u_char *Data, int
if (!global->CheckMAC(&eth_hdr)) return;
int mac = eth_hdr.h_dest[5];
+ global->ActualMac=mac;
struct iphdr *ip_hdr = (iphdr *) &Data[SECT_IP_HDR_START];
struct udphdr *udp_hdr = (udphdr *) &Data[SECT_UDP_HDR_START];
@@ -120,21 +121,32 @@ void cFilterInfosatepg::Process(u_short Pid, u_char Tid, const u_char *Data, int
if (ntohs(ishdr->technisatId)!=0x0001) return;
+ int pktnr = ntohs(ishdr->pktnr);
+ int pktcnt = ntohs(ishdr->pktcnt);
+
const u_char *infosatdata = &Data[SECT_IS_DATA_START];
int len = Length - SECT_IS_DATA_START-4;
char file[1024];
snprintf(file,sizeof(file),"%s/infosatepg%02i%02i_%03i.dat",global->Directory(),ishdr->day,ishdr->month,
- ntohs(ishdr->pktcnt));
+ pktcnt);
- if (global->Infosatdata[mac].NeverSeen(ishdr->day,ishdr->month,ntohs(ishdr->pktcnt)))
+ if (global->Infosatdata[mac].NeverSeen(ishdr->day,ishdr->month,pktcnt))
{
// never seen such a packet -> init structure
- global->Infosatdata[mac].Init(file,ishdr->day,ishdr->month,ntohs(ishdr->pktcnt));
+ global->Infosatdata[mac].Init(file,ishdr->day,ishdr->month,pktcnt);
}
+ // Check if we missed a packet
+ global->Infosatdata[mac].CheckMissed(pktnr);
+
// Check if we already have this packet
- if (global->Infosatdata[mac].GetBit(ntohs(ishdr->pktnr))) return;
+ if (global->Infosatdata[mac].GetBit(pktnr))
+ {
+ global->Infosatdata[mac].SetLastPkt(pktnr);
+ return;
+ }
+
#ifdef VDRDEBUG
dsyslog("infosatepg: mac=%02x-%02x-%02x-%02x-%02x-%02x",eth_hdr.h_dest[0],eth_hdr.h_dest[1],
@@ -142,7 +154,7 @@ void cFilterInfosatepg::Process(u_short Pid, u_char Tid, const u_char *Data, int
dsyslog("infosatepg: tid=%04i tbl=%04i stbl=%04i day=%02i month=%02i pktnr=%03i pktcnt=%03i len=%i",
ntohs(ishdr->technisatId),ishdr->tableId,ishdr->tablesubId,ishdr->day,
- ishdr->month, ntohs(ishdr->pktnr), ntohs(ishdr->pktcnt), len);
+ ishdr->month, pktnr, pktcnt, len);
dsyslog("infosatepg: save to %s", file);
#endif
@@ -156,7 +168,7 @@ void cFilterInfosatepg::Process(u_short Pid, u_char Tid, const u_char *Data, int
}
return;
}
- off_t offset = (off_t) (ntohs(ishdr->pktnr)*1400);
+ off_t offset = (off_t) (pktnr*1400);
if (lseek(f,offset,SEEK_SET)!=(off_t) -1)
{
#ifdef VDRDEBUG
@@ -165,13 +177,13 @@ void cFilterInfosatepg::Process(u_short Pid, u_char Tid, const u_char *Data, int
if (write(f,infosatdata,len)==len)
{
// set bit in Infosatdata bitfield
- global->Infosatdata[mac].SetBit(ntohs(ishdr->pktnr),true);
+ global->Infosatdata[mac].SetBit(pktnr,true);
}
}
close(f);
#ifdef WRITE_RAW
- sprintf(file,"%s/%03i.dat",dir,ntohs(ishdr->pktnr));
+ sprintf(file,"%s/%03i.dat",dir,pktnr);
f=open(file,O_RDWR|O_CREAT,0664);
if (f==-1) return;
write(f,Data,Length);
diff --git a/global.cpp b/global.cpp
index ec663d4..31311ac 100644
--- a/global.cpp
+++ b/global.cpp
@@ -29,6 +29,8 @@ void cGlobalInfosatdata::Init(char *File,int Day,int Month,int Packetcount)
}
Processed=false;
receivedall=false;
+ missed=0;
+ lastpkt=-1;
receivedpercent=0;
day=Day;
month=Month;
@@ -103,6 +105,15 @@ void cGlobalInfosatdata::Debug(const char *Directory)
}
#endif
+void cGlobalInfosatdata::CheckMissed(int ActualPacket)
+{
+ if (receivedall) return; // count missed packets while receiving
+ if ((ActualPacket!=(lastpkt+1)) && (lastpkt!=-1)) {
+ missed++;
+ }
+ lastpkt=ActualPacket;
+}
+
bool cGlobalInfosatdata::CheckReceivedAll()
{
int donecnt=0;
@@ -149,6 +160,7 @@ cGlobalInfosatepg::cGlobalInfosatepg()
ProcessedAll=false;
NoWakeup=false;
NoDeferredShutdown=false;
+ ActualMac=0;
}
cGlobalInfosatepg::~cGlobalInfosatepg()
@@ -351,6 +363,7 @@ void cGlobalInfosatepg::ResetReceivedAll(void)
Infosatdata[mac].ResetReceivedAll();
}
wakeuptime=-1;
+ ProcessedAll=false;
}
void cGlobalInfosatepg::ResetProcessed (void)
diff --git a/global.h b/global.h
index 30395fb..fd5dad1 100644
--- a/global.h
+++ b/global.h
@@ -31,6 +31,8 @@ class cGlobalInfosatdata
private:
bool receivedall;
int receivedpercent;
+ int lastpkt;
+ int missed;
u_char day;
u_char month;
u_short pktcnt;
@@ -39,6 +41,10 @@ private:
public:
cGlobalInfosatdata();
bool Processed;
+ int Missed()
+ {
+ return missed;
+ }
bool ReceivedAll()
{
return receivedall;
@@ -48,6 +54,8 @@ public:
Init(file,0,0,0);
}
bool CheckReceivedAll();
+ void CheckMissed(int ActualPacket);
+ void SetLastPkt(int ActualPacket) { lastpkt = ActualPacket; }
int ReceivedPercent()
{
return receivedpercent;
@@ -76,9 +84,9 @@ public:
void Init (char *File, int Day, int Month, int Packetcount);
int Load (int fd);
int Save (int fd);
- #ifdef INFOSATEPG_DEBUG
- void Debug (const char *Directory);
- #endif
+#ifdef INFOSATEPG_DEBUG
+ void Debug (const char *Directory);
+#endif
};
class cGlobalInfosatepg
@@ -89,13 +97,13 @@ class cGlobalInfosatepg
// Bit 20-30 reserved for future used
// Bit 31 always zero
- #define USE_SHORTTEXT 1
- #define USE_LONGTEXT 2
- #define USE_EXTEPG 4
- #define USE_MERGELONGTEXT 8
- #define USE_APPEND 16
+#define USE_SHORTTEXT 1
+#define USE_LONGTEXT 2
+#define USE_EXTEPG 4
+#define USE_MERGELONGTEXT 8
+#define USE_APPEND 16
- #define USE_NOTHING 0
+#define USE_NOTHING 0
struct infosatchannels
{
@@ -104,9 +112,9 @@ class cGlobalInfosatepg
int Usage;
};
- #define EPG_FIRST_DAY_MAC 1
- #define EPG_LAST_DAY_MAC 7
- #define EPG_DAYS 7
+#define EPG_FIRST_DAY_MAC 1
+#define EPG_LAST_DAY_MAC 7
+#define EPG_DAYS 7
private:
const char *directory;
@@ -140,7 +148,10 @@ public:
return wakeuptime;
}
int LastCurrentChannel;
- int Channel() { return channel; }
+ int Channel()
+ {
+ return channel;
+ }
bool FindReceiverChannel();
int Frequency;
char Polarization;
@@ -193,5 +204,6 @@ public:
{
return numinfosatchannels;
}
+ int ActualMac;
};
#endif
diff --git a/infosatepg.cpp b/infosatepg.cpp
index 7fc3cff..038e2ad 100644
--- a/infosatepg.cpp
+++ b/infosatepg.cpp
@@ -27,7 +27,7 @@ cPluginInfosatepg::cPluginInfosatepg(void)
statusMonitor=NULL;
global=new cGlobalInfosatepg;
numprocessed=0;
- mac=EPG_FIRST_DAY_MAC;
+ pmac=EPG_FIRST_DAY_MAC;
}
cPluginInfosatepg::~cPluginInfosatepg()
@@ -46,7 +46,7 @@ const char *cPluginInfosatepg::CommandLineHelp(void)
bool cPluginInfosatepg::ProcessArgs(int argc, char *argv[])
{
- // Implement command line argument processing here if applicable.
+ // Command line argument processing
static struct option long_options[] =
{
{ "dir", required_argument, NULL, 'd'
@@ -127,29 +127,28 @@ void cPluginInfosatepg::MainThreadHook(void)
{
// Perform actions in the context of the main program thread.
if (!global->WaitOk()) return;
- if (global->ReceivedAll() && !global->ProcessedAll)
+
+ if (!global->ProcessedAll)
{
- if (!global->Infosatdata[mac].Processed)
+ if ((!global->Infosatdata[pmac].Processed) && global->Infosatdata[pmac].ReceivedAll())
{
isyslog ("infosatepg: found data to be processed: day=%i month=%i",
- global->Infosatdata[mac].Day(),global->Infosatdata[mac].Month());
- cProcessInfosatepg process(mac,global);
- global->SetWaitTimer();
- }
- if (global->Infosatdata[mac].Processed)
- {
- numprocessed++;
- mac++;
- }
- if (numprocessed==EPG_DAYS)
- {
- global->ProcessedAll=true;
+ global->Infosatdata[pmac].Day(),global->Infosatdata[pmac].Month());
+ cProcessInfosatepg process(pmac,global);
+ if (global->Infosatdata[pmac].Processed)
+ {
+ numprocessed++;
+ pmac++;
+ }
+
+ if (numprocessed==EPG_DAYS)
+ {
+ global->ProcessedAll=true;
+ numprocessed=0;
+ pmac=EPG_FIRST_DAY_MAC;
+ }
}
- }
- else
- {
- numprocessed=0;
- mac=EPG_FIRST_DAY_MAC;
+ global->SetWaitTimer();
}
if ((global->Switched()) || (global->ReceivedAll()) || (global->Channel()==-1)) return;
@@ -159,20 +158,18 @@ void cPluginInfosatepg::MainThreadHook(void)
if (ShutdownHandler.IsUserInactive())
{
- // we are idle -> use live device if we can
- cDevice *dev;
- dev=cDevice::ActualDevice();
- if (dev->ProvidesTransponder(chan) && !dev->Receiving())
+ // first keep the current channel in "mind"
+ if (global->LastCurrentChannel==-1) global->LastCurrentChannel=
+ cDevice::PrimaryDevice()->CurrentChannel();
+
+ // we are idle -> try to use live device if we can
+ if (cDevice::PrimaryDevice()->SwitchChannel(chan,true))
{
- // ok -> use this device
- dsyslog("infosatepg: found free device %i (live)",dev->DeviceNumber()+1);
- if (global->LastCurrentChannel==-1) global->LastCurrentChannel=
- cDevice::PrimaryDevice()->CurrentChannel();
- cDevice::PrimaryDevice()->SwitchChannel(chan,true);
global->SetWaitTimer();
return;
}
}
+ if (global->LastCurrentChannel!=-1) global->LastCurrentChannel=-1;
// Cannot use live device try another (if possible)
@@ -313,11 +310,17 @@ cString cPluginInfosatepg::SVDRPCommand(const char *Command, const char *Option,
if (!strcasecmp(Command,"RESR"))
{
global->ResetReceivedAll();
+ numprocessed=0;
+ pmac=EPG_FIRST_DAY_MAC;
+
asprintf(&output,"OK\n");
}
if (!strcasecmp(Command,"REPR"))
{
global->ResetProcessed();
+ numprocessed=0;
+ pmac=EPG_FIRST_DAY_MAC;
+
asprintf(&output,"OK\n");
}
if (!strcasecmp(Command,"STAT"))
@@ -347,12 +350,29 @@ cString cPluginInfosatepg::SVDRPCommand(const char *Command, const char *Option,
{
asprintf(&output,"%s Switchback to: unset\n",output);
}
+
+ asprintf(&output,"%s\n",output);
+ asprintf(&output,"%s | | missed | | \n",output);
+ asprintf(&output,"%s Day | Date | Packets | Received %% | Processed\n",output);
+ asprintf(&output,"%s------+--------+---------+------------+-----------\n",output);
+
for (int mac=EPG_FIRST_DAY_MAC; mac<=EPG_LAST_DAY_MAC; mac++)
{
- asprintf(&output,"%s Day %i (%02i.%02i.): %3i%% %s\n",
- output,mac,global->Infosatdata[mac].Day(),global->Infosatdata[mac].Month(),
+ if (global->ActualMac==mac)
+ {
+ asprintf(&output,"%s*",output);
+ }
+ else
+ {
+ asprintf(&output,"%s ",output);
+ }
+
+ asprintf(&output,"%s %i | %02i.%02i. | %3i | %3i | %s\n",
+ output,mac,global->Infosatdata[mac].Day(),
+ global->Infosatdata[mac].Month(),
+ global->Infosatdata[mac].Missed(),
global->Infosatdata[mac].ReceivedPercent(),
- global->Infosatdata[mac].Processed ? "processed" : "");
+ global->Infosatdata[mac].Processed ? "yes" : "no");
}
}
return output;
diff --git a/infosatepg.h b/infosatepg.h
index 7b4d80e..992369c 100644
--- a/infosatepg.h
+++ b/infosatepg.h
@@ -21,7 +21,7 @@ private:
cGlobalInfosatepg *global;
cStatusInfosatepg *statusMonitor;
int numprocessed;
- int mac;
+ int pmac;
public:
cPluginInfosatepg(void);
virtual ~cPluginInfosatepg();
diff --git a/process.cpp b/process.cpp
index cc98cc8..96f0439 100644
--- a/process.cpp
+++ b/process.cpp
@@ -677,7 +677,9 @@ bool cProcessInfosatepg::AddInfosatEvent(cChannel *channel, cInfosatevent *iEven
cSchedulesLock SchedulesLock(true,2000); // to be safe ;)
const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
if (!Schedules) return false; // No write lock -> try later!
- cSchedule* Schedule = (cSchedule *) Schedules->GetSchedule(channel,true);
+ bool sAdd=false;
+ if ((iEvent->Usage() & USE_APPEND)==USE_APPEND) sAdd=true;
+ cSchedule* Schedule = (cSchedule *) Schedules->GetSchedule(channel,sAdd);
if (!Schedule) return true; // No schedule -> do nothing (is this ok?)
time_t start=0;
@@ -686,13 +688,19 @@ bool cProcessInfosatepg::AddInfosatEvent(cChannel *channel, cInfosatevent *iEven
if ((lastEvent) && (iEvent->StartTime()<lastEvent->EndTime()))
{
- // try to find, 1st with our own EventID
- Event = (cEvent *) Schedule->GetEvent(iEvent->EventID());
- // 2nd with StartTime +/- WaitTime
+ start=iEvent->StartTime();
+ // try to find, 1st with StartTime
+ Event = (cEvent *) Schedule->GetEvent(iEvent->EventID(),iEvent->StartTime());
+ // 2nd with our own EventID
+ if (!Event) Event = (cEvent *) Schedule->GetEvent(iEvent->EventID());
+ // 3rd with StartTime +/- WaitTime
if (!Event) Event= (cEvent *) SearchEvent(Schedule,iEvent);
- if (!Event) return true; // just bail out with ok
+ if (!Event)
+ {
+ dsyslog("infosatepg: failed to find event %s [%s]", iEvent->Title(),ctime(&start));
+ return true; // just bail out with ok
+ }
- start=iEvent->StartTime();
dsyslog("infosatepg: changing event %s [%s]", iEvent->Title(),ctime(&start));
// change existing event, prevent EIT EPG to update
@@ -710,7 +718,8 @@ bool cProcessInfosatepg::AddInfosatEvent(cChannel *channel, cInfosatevent *iEven
Event->SetDuration(iEvent->Duration());
Event->SetTitle(iEvent->Title());
start=iEvent->StartTime();
- dsyslog("infosatepg: adding new event %s [%s]",iEvent->Title(),ctime(&start));
+ dsyslog("infosatepg: adding new event %s (%lu) [%s]",iEvent->Title(),
+ (u_long) iEvent->EventID(),ctime(&start));
Schedule->AddEvent(Event);
}
diff --git a/setup.cpp b/setup.cpp
index c30f447..5452e68 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -236,6 +236,11 @@ eOSState cMenuSetupChannelMenu::ProcessKey (eKeys Key)
state=osContinue;
break;
+ case kOk:
+ Store();
+ state=osBack;
+ break;
+
default:
break;
}