From e3fe42608da06dcaf6932472343b3f39ea1bcea3 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 16 Apr 2000 13:54:16 +0200 Subject: Dropped dynamic repeat function --- osm.c | 4 ++-- remote.c | 20 +++++++++++--------- remote.h | 4 ++-- tools.h | 3 ++- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/osm.c b/osm.c index 70305ce8..982e1e10 100644 --- a/osm.c +++ b/osm.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: osm.c 1.3 2000/04/15 14:04:21 kls Exp $ + * $Id: osm.c 1.4 2000/04/16 13:54:10 kls Exp $ */ #include @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) DvbApi.StopRecord(); DvbApi.StopReplay(); //TODO kill any remaining sub-processes! - isyslog(LOG_INFO, "exiting", Interrupted); + isyslog(LOG_INFO, "exiting"); closelog(); return 0; } diff --git a/remote.c b/remote.c index bf5b41f8..49864790 100644 --- a/remote.c +++ b/remote.c @@ -4,7 +4,7 @@ * See the main source file 'osm.c' for copyright information and * how to reach the author. * - * $Id: remote.c 1.2 2000/04/15 16:00:51 kls Exp $ + * $Id: remote.c 1.3 2000/04/16 13:54:16 kls Exp $ */ #include "remote.h" @@ -17,6 +17,9 @@ #include #include "tools.h" +#define REPEATLIMIT 100 // ms +#define REPEATDELAY 250 // ms + cRcIo::cRcIo(char *DeviceName) { dp = 0; @@ -25,7 +28,6 @@ cRcIo::cRcIo(char *DeviceName) address = 0xFFFF; t = 0; firstTime = lastTime = 0; - minDelta = 0; lastCommand = 0; if ((f = open(DeviceName, O_RDWR | O_NONBLOCK)) >= 0) { struct termios t; @@ -35,8 +37,11 @@ cRcIo::cRcIo(char *DeviceName) if (tcsetattr(f, TCSAFLUSH, &t) == 0) return; } + LOG_ERROR_STR(DeviceName); close(f); } + else + LOG_ERROR_STR(DeviceName); f = -1; } @@ -48,7 +53,7 @@ cRcIo::~cRcIo() int cRcIo::ReceiveByte(bool Wait) { - // Returns the byte if one was received within 1 second, -1 otherwise + // Returns the byte if one was received within a timeout, -1 otherwise if (f >= 0) { fd_set set; struct timeval timeout; @@ -112,7 +117,6 @@ bool cRcIo::SetCode(unsigned char Code, unsigned short Address) { code = Code; address = Address; - minDelta = 200; return SendCommand(code); } @@ -157,12 +161,10 @@ bool cRcIo::GetCommand(unsigned int *Command, unsigned short *Address) // let's have a timeout to avoid getting overrun by commands int now = time_ms(); int delta = now - lastTime; - if (delta < minDelta) - minDelta = delta; // dynamically adjust to the smallest delta lastTime = now; - if (delta < minDelta * 1.3) { // if commands come in rapidly... - if (now - firstTime < 250) - return false; // ...repeat function kicks in after 250ms + if (delta < REPEATLIMIT) { // if commands come in rapidly... + if (now - firstTime < REPEATDELAY) + return false; // ...repeat function kicks in after a short delay return true; } } diff --git a/remote.h b/remote.h index 68279291..22a80850 100644 --- a/remote.h +++ b/remote.h @@ -4,7 +4,7 @@ * See the main source file 'osm.c' for copyright information and * how to reach the author. * - * $Id: remote.h 1.1 2000/02/19 13:36:48 kls Exp $ + * $Id: remote.h 1.2 2000/04/16 13:53:50 kls Exp $ */ #ifndef __REMOTE_H @@ -19,7 +19,7 @@ private: unsigned char dp, code, mode; unsigned short address; time_t t; - int firstTime, lastTime, minDelta; + int firstTime, lastTime; unsigned int lastCommand; bool SendCommand(unsigned char Cmd); int ReceiveByte(bool Wait = true); diff --git a/tools.h b/tools.h index 48665a84..cb91fc7b 100644 --- a/tools.h +++ b/tools.h @@ -4,12 +4,13 @@ * See the main source file 'osm.c' for copyright information and * how to reach the author. * - * $Id: tools.h 1.3 2000/04/15 15:09:47 kls Exp $ + * $Id: tools.h 1.4 2000/04/16 13:54:04 kls Exp $ */ #ifndef __TOOLS_H #define __TOOLS_H +#include #include #include -- cgit v1.2.3