From f5fca64371bdb7ffa1ca2c4d9bc0a49731dd39c1 Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Tue, 20 Jan 2004 14:25:12 +0000 Subject: [lcd4linux @ 2004-01-20 14:25:12 by reinelt] some reorganization moved drv_generic to drv_generic_serial moved port locking stuff to drv_generic_serial --- Makefile.am | 4 +- Makefile.in | 16 ++--- drv_MatrixOrbital.c | 45 +++----------- drv_generic.c | 168 ---------------------------------------------------- drv_generic.h | 52 ---------------- drv_generic_text.c | 9 ++- widget_bar.c | 9 ++- 7 files changed, 32 insertions(+), 271 deletions(-) delete mode 100644 drv_generic.c delete mode 100644 drv_generic.h diff --git a/Makefile.am b/Makefile.am index 180a9e5..7c1759e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -54,8 +54,8 @@ imon.c imon.h \ \ display.c display.h \ drv.c drv.h \ -drv_generic.c drv_generic.h \ -drv_generic_text.c drv_generic_text.h \ +drv_generic_serial.c drv_generic_serial.h \ +drv_generic_text.c drv_generic_text.h \ debug.c debug.h \ cfg.c cfg.h \ lock.c lock.h \ diff --git a/Makefile.in b/Makefile.in index 609db6c..fcec677 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 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_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.c drv_generic.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 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_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_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@ @@ -157,7 +157,7 @@ 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.$(OBJEXT) \ +display.$(OBJEXT) drv.$(OBJEXT) drv_generic_serial.$(OBJEXT) \ drv_generic_text.$(OBJEXT) debug.$(OBJEXT) cfg.$(OBJEXT) lock.$(OBJEXT) \ pixmap.$(OBJEXT) bar.$(OBJEXT) icon.$(OBJEXT) fontmap.$(OBJEXT) \ udelay.$(OBJEXT) @@ -181,12 +181,12 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \ .deps/MilfordInstruments.P .deps/PalmPilot.P .deps/Raster.P .deps/SIN.P \ .deps/T6963.P .deps/Text.P .deps/USBLCD.P .deps/XWindow.P .deps/bar.P \ .deps/battery.P .deps/cfg.P .deps/debug.P .deps/display.P .deps/drv.P \ -.deps/drv_MatrixOrbital.P .deps/drv_generic.P .deps/drv_generic_text.P \ -.deps/dvb.P .deps/evaluator.P .deps/exec.P .deps/expr.P .deps/filter.P \ -.deps/fontmap.P .deps/hash.P .deps/icon.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/drv_MatrixOrbital.P .deps/drv_generic_serial.P \ +.deps/drv_generic_text.P .deps/dvb.P .deps/evaluator.P .deps/exec.P \ +.deps/expr.P .deps/filter.P .deps/fontmap.P .deps/hash.P .deps/icon.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_proc_stat.P .deps/plugin_string.P \ .deps/plugin_uname.P .deps/plugin_xmms.P .deps/processor.P .deps/seti.P \ diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c index 706dda9..2a8be1f 100644 --- a/drv_MatrixOrbital.c +++ b/drv_MatrixOrbital.c @@ -1,4 +1,4 @@ -/* $Id: drv_MatrixOrbital.c,v 1.12 2004/01/20 12:45:47 reinelt Exp $ +/* $Id: drv_MatrixOrbital.c,v 1.13 2004/01/20 14:25:12 reinelt Exp $ * * new style driver for Matrix Orbital serial display modules * @@ -23,6 +23,11 @@ * * * $Log: drv_MatrixOrbital.c,v $ + * Revision 1.13 2004/01/20 14:25:12 reinelt + * some reorganization + * moved drv_generic to drv_generic_serial + * moved port locking stuff to drv_generic_serial + * * Revision 1.12 2004/01/20 12:45:47 reinelt * "Default screen" working with MatrixOrbital * @@ -86,20 +91,16 @@ #include #include #include -#include #include -#include -#include #include "debug.h" #include "cfg.h" #include "plugin.h" -#include "lock.h" #include "widget.h" #include "widget_text.h" #include "widget_bar.h" #include "drv.h" -#include "drv_generic.h" +#include "drv_generic_serial.h" #include "drv_generic_text.h" @@ -182,8 +183,7 @@ static int drv_MO_start (char *section) { int i; char *model; - char *port, buffer[256]; - speed_t speed; + char buffer[256]; model=cfg_get(section, "Model", NULL); if (model!=NULL && *model!='\0') { @@ -202,34 +202,7 @@ static int drv_MO_start (char *section) } - port=cfg_get(section, "Port", NULL); - if (port==NULL || *port=='\0') { - error ("%s: no '%s.Port' entry from %s", Name, section, cfg_source()); - return -1; - } - - if (cfg_number(section, "Speed", 19200, 1200, 19200, &i)<0) return -1; - switch (i) { - case 1200: - speed=B1200; - break; - case 2400: - speed=B2400; - break; - case 9600: - speed=B9600; - break; - case 19200: - speed=B19200; - break; - default: - error ("%s: unsupported speed '%d' from %s", Name, i, cfg_source()); - return -1; - } - - info ("%s: using port '%s' at %d baud", Name, port, i); - - if (drv_generic_serial_open(Name, port, speed)<0) return -1; + if (drv_generic_serial_open(section, Name)<0) return -1; // read module type drv_generic_serial_write ("\3767", 2); diff --git a/drv_generic.c b/drv_generic.c deleted file mode 100644 index fbec1e9..0000000 --- a/drv_generic.c +++ /dev/null @@ -1,168 +0,0 @@ -/* $Id: drv_generic.c,v 1.2 2004/01/20 05:36:59 reinelt Exp $ - * - * generic driver helper for text- and graphic-based displays - * - * Copyright 1999, 2000 Michael Reinelt - * Copyright 2004 The LCD4Linux Team - * - * 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: drv_generic.c,v $ - * Revision 1.2 2004/01/20 05:36:59 reinelt - * moved text-display-specific stuff to drv_generic_text - * moved all the bar stuff from drv_generic_bar to generic_text - * - * Revision 1.1 2004/01/20 04:51:39 reinelt - * moved generic stuff from drv_MatrixOrbital to drv_generic - * implemented new-stylish bars which are nearly finished - * - */ - -/* - * - * exported fuctions: - * - * Fixme: document me! - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" -#include "cfg.h" -#include "plugin.h" -#include "lock.h" -#include "widget.h" -#include "widget_text.h" -#include "widget_bar.h" -#include "drv.h" -#include "drv_generic.h" - - -static char *Driver; -static char *Port; -static speed_t Speed; -static int Device=-1; - - -// **************************************** -// *** generic serial/USB communication *** -// **************************************** - -int drv_generic_serial_open (char *driver, char *port, speed_t speed) -{ - int fd; - pid_t pid; - struct termios portset; - - Driver = driver; - Port = port; - Speed = speed; - - if ((pid=lock_port(port))!=0) { - if (pid==-1) - error ("%s: port %s could not be locked", Driver, Port); - else - error ("%s: port %s is locked by process %d", Driver, Port, pid); - return -1; - } - - fd = open(Port, O_RDWR | O_NOCTTY | O_NDELAY); - if (fd==-1) { - error ("%s: open(%s) failed: %s", Driver, Port, strerror(errno)); - unlock_port(Port); - return -1; - } - - if (tcgetattr(fd, &portset)==-1) { - error ("%s: tcgetattr(%s) failed: %s", Driver, Port, strerror(errno)); - unlock_port(Port); - return -1; - } - - cfmakeraw(&portset); - cfsetospeed(&portset, Speed); - if (tcsetattr(fd, TCSANOW, &portset)==-1) { - error ("%s: tcsetattr(%s) failed: %s", Driver, Port, strerror(errno)); - unlock_port(Port); - return -1; - } - - Device=fd; - return Device; -} - - -int drv_generic_serial_read (char *string, int len) -{ - int run, ret; - - if (Device==-1) return -1; - for (run=0; run<10; run++) { - ret=read (Device, string, len); - if (ret>=0 || errno!=EAGAIN) break; - debug ("read(): EAGAIN"); - usleep(1000); - } - - if (ret<0) { - error("%s: read(%s, %d) failed: %s", Driver, Port, len, strerror(errno)); - } else if (ret!=len) { - error ("%s: partial read: len=%d ret=%d", Driver, len, ret); - } - - return ret; -} - - -void drv_generic_serial_write (char *string, int len) -{ - int run, ret; - - if (Device==-1) return; - for (run=0; run<10; run++) { - ret=write (Device, string, len); - if (ret>=0 || errno!=EAGAIN) break; - debug ("write(): EAGAIN"); - usleep(1000); - } - - if (ret<0) { - error ("MatrixOrbital: write(%s) failed: %s", Port, strerror(errno)); - } else if (ret!=len) { - error ("MatrixOrbital: partial write: len=%d ret=%d", len, ret); - } - - return; -} - - -int drv_generic_serial_close (void) -{ - debug ("%s: closing port %s", Driver, Port); - close (Device); - unlock_port(Port); - return 0; -} - diff --git a/drv_generic.h b/drv_generic.h deleted file mode 100644 index 52d53d4..0000000 --- a/drv_generic.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $Id: drv_generic.h,v 1.2 2004/01/20 05:36:59 reinelt Exp $ - * - * generic driver helper for text- and graphic-based displays - * - * Copyright 1999, 2000 Michael Reinelt - * Copyright 2004 The LCD4Linux Team - * - * 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: drv_generic.h,v $ - * Revision 1.2 2004/01/20 05:36:59 reinelt - * moved text-display-specific stuff to drv_generic_text - * moved all the bar stuff from drv_generic_bar to generic_text - * - * Revision 1.1 2004/01/20 04:51:39 reinelt - * moved generic stuff from drv_MatrixOrbital to drv_generic - * implemented new-stylish bars which are nearly finished - * - */ - -/* - * - * exported fuctions: - * - * Fixme: document me! - * - */ - -#ifndef _DRV_GENERIC_H_ -#define _DRV_GENERIC_H_ - -int drv_generic_serial_open (char *driver, char *port, speed_t speed); -int drv_generic_serial_read (char *string, int len); -void drv_generic_serial_write (char *string, int len); -int drv_generic_serial_close (void); - -#endif diff --git a/drv_generic_text.c b/drv_generic_text.c index 2de0c29..0ba2f10 100644 --- a/drv_generic_text.c +++ b/drv_generic_text.c @@ -1,4 +1,4 @@ -/* $Id: drv_generic_text.c,v 1.2 2004/01/20 12:45:47 reinelt Exp $ +/* $Id: drv_generic_text.c,v 1.3 2004/01/20 14:25:12 reinelt Exp $ * * generic driver helper for text-based displays * @@ -23,6 +23,11 @@ * * * $Log: drv_generic_text.c,v $ + * Revision 1.3 2004/01/20 14:25:12 reinelt + * some reorganization + * moved drv_generic to drv_generic_serial + * moved port locking stuff to drv_generic_serial + * * Revision 1.2 2004/01/20 12:45:47 reinelt * "Default screen" working with MatrixOrbital * @@ -51,12 +56,10 @@ #include "debug.h" #include "cfg.h" #include "plugin.h" -#include "lock.h" #include "widget.h" #include "widget_text.h" #include "widget_bar.h" #include "drv.h" -#include "drv_generic.h" #include "drv_generic_text.h" diff --git a/widget_bar.c b/widget_bar.c index 65cb748..ab93ea5 100644 --- a/widget_bar.c +++ b/widget_bar.c @@ -1,4 +1,4 @@ -/* $Id: widget_bar.c,v 1.3 2004/01/20 12:45:47 reinelt Exp $ +/* $Id: widget_bar.c,v 1.4 2004/01/20 14:25:12 reinelt Exp $ * * bar widget handling * @@ -21,6 +21,11 @@ * * * $Log: widget_bar.c,v $ + * Revision 1.4 2004/01/20 14:25:12 reinelt + * some reorganization + * moved drv_generic to drv_generic_serial + * moved port locking stuff to drv_generic_serial + * * Revision 1.3 2004/01/20 12:45:47 reinelt * "Default screen" working with MatrixOrbital * @@ -140,7 +145,7 @@ int widget_bar_init (WIDGET *Self) // sanity check if (B->expression1==NULL || *B->expression1=='\0') { - error ("widget %s has no expression, using '0.0'", Self->name, c); + error ("widget %s has no expression, using '0.0'", Self->name); B->expression1="0"; } -- cgit v1.2.3