]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2001-03-13 08:34:15 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Tue, 13 Mar 2001 08:34:15 +0000 (08:34 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Tue, 13 Mar 2001 08:34:15 +0000 (08:34 +0000)
corrected a off-by-one bug with sensors

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@116 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

exec.c
lcd4linux.conf.sample
mail.c
parser.c
processor.c
system.c

diff --git a/exec.c b/exec.c
index 71c18a19fb87670f156367173f8fbb15caf50da5..c37fa5613db04aecb3b2b38b8f7fb71e11a13afa 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -1,4 +1,4 @@
-/* $Id: exec.c,v 1.4 2001/03/09 14:24:49 ltoetsch Exp $
+/* $Id: exec.c,v 1.5 2001/03/13 08:34:15 reinelt Exp $
  *
  * exec ('x*') functions
  *
  *
  *
  * $Log: exec.c,v $
+ * Revision 1.5  2001/03/13 08:34:15  reinelt
+ *
+ * corrected a off-by-one bug with sensors
+ *
  * Revision 1.4  2001/03/09 14:24:49  ltoetsch
  * exec: Scale_x ->Min/Max_x
  *
@@ -67,7 +71,7 @@ int Exec(int index, char buff[EXEC_TXT_LEN], double *val)
   size_t len;
   int i;
 
-  if (index < 1 || index > EXECS)
+  if (index < 0 || index > EXECS)
     return -1; 
   if (errs[index])
     return -1;
index ec8d8579de068825b94c9204b175c4e44c0bc5b3..6724650b4b93d756e6cbd9bf1a8ea393d022d846 100644 (file)
@@ -1,12 +1,12 @@
-#Display LCD2041
-#Port /dev/ttyS2
-#Speed 19200
-#Contrast 160
+Display LCD2041
+Port /dev/ttyS2
+Speed 19200
+Contrast 160
 
-Display HD44780
-Port 0x278
-Size 24x2
-Delay 503
+#Display HD44780
+#Port 0x278
+#Size 24x2
+#Delay 503
 
 #Display BLC100x
 #Port /dev/ttyS2
@@ -118,3 +118,4 @@ Sensor2_max 50
 Sensor3 /proc/sys/dev/sensors/as99127f-i2c-0-2d/temp3
 Sensor3_min 30
 Sensor3_max 50
+
diff --git a/mail.c b/mail.c
index 8d55471f59a3b27b686c822eb902b57807191c4e..2986512eb12f256f1235f1bcf2b1efe109ee92e0 100644 (file)
--- a/mail.c
+++ b/mail.c
@@ -1,4 +1,4 @@
-/* $Id: mail.c,v 1.4 2001/03/08 09:02:04 reinelt Exp $
+/* $Id: mail.c,v 1.5 2001/03/13 08:34:15 reinelt Exp $
  *
  * email specific functions
  *
  *
  *
  * $Log: mail.c,v $
+ * Revision 1.5  2001/03/13 08:34:15  reinelt
+ *
+ * corrected a off-by-one bug with sensors
+ *
  * Revision 1.4  2001/03/08 09:02:04  reinelt
  *
  * seti client cleanup
@@ -83,7 +87,7 @@ int Mail (int index, int *num)
   char *txt;
   char txt1[100];
 
-  if (index<1 || index>MAILBOXES) return -1;
+  if (index<0 || index>MAILBOXES) return -1;
 
   if (time(NULL)==now[index]) return 0;   // More then 1 second after last check
   time(&now[index]);                      // for Mailbox #index
index 8efa7618100b90ee79ede631db0fed1d6a32c5fd..3e16cdf298e059fee29ca9e29c3a0bc4f5c42286 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1,4 +1,4 @@
-/* $Id: parser.c,v 1.13 2001/03/08 15:25:38 ltoetsch Exp $
+/* $Id: parser.c,v 1.14 2001/03/13 08:34:15 reinelt Exp $
  *
  * row definition parser
  *
  *
  *
  * $Log: parser.c,v $
+ * Revision 1.14  2001/03/13 08:34:15  reinelt
+ *
+ * corrected a off-by-one bug with sensors
+ *
  * Revision 1.13  2001/03/08 15:25:38  ltoetsch
  * improved exec
  *
@@ -192,7 +196,7 @@ static int get_token (char *s, char **p, int bar, int usage[])
        return -1;
       }
       c=*(s+l-1);
-      if (strncmp(Symtab[i].symbol, s, l-1)==0 && c>='1' && c<='9') {
+      if (strncmp(Symtab[i].symbol, s, l-1)==0 && c>='0' && c<='9') {
        *p=s+l;
        usage[Symtab[i].token]|=(1<<(c-'0'));
        usage[Symtab[i].class]=1;
index 173412f3c77f4cb7178245bc9da24fd53365edae..867674746bbc3548787d693063078593fc7ac97a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: processor.c,v 1.18 2001/03/08 15:25:38 ltoetsch Exp $
+/* $Id: processor.c,v 1.19 2001/03/13 08:34:15 reinelt Exp $
  *
  * main data processing
  *
  *
  *
  * $Log: processor.c,v $
+ * Revision 1.19  2001/03/13 08:34:15  reinelt
+ *
+ * corrected a off-by-one bug with sensors
+ *
  * Revision 1.18  2001/03/08 15:25:38  ltoetsch
  * improved exec
  *
@@ -148,8 +152,8 @@ struct { int usage, in, out, total, max, peak; } isdn;
 struct { int rx, tx, total, max, peak; } ppp;
 struct { int perc, stat; double dur; } batt;
 struct { double perc, cput; } seti;
-struct { int num; } mail[MAILBOXES];
-struct { double val, min, max; } sensor[SENSORS];
+struct { int num; } mail[MAILBOXES+1];
+struct { double val, min, max; } sensor[SENSORS+1];
 
 static double query (int token)
 {
@@ -516,19 +520,19 @@ static void collect_data (void)
     Battery (&batt.perc, &batt.stat, &batt.dur);
   }
   
-  for (i=1; i<=MAILBOXES; i++) {
+  for (i=0; i<=MAILBOXES; i++) {
     if (token_usage[T_MAIL]&(1<<i)) {
       Mail (i, &mail[i].num);
     }
   }
   
-  for (i=1; i<SENSORS; i++) {
+  for (i=0; i<=SENSORS; i++) {
     if (token_usage[T_SENSOR]&(1<<i)) {
       Sensor (i, &sensor[i].val, &sensor[i].min, &sensor[i].max);
     }
   }
 
-  for (i=1; i<EXECS; i++) {
+  for (i=0; i<=EXECS; i++) {
     if (token_usage[T_EXEC]&(1<<i)) {
       Exec (i, exec[i].s, &exec[i].val);
     }
index cbf1bfef1864c2899b92023153edb5d614d59d4c..a1a9b1c4bccd8e3b63a39a0d100d01f0aba60575 100644 (file)
--- a/system.c
+++ b/system.c
@@ -1,4 +1,4 @@
-/* $Id: system.c,v 1.22 2001/03/12 12:39:36 reinelt Exp $
+/* $Id: system.c,v 1.23 2001/03/13 08:34:15 reinelt Exp $
  *
  * system status retreivement
  *
  *
  *
  * $Log: system.c,v $
+ * Revision 1.23  2001/03/13 08:34:15  reinelt
+ *
+ * corrected a off-by-one bug with sensors
+ *
  * Revision 1.22  2001/03/12 12:39:36  reinelt
  *
  * reworked autoconf a lot: drivers may be excluded, #define's went to config.h
@@ -730,14 +734,14 @@ int Sensor (int index, double *val, double *min, double *max)
 {
   char buffer[32];
   double dummy, value;
-  static int fd[SENSORS]={[0 ... SENSORS-1]=-2,};
-  static char *sensor[SENSORS]={NULL,};
-  static double val_buf[SENSORS]={0.0,};
-  static double min_buf[SENSORS]={0.0,};
-  static double max_buf[SENSORS]={0.0,};
-  static time_t now[SENSORS]={0,};
-
-  if (index<1 || index>=SENSORS) return -1;
+  static int fd[SENSORS+1]={[0 ... SENSORS]=-2,};
+  static char *sensor[SENSORS+1]={NULL,};
+  static double val_buf[SENSORS+1]={0.0,};
+  static double min_buf[SENSORS+1]={0.0,};
+  static double max_buf[SENSORS+1]={0.0,};
+  static time_t now[SENSORS+1]={0,};
+
+  if (index<0 || index>SENSORS) return -1;
 
   *val=val_buf[index];
   *min=min_buf[index];