/* $Id: processor.c,v 1.21 2001/03/15 09:47:13 reinelt Exp $ * * main data processing * * Copyright 1999, 2000 by Michael Reinelt (reinelt@eunet.at) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * $Log: processor.c,v $ * Revision 1.21 2001/03/15 09:47:13 reinelt * * some fixes to ppdef * off-by-one bug in processor.c fixed * * Revision 1.20 2001/03/14 13:19:29 ltoetsch * Added pop3/imap4 mail support * * 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 * * Revision 1.17 2001/03/08 08:39:55 reinelt * * fixed two typos * * Revision 1.16 2001/03/07 18:10:21 ltoetsch * added e(x)ec commands * * Revision 1.15 2001/03/02 10:18:03 ltoetsch * added /proc/apm battery stat * * Revision 1.14 2001/02/19 00:15:46 reinelt * * integrated mail and seti client * major rewrite of parser and tokenizer to support double-byte tokens * * Revision 1.13 2001/02/16 14:15:11 reinelt * * fixed type in processor.c * GPO documentation update from Carsten * * Revision 1.12 2001/02/16 08:23:09 reinelt * * new token 'ic' (ISDN connected) by Carsten Nau * * Revision 1.11 2001/02/14 07:40:16 reinelt * * first (incomplete) GPO implementation * * Revision 1.10 2001/02/13 09:00:13 reinelt * * prepared framework for GPO's (general purpose outputs) * * Revision 1.9 2001/02/11 23:34:07 reinelt * * fixed a small bug where the throughput of an offline ISDN connection * is displayed as '----', but the online value is 5 chars long. * corrected to ' ----'. Thanks to Carsten Nau * * Revision 1.8 2000/08/10 09:44:09 reinelt * * new debugging scheme: error(), info(), debug() * uses syslog if in daemon mode * * 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 * token is '%t[iomt]' at the moment, but this will change in the near future * * Revision 1.5 2000/04/15 11:56:35 reinelt * * more debug messages * * Revision 1.4 2000/04/15 11:13:54 reinelt * * added '-d' (debugging) switch * added several debugging messages * removed config entry 'Delay' for HD44780 driver * delay loop for HD44780 will be calibrated automatically * * Revision 1.3 2000/04/01 16:22:38 reinelt * * bug that caused a segfault in processor.c fixed (thanks to herp) * * Revision 1.
# Sweden - Gusum
[CHANNEL]
	DELIVERY_SYSTEM = DVBT
	FREQUENCY = 482000000
	BANDWIDTH_HZ = 8000000
	CODE_RATE_HP = 2/3
	CODE_RATE_LP = NONE
	MODULATION = QAM/64
	TRANSMISSION_MODE = 8K
	GUARD_INTERVAL = 1/8
	HIERARCHY = NONE
	INVERSION = AUTO
: 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, "%5.0f", query(token)); else *p+=sprintf (*p, " ----"); break; case T_ISDN_USED: if (isdn.usage) *p+=sprintf (*p, "*"); else *p+=sprintf (*p, " "); break; case T_SETI_PRC: val=100.0*query(token); if (val<100.0) *p+=sprintf (*p, "%4.1f", val); else *p+=sprintf (*p, " 100"); break; case T_SETI_CPU: val=query(token); *p+=sprintf (*p, "%2d.%2.2d:%2.2d", (int)val/86400, (int)((int)val%86400)/3600, (int)(((int)val%86400)%3600)/60 ); break; case T_BATT_PERC: *p+=sprintf(*p, "%3.0f", query(token)); break; case T_BATT_STAT: { int ival = (int) query(token); switch (ival) { case 0: **p = '='; break; case 1: **p = '+'; break; case 2: **p = '-'; break; default: **p = '?'; break; } } (*p)++; break; case T_BATT_DUR: { char eh = 's'; val = query(token); if (val > 99) { val /= 60; eh = 'm'; } if (val > 99) { val /= 60; eh = 'h'; } if (val > 99) { val /= 24; eh = 'd'; } *p+=sprintf(*p, "%2.0f%c", val, eh); } break; case T_MAIL: case T_MAIL_UNSEEN: val=query(token); *p+=sprintf (*p, "%3.0f", val); break; case T_EXEC: i = (token>>8)-'0'; *p+=sprintf (*p, "%.*s",cols-(*p-start), exec[i].s); for (i=*p-start; idisk.write?disk.read:disk.write; if (disk.max>disk.peak) disk.peak=disk.max; } if (token_usage[C_ETH]) { 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; } if (token_usage[C_ISDN]) { Isdn (&isdn.in, &isdn.out, &isdn.usage); isdn.total=isdn.in+isdn.out; isdn.max=isdn.in>isdn.out?isdn.in:isdn.out; if (isdn.max>isdn.peak) isdn.peak=isdn.max; } if (token_usage[C_PPP]) { PPP (0, &ppp.rx, &ppp.tx); ppp.total=ppp.rx+ppp.tx; ppp.max=ppp.rx>ppp.tx?ppp.rx:ppp.tx; if (ppp.max>ppp.peak) ppp.peak=ppp.max; } if (token_usage[C_SETI]) { Seti (&seti.perc, &seti.cput); } if (token_usage[C_BATT]) { Battery (&batt.perc, &batt.stat, &batt.dur); } for (i=0; i<=MAILBOXES; i++) { if (token_usage[T_MAIL]&(1<T_EXTENDED) token += (*(unsigned char*)++s)<<8; for (q = p, len=0; *q && isspace(*q); q++) len++; print_token (token, &p, buffer, len); } else if (*s=='$') { double val1, val2; int i, type, len; type=*++s; len=*++s; token = *(unsigned char*)++s; if (token>T_EXTENDED) token += (*(unsigned char*)++s)<<8; val1=query_bar(token); val2=val1; if (type & (BAR_H2 | BAR_V2)) { token = *(unsigned char*)++s; if (token>T_EXTENDED) token += (*(unsigned char*)++s)<<8; val2=query_bar(token); } if (type & BAR_H) lcd_bar (type, r, p-buffer+1, len*xres, val1*len*xres, val2*len*xres); else lcd_bar (type, r, p-buffer+1, len*yres, val1*len*yres, val2*len*yres); if (type & BAR_H) { for (i=0; i 0.0); } void process_init (void) { int i; load.overload=atof(cfg_get("overload")?:"2.0"); lcd_query (&rows, &cols, &xres, &yres, &supported_bars, &gpos); if (rows>ROWS) { error ("%d rows exceeds limit, reducing to %d rows", rows, ROWS); rows=ROWS; } if (gpos>GPOS) { error ("%d gpos exceeds limit, reducing to %d gpos", gpos, GPOS); gpos=GPOS; } debug ("%d rows, %d columns, %dx%d pixels, %d GPOs", rows, cols, xres, yres, gpos); for (i=1; i<=rows; i++) { char buffer[8], *p; snprintf (buffer, sizeof(buffer), "Row%d", i); p=cfg_get(buffer)?:""; debug ("%s: %s", buffer, p); row[i]=strdup(parse_row(p, supported_bars, token_usage)); } for (i=1; i<=gpos; i++) { char buffer[8], *p; snprintf (buffer, sizeof(buffer), "GPO%d", i); p=cfg_get(buffer)?:""; debug ("%s: %s", buffer, p); gpo[i]=parse_gpo(p, token_usage); } } void process (int smooth) { int i, val; char *txt; collect_data(); for (i=1; i<=rows; i++) { txt=process_row (i); if (smooth==0) lcd_put (i, 1, txt); } for (i=1; i<=gpos; i++) { val=process_gpo (i); lcd_gpo (i, val); } lcd_flush(); }