diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2000-07-31 10:43:44 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2000-07-31 10:43:44 +0000 |
commit | 7ff246c0458df37567dcefebfd9a720f9b98cdb7 (patch) | |
tree | a9166e080f3ac5e3675bfa3fad68942d47ff955d | |
parent | 5369cdf6f69abc9a33581e8209f4fc1d2ea468f1 (diff) | |
download | lcd4linux-7ff246c0458df37567dcefebfd9a720f9b98cdb7.tar.gz |
[lcd4linux @ 2000-07-31 10:43:44 by reinelt]
some changes to support kernel-2.4 (different layout of various files in /proc)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@60 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to '')
-rw-r--r-- | HD44780.c | 14 | ||||
-rwxr-xr-x | configure | 107 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 34 | ||||
-rw-r--r-- | processor.c | 42 | ||||
-rw-r--r-- | system.c | 107 | ||||
-rw-r--r-- | system.h | 8 | ||||
-rw-r--r-- | udelay.c | 10 |
8 files changed, 235 insertions, 91 deletions
@@ -1,4 +1,4 @@ -/* $Id: HD44780.c,v 1.5 2000/07/31 06:46:35 reinelt Exp $ +/* $Id: HD44780.c,v 1.6 2000/07/31 10:43:44 reinelt Exp $ * * driver for display modules based on the HD44780 chip * @@ -20,6 +20,10 @@ * * * $Log: HD44780.c,v $ + * Revision 1.6 2000/07/31 10:43:44 reinelt + * + * some changes to support kernel-2.4 (different layout of various files in /proc) + * * Revision 1.5 2000/07/31 06:46:35 reinelt * * eliminated some compiler warnings with glibc @@ -68,7 +72,15 @@ #include <time.h> #include <signal.h> #include <errno.h> +#ifdef HAVE_SYS_IO_H #include <sys/io.h> +#else +#ifdef HAVE_ASM_IO_H +#include <asm/io.h> +#else +#error "neither sys/io.h nor asm/io.h found!" +#endif +#endif #include "debug.h" #include "cfg.h" @@ -2234,14 +2234,54 @@ else fi done +for ac_hdr in sys/io.h asm/io.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:2242: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 2247 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2252: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:2240: checking for pid_t" >&5 +echo "configure:2280: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2245 "configure" +#line 2285 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -2269,12 +2309,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:2273: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:2313: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2278 "configure" +#line 2318 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/time.h> @@ -2283,7 +2323,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:2287: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2327: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -2306,13 +2346,13 @@ fi if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:2310: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:2350: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext <<EOF -#line 2316 "configure" +#line 2356 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -2330,7 +2370,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 2334 "configure" +#line 2374 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -2351,13 +2391,49 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 fi fi +echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 +echo "configure:2396: checking for 8-bit clean memcmp" >&5 +if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_memcmp_clean=no +else + cat > conftest.$ac_ext <<EOF +#line 2404 "configure" +#include "confdefs.h" + +main() +{ + char c0 = 0x40, c1 = 0x80, c2 = 0x81; + exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1); +} + +EOF +if { (eval echo configure:2414: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_func_memcmp_clean=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_memcmp_clean=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 +test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" + echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:2356: checking return type of signal handlers" >&5 +echo "configure:2432: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2361 "configure" +#line 2437 "configure" #include "confdefs.h" #include <sys/types.h> #include <signal.h> @@ -2374,7 +2450,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:2378: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2454: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -2392,15 +2468,15 @@ cat >> confdefs.h <<EOF EOF -for ac_func in gettimeofday strdup strerror strstr strtol uname +for ac_func in gettimeofday socket strdup strerror strstr strtol uname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2399: checking for $ac_func" >&5 +echo "configure:2475: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2404 "configure" +#line 2480 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -2423,7 +2499,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:2427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2614,6 +2690,7 @@ s%@X_LIBS@%$X_LIBS%g s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g s%@WITH_X_TRUE@%$WITH_X_TRUE%g s%@WITH_X_FALSE@%$WITH_X_FALSE%g +s%@LIBOBJS@%$LIBOBJS%g CEOF EOF diff --git a/configure.in b/configure.in index fbc3775..1cf0df5 100644 --- a/configure.in +++ b/configure.in @@ -18,6 +18,7 @@ AM_CONDITIONAL(WITH_X, test x$no_x = x) dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h) +AC_CHECK_HEADERS(sys/io.h asm/io.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_PID_T @@ -25,7 +26,8 @@ AC_HEADER_TIME dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL +AC_FUNC_MEMCMP AC_TYPE_SIGNAL -AC_CHECK_FUNCS(gettimeofday strdup strerror strstr strtol uname) +AC_CHECK_FUNCS(gettimeofday socket strdup strerror strstr strtol uname) AC_OUTPUT(Makefile) diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 87400b6..fc7f232 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -1,12 +1,15 @@ -Display LCD2041 -Port /dev/ttyS2 -Speed 19200 -Contrast 160 +#Display LCD2041 +#Port /dev/ttyS2 +#Speed 19200 +#Contrast 160 + +Display HD44780 +Port 0x378 +Size 16x2 +Delay 398 -#Display HD44780 -#Port 0x378 -#Size 16x2 -#Delay 300 +Row1 "Disk%dm $R10dr+dw" +Row2 "Net %nm $R10nr+nw" #Display BLC100x #Port /dev/ttyS2 @@ -44,15 +47,14 @@ Contrast 160 #Row1 "*** %o %v ***" #Row2 "%p CPU %r MB RAM" #Row3 "Busy %cb%% $r10cs+cb" -#Row4 "Load %l1%L$r10l1" - -Row1 "Load %l1%L$r10cs+cb" -Row2 "Disk %dm $R10dr+dw" -Row3 "Net %nm $R10nr+nw" -#Row4 "ISDN %im $r10ii+io" -Row5 "Temp %s2°$r10s1+s2" +#Row4 "Load%l1%L$r10l1" -Row4 "DSL %tm $r10ti+to" +#Row1 "Load%l1%L$r10cs+cb" +#Row2 "Disk%dm $R10dr+dw" +#Row3 "Net %nm $R10nr+nw" +#Row4 "ISDN%im $r10ii+io" +#Row4 "DSL %tm $r10ti+to" +#Row5 "Temp%s2°$r10s1+s2" #Row1 "$u3l1$u3cb$u3cs $u3mu$u3ma$u3ms $u3dr$u3dw $u3nr$u3nw $u3ii$u3io" #Row2 " " diff --git a/processor.c b/processor.c index f77aa3d..da1c3d2 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.6 2000/05/21 06:20:35 reinelt Exp $ +/* $Id: processor.c,v 1.7 2000/07/31 10:43:44 reinelt Exp $ * * main data processing * @@ -20,6 +20,10 @@ * * * $Log: processor.c,v $ + * Revision 1.7 2000/07/31 10:43:44 reinelt + * + * some changes to support kernel-2.4 (different layout of various files in /proc) + * * Revision 1.6 2000/05/21 06:20:35 reinelt * * added ppp throughput @@ -87,7 +91,7 @@ struct { int total, used, free, shared, buffer, cache, avail; } ram; struct { double load1, load2, load3, overload; } load; struct { double user, nice, system, idle; } busy; struct { int read, write, total, max, peak; } disk; -struct { int rx, tx, total, max, peak; } net; +struct { int rx, tx, total, max, peak, bytes; } net; struct { int usage, in, out, total, max, peak; } isdn; struct { int rx, tx, total, max, peak; } ppp; struct { double val, min, max; } sensor[SENSORS]; @@ -292,13 +296,12 @@ static void print_token (int token, char **p) case T_SENSOR_8: case T_SENSOR_9: val=query(token); - if (val<10.0) { - *p+=sprintf (*p, "%4.2f", val); - } else if (val<100.0) { - *p+=sprintf (*p, "%4.1f", val); - } else { - *p+=sprintf (*p, "%4.0f", val); - } + if (val<10.0) + *p+=sprintf (*p, "%5.2f", val); + else if (val<100.0) + *p+=sprintf (*p, "%5.1f", val); + else + *p+=sprintf (*p, "%5.0f", val); break; case T_CPU_USER: case T_CPU_NICE: @@ -307,23 +310,26 @@ static void print_token (int token, char **p) case T_CPU_IDLE: *p+=sprintf (*p, "%3.0f", 100.0*query(token)); break; + case T_ETH_RX: + case T_ETH_TX: + case T_ETH_MAX: + case T_ETH_TOTAL: + val=query(token); + if (net.bytes) + val/=1024.0; + *p+=sprintf (*p, "%5.0f", val); + break; case T_ISDN_IN: case T_ISDN_OUT: case T_ISDN_MAX: case T_ISDN_TOTAL: if (isdn.usage) - *p+=sprintf (*p, "%4.0f", query(token)); + *p+=sprintf (*p, "%5.0f", query(token)); else *p+=sprintf (*p, "----"); break; - case T_PPP_RX: - case T_PPP_TX: - case T_PPP_MAX: - case T_PPP_TOTAL: - *p+=sprintf (*p, "%5.0f", query(token)); - break; default: - *p+=sprintf (*p, "%4.0f", query(token)); + *p+=sprintf (*p, "%5.0f", query(token)); } } @@ -353,7 +359,7 @@ static void collect_data (void) } if (token_usage[C_ETH]) { - Net (&net.rx, &net.tx); + Net (&net.rx, &net.tx, &net.bytes); net.total=net.rx+net.tx; net.max=net.rx>net.tx?net.rx:net.tx; if (net.max>net.peak) net.peak=net.max; @@ -1,4 +1,4 @@ -/* $Id: system.c,v 1.12 2000/05/21 06:20:35 reinelt Exp $ +/* $Id: system.c,v 1.13 2000/07/31 10:43:44 reinelt Exp $ * * system status retreivement * @@ -20,6 +20,10 @@ * * * $Log: system.c,v $ + * Revision 1.13 2000/07/31 10:43:44 reinelt + * + * some changes to support kernel-2.4 (different layout of various files in /proc) + * * Revision 1.12 2000/05/21 06:20:35 reinelt * * added ppp throughput @@ -108,11 +112,13 @@ * returns 0 if ok, -1 on error * * int Disk (int *r, int *w); - * sets number of read and write accesses to all disks + * sets number of blocks read and written from/to all disks * returns 0 if ok, -1 on error * - * int Net (int *rx, int *tx); - * sets number of packets received and transmitted + * int Net (int *rx, int *tx, int *bytes); + * sets number of packets or bytes received and transmitted + * *bytes ist set to 0 if rx/tx are packets + * *bytes ist set to 1 if rx/tx are bytes * returns 0 if ok, -1 on error * * int PPP (int unit, int *rx, int *tx); @@ -455,8 +461,6 @@ int Disk (int *r, int *w) { char buffer[4096], *p; static int fd=-2; - unsigned long r1, r2, r3, r4; - unsigned long w1, w2, w3, w4; *r=0; *w=0; @@ -482,36 +486,59 @@ int Disk (int *r, int *w) fd=-1; return -1; } - p=strstr(buffer, "disk_rblk"); - if (p==NULL) { - fprintf (stderr, "parse(/proc/stat) failed: no 'disk_rblk' line\n"); - fd=-1; - return -1; - } - if (sscanf(p+9, "%lu %lu %lu %lu\n", &r1, &r2, &r3, &r4)<4) { - fprintf (stderr, "scanf(/proc/stat) failed\n"); - fd=-1; - return -1; - } - p=strstr(buffer, "disk_wblk"); - if (p==NULL) { - fprintf (stderr, "parse(/proc/stat) failed: no 'disk_wblk' line\n"); - fd=-1; - return -1; - } - if (sscanf(p+9, "%lu %lu %lu %lu\n", &w1, &w2, &w3, &w4)<4) { - fprintf (stderr, "scanf(/proc/stat) failed\n"); - fd=-1; - return -1; + + p=strstr(buffer, "disk_io:"); + if (p!=NULL) { + int n; + unsigned long rblk, wblk; + unsigned long rsum, wsum; + p+=8; + rsum=0; + wsum=0; + while (sscanf(p, " (%*u,%*u):(%*u,%lu,%*u,%lu)%n", &rblk, &wblk, &n)==2) { + rsum+=rblk; + wsum+=wblk; + p+=n; + } + // assume that we got the number of sectors and a sector size of 512 bytes + // to get te number in kilobytes/sec, we calculate as follows: + // kb=blocks*512/1024, which is blocks/2 + *r=smooth ("disk_r", 500, rsum/2); + *w=smooth ("disk_w", 500, wsum/2); + + } else { + unsigned long r1, r2, r3, r4; + unsigned long w1, w2, w3, w4; + p=strstr(buffer, "disk_rblk"); + if (p==NULL) { + fprintf (stderr, "parse(/proc/stat) failed: no 'disk_rblk' line\n"); + fd=-1; + return -1; + } + if (sscanf(p+9, "%lu %lu %lu %lu\n", &r1, &r2, &r3, &r4)<4) { + fprintf (stderr, "scanf(/proc/stat) failed\n"); + fd=-1; + return -1; + } + p=strstr(buffer, "disk_wblk"); + if (p==NULL) { + fprintf (stderr, "parse(/proc/stat) failed: no 'disk_wblk' line\n"); + fd=-1; + return -1; + } + if (sscanf(p+9, "%lu %lu %lu %lu\n", &w1, &w2, &w3, &w4)<4) { + fprintf (stderr, "scanf(/proc/stat) failed\n"); + fd=-1; + return -1; + } + *r=smooth ("disk_r", 500, r1+r2+r3+r4); + *w=smooth ("disk_w", 500, w1+w2+w3+w4); } - *r=smooth ("disk_r", 500, r1+r2+r3+r4); - *w=smooth ("disk_w", 500, w1+w2+w3+w4); - return 0; } -int Net (int *rx, int *tx) +int Net (int *rx, int *tx, int *bytes) { char buffer[4096], *p, *s; static int fd=-2; @@ -519,6 +546,7 @@ int Net (int *rx, int *tx) *rx=0; *tx=0; + *bytes=0; if (fd==-1) return -1; @@ -548,15 +576,24 @@ int Net (int *rx, int *tx) p=buffer; while ((s=strsep(&p, "\n"))) { unsigned long r, t; - if (sscanf (s, " eth%*d:%*d: %ld %*d %*d %*d %*d %ld", &r, &t)==2 || - sscanf (s, " eth%*d: %ld %*d %*d %*d %*d %ld", &r, &t)==2) { + + if (sscanf (s, " eth%*d:%ld %*d %*d %*d %*d %*d %*d %*d %ld %*d %*d %*d %*d %*d %*d %*d", &r, &t)==2) { pkg_rx+=r; pkg_tx+=t; - } + *bytes=1; + } else { + if (sscanf (s, " eth%*d:%*d: %ld %*d %*d %*d %*d %ld %*d %*d %*d %*d %*d", &r, &t)==2 || + sscanf (s, " eth%*d:%ld %*d %*d %*d %*d %ld %*d %*d %*d %*d %*d", &r, &t)==2) { + pkg_rx+=r; + pkg_tx+=t; + *bytes=0; + } + } } + *rx=smooth("net_rx", 500, pkg_rx); *tx=smooth("net_tx", 500, pkg_tx); - + return 0; } @@ -1,4 +1,4 @@ -/* $Id: system.h,v 1.7 2000/05/21 06:20:35 reinelt Exp $ +/* $Id: system.h,v 1.8 2000/07/31 10:43:44 reinelt Exp $ * * system status retreivement * @@ -20,6 +20,10 @@ * * * $Log: system.h,v $ + * Revision 1.8 2000/07/31 10:43:44 reinelt + * + * some changes to support kernel-2.4 (different layout of various files in /proc) + * * Revision 1.7 2000/05/21 06:20:35 reinelt * * added ppp throughput @@ -65,7 +69,7 @@ int Ram (int *total, int *free, int *shared, int *buffered, int *cached); int Load (double *load1, double *load2, double *load3); int Busy (double *user, double *nice, double *system, double *idle); int Disk (int *r, int *w); -int Net (int *rx, int *tx); +int Net (int *rx, int *tx, int *bytes); int PPP (int unit, int *rx, int *tx); int Sensor (int index, double *val, double *min, double *max); @@ -1,4 +1,4 @@ -/* $Id: udelay.c,v 1.1 2000/04/15 16:56:52 reinelt Exp $ +/* $Id: udelay.c,v 1.2 2000/07/31 10:43:44 reinelt Exp $ * * short delays * @@ -20,6 +20,10 @@ * * * $Log: udelay.c,v $ + * Revision 1.2 2000/07/31 10:43:44 reinelt + * + * some changes to support kernel-2.4 (different layout of various files in /proc) + * * Revision 1.1 2000/04/15 16:56:52 reinelt * * moved delay loops to udelay.c @@ -80,7 +84,7 @@ void udelay_calibrate (void) tick=clock(); while (clock()==tick); tick=clock(); - udelay(1000000/CLOCKS_PER_SEC); + udelay(1000000/CLK_TCK); if (clock()>tick) break; } @@ -92,7 +96,7 @@ void udelay_calibrate (void) tick=clock(); while (clock()==tick); tick=clock(); - udelay(1000000/CLOCKS_PER_SEC); + udelay(1000000/CLK_TCK); if (clock()>tick) loops_per_usec&=~bit; } |