From f3076919635e550ed752db4030468a3f256f60a1 Mon Sep 17 00:00:00 2001 From: reinelt Date: Tue, 13 Mar 2001 08:34:15 +0000 Subject: [lcd4linux @ 2001-03-13 08:34:15 by reinelt] 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 | 8 ++++++-- lcd4linux.conf.sample | 17 +++++++++-------- mail.c | 8 ++++++-- parser.c | 8 ++++++-- processor.c | 16 ++++++++++------ system.c | 22 +++++++++++++--------- 6 files changed, 50 insertions(+), 29 deletions(-) diff --git a/exec.c b/exec.c index 71c18a1..c37fa56 100644 --- 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 * @@ -20,6 +20,10 @@ * * * $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; diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index ec8d857..6724650 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -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 8d55471..2986512 100644 --- 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 * @@ -20,6 +20,10 @@ * * * $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 diff --git a/parser.c b/parser.c index 8efa761..3e16cdf 100644 --- 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 * @@ -20,6 +20,10 @@ * * * $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; diff --git a/processor.c b/processor.c index 173412f..8676747 100644 --- a/processor.c +++ b/processor.c @@ -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 * @@ -20,6 +20,10 @@ * * * $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<=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]; -- cgit v1.2.3