aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2003-10-22 04:19:16 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2003-10-22 04:19:16 +0000
commit76a717b70b1e3f7d58cefdfec3f647a17756d7e9 (patch)
treec6e95b153eca7b102da2f6c987f42594b329f47e
parent42441be6879253602a893b8421310053b25a1005 (diff)
downloadlcd4linux-76a717b70b1e3f7d58cefdfec3f647a17756d7e9.tar.gz
[lcd4linux @ 2003-10-22 04:19:16 by reinelt]
Makefile.in for imon.c/.h, some MatrixOrbital clients git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@267 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--Makefile.in8
-rw-r--r--MatrixOrbital.c108
-rw-r--r--icon.c7
-rw-r--r--lcd4linux.c29
4 files changed, 115 insertions, 37 deletions
diff --git a/Makefile.in b/Makefile.in
index 215a70b..5d6eae5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -101,7 +101,7 @@ AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall
lcd4linux_LDFLAGS = $(X_LIBS)
lcd4linux_LDADD = liblcd4linux.la @DRVLIBS@
-lcd4linux_SOURCES = lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h evaluator.c evaluator.h client.c client.h system.c system.h isdn.c isdn.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h widget.c widget.h exec.c exec.h mail2.c socket.c socket.h
+lcd4linux_SOURCES = lcd4linux.c pid.c pid.h parser.c parser.h processor.c processor.h evaluator.c evaluator.h client.c client.h system.c system.h isdn.c isdn.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h widget.c widget.h exec.c exec.h mail2.c socket.c socket.h imon.c imon.h
liblcd4linux_la_DEPENDENCIES = @DRIVERS@
@@ -140,7 +140,7 @@ lcd4linux_OBJECTS = lcd4linux.$(OBJEXT) pid.$(OBJEXT) parser.$(OBJEXT) \
processor.$(OBJEXT) evaluator.$(OBJEXT) client.$(OBJEXT) \
system.$(OBJEXT) isdn.$(OBJEXT) mail.$(OBJEXT) seti.$(OBJEXT) \
battery.$(OBJEXT) dvb.$(OBJEXT) filter.$(OBJEXT) widget.$(OBJEXT) \
-exec.$(OBJEXT) mail2.$(OBJEXT) socket.$(OBJEXT)
+exec.$(OBJEXT) mail2.$(OBJEXT) socket.$(OBJEXT) imon.$(OBJEXT)
lcd4linux_DEPENDENCIES = liblcd4linux.la
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -163,8 +163,8 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \
.deps/Skeleton.P .deps/T6963.P .deps/Text.P .deps/USBLCD.P \
.deps/XWindow.P .deps/bar.P .deps/battery.P .deps/cfg.P .deps/client.P \
.deps/debug.P .deps/display.P .deps/dvb.P .deps/evaluator.P \
-.deps/exec.P .deps/filter.P .deps/fontmap.P .deps/icon.P .deps/isdn.P \
-.deps/lcd4linux.P .deps/lock.P .deps/mail.P .deps/mail2.P \
+.deps/exec.P .deps/filter.P .deps/fontmap.P .deps/icon.P .deps/imon.P \
+.deps/isdn.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/processor.P .deps/seti.P .deps/socket.P .deps/system.P \
.deps/udelay.P .deps/widget.P
diff --git a/MatrixOrbital.c b/MatrixOrbital.c
index 2187276..74632aa 100644
--- a/MatrixOrbital.c
+++ b/MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: MatrixOrbital.c,v 1.46 2003/10/12 04:46:19 reinelt Exp $
+/* $Id: MatrixOrbital.c,v 1.47 2003/10/22 04:19:16 reinelt Exp $
*
* driver for Matrix Orbital serial display modules
*
@@ -22,6 +22,9 @@
*
*
* $Log: MatrixOrbital.c,v $
+ * Revision 1.47 2003/10/22 04:19:16 reinelt
+ * Makefile.in for imon.c/.h, some MatrixOrbital clients
+ *
* Revision 1.46 2003/10/12 04:46:19 reinelt
*
*
@@ -313,14 +316,14 @@ static int MO_open (void)
static int MO_read (char *string, int len)
{
- int ret;
-
+ int run, ret;
+
if (Device==-1) return -1;
- ret=read (Device, string, len);
- if (ret<0 && errno==EAGAIN) {
- debug ("read(): EAGAIN");
- usleep(10000);
+ 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) {
@@ -333,14 +336,26 @@ static int MO_read (char *string, int len)
static void MO_write (char *string, int len)
{
+ int run, ret;
+
if (Device==-1) return;
- if (write (Device, string, len)==-1) {
- if (errno==EAGAIN) {
- usleep(1000);
- if (write (Device, string, len)>=0) 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));
}
+
+ // Fixme
+ if (ret!=len) {
+ error ("MatrixOrbital: partial write: len=%d ret=%d", len, ret);
+ }
+
+ return;
}
@@ -458,17 +473,21 @@ static void client_gpo (RESULT *result, RESULT *arg1, RESULT *arg2)
num=R2N(arg1);
val=R2N(arg2);
- if (num<0.0) num=0.0;
- if (val<0.0) val=0.0;
+ if (num<1) num=1;
+ if (num>6) num=6;
+
+ if (val>=1.0) {
+ val=1.0;
+ } else {
+ val=0.0;
+ }
switch (protocol) {
case 1:
if (num==0) {
if (val>=1.0) {
- val=1.0;
MO_write ("\376W", 2); // GPO on
} else {
- val=0.0;
MO_write ("\376V", 2); // GPO off
}
} else {
@@ -479,16 +498,64 @@ static void client_gpo (RESULT *result, RESULT *arg1, RESULT *arg2)
case 2:
if (val>=1.0) {
- val=1.0;
cmd[1]='W'; // GPO on
} else {
- val=0.0;
cmd[1]='V'; // GPO off
}
cmd[2]=(char)num;
MO_write (cmd, 3);
break;
}
+
+ SetResult(&result, R_NUMBER, &val);
+}
+
+
+static void client_pwm (RESULT *result, RESULT *arg1, RESULT *arg2)
+{
+ int num;
+ double val;
+ char cmd[4]="\376\300";
+
+ num=R2N(arg1);
+ if (num<1) num=1;
+ if (num>6) num=6;
+ cmd[2]=(char)num;
+
+ val=R2N(arg2);
+ if (val< 0.0) val= 0.0;
+ if (val>255.0) val=255.0;
+ cmd[3]=(char)val;
+
+ MO_write (cmd, 4);
+
+ SetResult(&result, R_NUMBER, &val);
+}
+
+
+static void client_rpm (RESULT *result, RESULT *arg1)
+{
+ int num;
+ double val;
+ char cmd[3]="\376\301";
+ char buffer[7];
+
+ num=R2N(arg1);
+ if (num<1) num=1;
+ if (num>6) num=6;
+ cmd[2]=(char)num;
+
+ MO_write (cmd, 3);
+ usleep(100000);
+ MO_read (buffer, 7);
+
+ debug ("rpm: buffer[0]=0x%01x", buffer[0]);
+ debug ("rpm: buffer[1]=0x%01x", buffer[1]);
+ debug ("rpm: buffer[2]=0x%01x", buffer[2]);
+ debug ("rpm: buffer[3]=0x%01x", buffer[3]);
+ debug ("rpm: buffer[4]=0x%01x", buffer[4]);
+ debug ("rpm: buffer[5]=0x%01x", buffer[5]);
+ debug ("rpm: buffer[6]=0x%01x", buffer[6]);
SetResult(&result, R_NUMBER, &val);
}
@@ -522,7 +589,7 @@ static int MO_init (LCD *Self, int protocol)
}
Port=strdup(port);
- if (cfg_number("Speed", 19200, 1200,19200, &i)<0) return -1;
+ if (cfg_number("Speed", 19200, 1200, 19200, &i)<0) return -1;
switch (i) {
case 1200:
Speed=B1200;
@@ -593,10 +660,13 @@ static int MO_init (LCD *Self, int protocol)
AddFunction ("contrast", 1, client_contrast);
AddFunction ("backlight", 1, client_backlight);
AddFunction ("gpo", 2, client_gpo);
+ AddFunction ("pwm", 2, client_pwm);
+ AddFunction ("rpm", 1, client_rpm);
return 0;
}
+
int MO_init1 (LCD *Self)
{
return MO_init(Self, 1);
diff --git a/icon.c b/icon.c
index d65a8c4..1fc5d78 100644
--- a/icon.c
+++ b/icon.c
@@ -1,4 +1,4 @@
-/* $Id: icon.c,v 1.9 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: icon.c,v 1.10 2003/10/22 04:19:16 reinelt Exp $
*
* generic icon and heartbeat handling
*
@@ -22,6 +22,9 @@
*
*
* $Log: icon.c,v $
+ * Revision 1.10 2003/10/22 04:19:16 reinelt
+ * Makefile.in for imon.c/.h, some MatrixOrbital clients
+ *
* Revision 1.9 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -186,7 +189,7 @@ void icon_clear(void)
for (n=0; n<ROWS*COLS; n++) {
Screen[n]=-1;
}
-
+
}
diff --git a/lcd4linux.c b/lcd4linux.c
index 9af5a6a..271373e 100644
--- a/lcd4linux.c
+++ b/lcd4linux.c
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.49 2003/10/11 06:01:53 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.50 2003/10/22 04:19:16 reinelt Exp $
*
* LCD4Linux
*
@@ -22,6 +22,9 @@
*
*
* $Log: lcd4linux.c,v $
+ * Revision 1.50 2003/10/22 04:19:16 reinelt
+ * Makefile.in for imon.c/.h, some MatrixOrbital clients
+ *
* Revision 1.49 2003/10/11 06:01:53 reinelt
*
* renamed expression.{c,h} to client.{c,h}
@@ -495,12 +498,6 @@ int main (int argc, char *argv[])
exit (1);
}
- // now install our own signal handler
- signal(SIGHUP, handler);
- signal(SIGINT, handler);
- signal(SIGQUIT, handler);
- signal(SIGTERM, handler);
-
// process_init sets global vars tick, tack
process_init();
@@ -512,11 +509,13 @@ int main (int argc, char *argv[])
printf("\neval> ");
for(fgets(line, 1024, stdin); !feof(stdin); fgets(line, 1024, stdin)) {
if (line[strlen(line)-1]=='\n') line[strlen(line)-1]='\0';
- Eval(line, &result);
- if (result.type==R_NUMBER) {
- printf ("%g\n", R2N(&result));
- } else if (result.type==R_STRING) {
- printf ("'%s'\n", R2S(&result));
+ if (strlen(line)>0) {
+ Eval(line, &result);
+ if (result.type==R_NUMBER) {
+ printf ("%g\n", R2N(&result));
+ } else if (result.type==R_STRING) {
+ printf ("'%s'\n", R2S(&result));
+ }
}
printf("eval> ");
}
@@ -534,6 +533,12 @@ int main (int argc, char *argv[])
debug ("starting main loop");
+ // now install our own signal handler
+ signal(SIGHUP, handler);
+ signal(SIGINT, handler);
+ signal(SIGQUIT, handler);
+ signal(SIGTERM, handler);
+
while (got_signal==0) {
process ();
usleep(tack*1000);