aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile.am1
-rw-r--r--Makefile.in32
-rw-r--r--plugin.c6
-rw-r--r--plugin_dvb.c137
4 files changed, 160 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am
index 718b5fd..2826a9f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,6 +39,7 @@ plugin_cpuinfo.c \
plugin_meminfo.c \
plugin_netdev.c \
plugin_ppp.c \
+plugin_dvb.c \
plugin_i2c_sensors.c \
plugin_xmms.c \
system.c system.h \
diff --git a/Makefile.in b/Makefile.in
index 4a08afc..1dcc66e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -106,7 +106,7 @@ lcd4linux_LDADD = @DRIVERS@ @DRVLIBS@
#remove next line for liblcd4linux
lcd4linux_DEPENDENCIES = @DRIVERS@
-lcd4linux_SOURCES = lcd4linux.c pid.c pid.h hash.c hash.h parser.c parser.h processor.c processor.h layout.c layout.h timer.c timer.h evaluator.c evaluator.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c plugin_uname.c plugin_loadavg.c plugin_proc_stat.c plugin_cpuinfo.c plugin_meminfo.c plugin_netdev.c plugin_ppp.c plugin_i2c_sensors.c plugin_xmms.c system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h display.c display.h drv.c drv.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_text.c drv_generic_text.h debug.c debug.h cfg.c cfg.h lock.c lock.h pixmap.c pixmap.h bar.c bar.h icon.c icon.h fontmap.c fontmap.h udelay.c udelay.h
+lcd4linux_SOURCES = lcd4linux.c pid.c pid.h hash.c hash.h parser.c parser.h processor.c processor.h layout.c layout.h timer.c timer.h evaluator.c evaluator.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c plugin_uname.c plugin_loadavg.c plugin_proc_stat.c plugin_cpuinfo.c plugin_meminfo.c plugin_netdev.c plugin_ppp.c plugin_dvb.c plugin_i2c_sensors.c plugin_xmms.c system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h display.c display.h drv.c drv.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_text.c drv_generic_text.h debug.c debug.h cfg.c cfg.h lock.c lock.h pixmap.c pixmap.h bar.c bar.h icon.c icon.h fontmap.c fontmap.h udelay.c udelay.h
#liblcd4linux_la_DEPENDENCIES = @DRIVERS@
@@ -154,14 +154,15 @@ plugin_math.$(OBJEXT) plugin_string.$(OBJEXT) plugin_cfg.$(OBJEXT) \
plugin_uname.$(OBJEXT) plugin_loadavg.$(OBJEXT) \
plugin_proc_stat.$(OBJEXT) plugin_cpuinfo.$(OBJEXT) \
plugin_meminfo.$(OBJEXT) plugin_netdev.$(OBJEXT) plugin_ppp.$(OBJEXT) \
-plugin_i2c_sensors.$(OBJEXT) plugin_xmms.$(OBJEXT) system.$(OBJEXT) \
-isdn.$(OBJEXT) wifi.$(OBJEXT) mail.$(OBJEXT) seti.$(OBJEXT) \
-battery.$(OBJEXT) dvb.$(OBJEXT) filter.$(OBJEXT) exec.$(OBJEXT) \
-expr.$(OBJEXT) mail2.$(OBJEXT) socket.$(OBJEXT) imon.$(OBJEXT) \
-display.$(OBJEXT) drv.$(OBJEXT) drv_generic_serial.$(OBJEXT) \
-drv_generic_parport.$(OBJEXT) drv_generic_text.$(OBJEXT) \
-debug.$(OBJEXT) cfg.$(OBJEXT) lock.$(OBJEXT) pixmap.$(OBJEXT) \
-bar.$(OBJEXT) icon.$(OBJEXT) fontmap.$(OBJEXT) udelay.$(OBJEXT)
+plugin_dvb.$(OBJEXT) plugin_i2c_sensors.$(OBJEXT) plugin_xmms.$(OBJEXT) \
+system.$(OBJEXT) isdn.$(OBJEXT) wifi.$(OBJEXT) mail.$(OBJEXT) \
+seti.$(OBJEXT) battery.$(OBJEXT) dvb.$(OBJEXT) filter.$(OBJEXT) \
+exec.$(OBJEXT) expr.$(OBJEXT) mail2.$(OBJEXT) socket.$(OBJEXT) \
+imon.$(OBJEXT) display.$(OBJEXT) drv.$(OBJEXT) \
+drv_generic_serial.$(OBJEXT) drv_generic_parport.$(OBJEXT) \
+drv_generic_text.$(OBJEXT) debug.$(OBJEXT) cfg.$(OBJEXT) lock.$(OBJEXT) \
+pixmap.$(OBJEXT) bar.$(OBJEXT) icon.$(OBJEXT) fontmap.$(OBJEXT) \
+udelay.$(OBJEXT)
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -189,12 +190,13 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \
.deps/imon.P .deps/isdn.P .deps/layout.P .deps/lcd4linux.P .deps/lock.P \
.deps/mail.P .deps/mail2.P .deps/parport.P .deps/parser.P .deps/pid.P \
.deps/pixmap.P .deps/plugin.P .deps/plugin_cfg.P .deps/plugin_cpuinfo.P \
-.deps/plugin_i2c_sensors.P .deps/plugin_loadavg.P .deps/plugin_math.P \
-.deps/plugin_meminfo.P .deps/plugin_netdev.P .deps/plugin_ppp.P \
-.deps/plugin_proc_stat.P .deps/plugin_string.P .deps/plugin_uname.P \
-.deps/plugin_xmms.P .deps/processor.P .deps/seti.P .deps/socket.P \
-.deps/system.P .deps/timer.P .deps/udelay.P .deps/widget.P \
-.deps/widget_bar.P .deps/widget_icon.P .deps/widget_text.P .deps/wifi.P
+.deps/plugin_dvb.P .deps/plugin_i2c_sensors.P .deps/plugin_loadavg.P \
+.deps/plugin_math.P .deps/plugin_meminfo.P .deps/plugin_netdev.P \
+.deps/plugin_ppp.P .deps/plugin_proc_stat.P .deps/plugin_string.P \
+.deps/plugin_uname.P .deps/plugin_xmms.P .deps/processor.P .deps/seti.P \
+.deps/socket.P .deps/system.P .deps/timer.P .deps/udelay.P \
+.deps/widget.P .deps/widget_bar.P .deps/widget_icon.P \
+.deps/widget_text.P .deps/wifi.P
SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(lcd4linux_OBJECTS)
diff --git a/plugin.c b/plugin.c
index e87fc86..24c9cb5 100644
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.16 2004/01/29 04:40:02 reinelt Exp $
+/* $Id: plugin.c,v 1.17 2004/02/10 06:54:39 reinelt Exp $
*
* plugin handler for the Evaluator
*
@@ -22,6 +22,9 @@
*
*
* $Log: plugin.c,v $
+ * Revision 1.17 2004/02/10 06:54:39 reinelt
+ * DVB plugin ported
+ *
* Revision 1.16 2004/01/29 04:40:02 reinelt
* every .c file includes "config.h" now
*
@@ -152,6 +155,7 @@ int plugin_init (void)
plugin_init_meminfo();
plugin_init_netdev();
plugin_init_ppp();
+ plugin_init_dvb();
plugin_init_i2c_sensors();
plugin_init_xmms();
diff --git a/plugin_dvb.c b/plugin_dvb.c
new file mode 100644
index 0000000..b44f396
--- /dev/null
+++ b/plugin_dvb.c
@@ -0,0 +1,137 @@
+/* $Id: plugin_dvb.c,v 1.1 2004/02/10 06:54:39 reinelt Exp $
+ *
+ * plugin for DVB status
+ *
+ * Copyright 2003 Michael Reinelt <reinelt@eunet.at>
+ * Copyright 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ *
+ * This file is part of LCD4Linux.
+ *
+ * LCD4Linux 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.
+ *
+ * LCD4Linux 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: plugin_dvb.c,v $
+ * Revision 1.1 2004/02/10 06:54:39 reinelt
+ * DVB plugin ported
+ *
+ */
+
+/*
+ * exported functions:
+ *
+ * int plugin_init_dvb (void)
+ * adds dvb() function
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <linux/dvb/frontend.h>
+
+#include "debug.h"
+#include "plugin.h"
+#include "hash.h"
+
+static char *frontend="/dev/dvb/adapter0/frontend0";
+
+static HASH DVB = { 0, };
+
+static int get_dvb_stats (void)
+{
+ int age;
+ int fd;
+ unsigned short snr, sig;
+ unsigned long ber, ucb;
+ char val[16];
+
+ // reread every 1000 msec only
+ age=hash_age(&DVB, NULL, NULL);
+ if (age>0 && age<=1000) return 0;
+
+ // open frontend
+ fd = open(frontend, O_RDONLY);
+ if (fd==-1) {
+ error ("open(%s) failed: %s", frontend, strerror(errno));
+ return -1;
+ }
+
+ if (ioctl(fd, FE_READ_SIGNAL_STRENGTH, &sig)!=0) {
+ error("ioctl(FE_READ_SIGNAL_STRENGTH) failed: %s", strerror(errno));
+ sig=0;
+ }
+
+ if (ioctl(fd, FE_READ_SNR, &snr)!=0) {
+ error("ioctl(FE_READ_SNR) failed: %s", strerror(errno));
+ snr=0;
+ }
+
+ if (ioctl(fd, FE_READ_BER, &ber)!=0) {
+ error("ioctl(FE_READ_BER) failed: %s", strerror(errno));
+ ber=0;
+ }
+
+ if (ioctl(fd, FE_READ_UNCORRECTED_BLOCKS, &ucb)!=0) {
+ error("ioctl(FE_READ_UNCORRECTED_BLOCKS) failed: %s", strerror(errno));
+ ucb=0;
+ }
+
+ close (fd);
+
+ snprintf (val, sizeof(val), "%f", sig/65535.0);
+ hash_set (&DVB, "signal_strength", val);
+
+ snprintf (val, sizeof(val), "%f", snr/65535.0);
+ hash_set (&DVB, "snr", val);
+
+ snprintf (val, sizeof(val), "%lu", ber);
+ hash_set (&DVB, "ber", val);
+
+ snprintf (val, sizeof(val), "%lu", ucb);
+ hash_set (&DVB, "uncorrected_blocks", val);
+
+ return 0;
+}
+
+
+static void my_dvb (RESULT *result, RESULT *arg1)
+{
+ char *val;
+
+ if (get_dvb_stats()<0) {
+ SetResult(&result, R_STRING, "");
+ return;
+ }
+
+ val=hash_get(&DVB, R2S(arg1));
+ if (val==NULL) val="";
+
+ SetResult(&result, R_STRING, val);
+}
+
+int plugin_init_dvb (void)
+{
+ AddFunction ("dvb", 3, my_dvb);
+ return 0;
+}
+