diff options
-rw-r--r-- | drv_Cwlinux.c | 27 | ||||
-rw-r--r-- | drv_generic_serial.c | 36 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 11 | ||||
-rw-r--r-- | plugin_i2c_sensors.c | 67 | ||||
-rw-r--r-- | plugin_pop3.c | 47 |
5 files changed, 111 insertions, 77 deletions
diff --git a/drv_Cwlinux.c b/drv_Cwlinux.c index dac2f61..67fc053 100644 --- a/drv_Cwlinux.c +++ b/drv_Cwlinux.c @@ -1,4 +1,4 @@ -/* $Id: drv_Cwlinux.c,v 1.9 2004/05/31 16:39:06 reinelt Exp $ +/* $Id: drv_Cwlinux.c,v 1.10 2004/05/31 21:05:13 reinelt Exp $ * * new style driver for Cwlinux display modules * @@ -23,6 +23,13 @@ * * * $Log: drv_Cwlinux.c,v $ + * Revision 1.10 2004/05/31 21:05:13 reinelt + * + * fixed lots of bugs in the Cwlinux driver + * do not emit EAGAIN error on the first retry + * made plugin_i2c_sensors a bit less 'chatty' + * moved init and exit functions to the bottom of plugin_pop3 + * * Revision 1.9 2004/05/31 16:39:06 reinelt * * added NULL display driver (for debugging/profiling purposes) @@ -141,7 +148,7 @@ static void drv_CW1602_defchar (int ascii, unsigned char *buffer) int i; char cmd[12]="\376Nn12345678\375"; - cmd[2]=(char)(ascii+1); + cmd[2]=(char)ascii; for (i=0; i<8; i++) { cmd[3+i] = buffer[i] & 0x1f; @@ -156,7 +163,7 @@ static void drv_CW12232_defchar (int ascii, unsigned char *buffer) int i, j; char cmd[10]="\376Nn123456\375"; - cmd[2]=(char)(ascii+1); + cmd[2]=(char)ascii; // The CW12232 uses a vertical bitmap layout, // so we have to 'rotate' the bitmap. @@ -227,7 +234,7 @@ static int drv_CW_start (char *section) } // open serial port - if (drv_generic_serial_open(section, Name, 0)<0) return -1; + if (drv_generic_serial_open(section, Name, 0) < 0) return -1; // this does not work as I'd expect it... #if 0 @@ -337,10 +344,14 @@ int drv_CW_init (char *section) // display preferences XRES = 6; // pixel width of one char YRES = 8; // pixel height of one char - CHARS = 8; // number of user-defineable characters - CHAR0 = 128; // ASCII of first user-defineable char + CHARS = 16; // number of user-defineable characters + CHAR0 = 1; // ASCII of first user-defineable char GOTO_COST = 3; // number of bytes a goto command requires + // start display + if ((ret=drv_CW_start (section))!=0) + return ret; + // real worker functions drv_generic_text_real_write = drv_CW_write; @@ -353,10 +364,6 @@ int drv_CW_init (char *section) break; } - // start display - if ((ret=drv_CW_start (section))!=0) - return ret; - // initialize generic text driver if ((ret=drv_generic_text_init(section, Name))!=0) return ret; diff --git a/drv_generic_serial.c b/drv_generic_serial.c index c60c18f..1c52c77 100644 --- a/drv_generic_serial.c +++ b/drv_generic_serial.c @@ -1,4 +1,4 @@ -/* $Id: drv_generic_serial.c,v 1.9 2004/05/28 13:51:42 reinelt Exp $ +/* $Id: drv_generic_serial.c,v 1.10 2004/05/31 21:05:13 reinelt Exp $ * * generic driver helper for serial and usbserial displays * @@ -23,6 +23,13 @@ * * * $Log: drv_generic_serial.c,v $ + * Revision 1.10 2004/05/31 21:05:13 reinelt + * + * fixed lots of bugs in the Cwlinux driver + * do not emit EAGAIN error on the first retry + * made plugin_i2c_sensors a bit less 'chatty' + * moved init and exit functions to the bottom of plugin_pop3 + * * Revision 1.9 2004/05/28 13:51:42 reinelt * * ported driver for Beckmann+Egle Mini-Terminals @@ -301,6 +308,7 @@ int drv_generic_serial_open (char *section, char *driver, unsigned int flags) cfmakeraw(&portset); portset.c_cflag |= flags; + cfsetispeed(&portset, Speed); cfsetospeed(&portset, Speed); if (tcsetattr(fd, TCSANOW, &portset)==-1) { error ("%s: tcsetattr(%s) failed: %s", Driver, Port, strerror(errno)); @@ -316,9 +324,9 @@ int drv_generic_serial_open (char *section, char *driver, unsigned int flags) int drv_generic_serial_poll (unsigned char *string, int len) { int ret; - if (Device==-1) return -1; + if (Device == -1) return -1; ret=read (Device, string, len); - if (ret<0 && errno!=EAGAIN) { + if (ret < 0 && errno != EAGAIN) { error("%s: read(%s) failed: %s", Driver, Port, strerror(errno)); } return ret; @@ -329,14 +337,14 @@ int drv_generic_serial_read (unsigned char *string, int len) { int run, ret; - for (run=0; run<10; run++) { - ret=drv_generic_serial_poll(string, len); - if (ret>=0 || errno!=EAGAIN) break; + for (run = 0; run < 10; run ++) { + ret = drv_generic_serial_poll(string, len); + if (ret >= 0 || errno != EAGAIN) break; info ("%s: read(%s): EAGAIN", Driver, Port); usleep(1000); } - if (ret>0 && ret!=len) { + if (ret > 0 && ret != len) { error ("%s: partial read(%s): len=%d ret=%d", Driver, Port, len, ret); } @@ -348,17 +356,17 @@ void drv_generic_serial_write (unsigned 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; - info ("%s: write(%s): EAGAIN", Driver, Port); + if (Device == -1) return; + for (run = 0; run < 10; run++) { + ret = write (Device, string, len); + if (ret >= 0 || errno != EAGAIN) break; + if (run > 0) info ("%s: write(%s): EAGAIN #%d", Driver, Port, run); usleep(1000); } - if (ret<0) { + if (ret < 0) { error ("%s: write(%s) failed: %s", Driver, Port, strerror(errno)); - } else if (ret!=len) { + } else if (ret != len) { error ("%s: partial write(%s): len=%d ret=%d", Driver, Port, len, ret); } diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index b61807d..5e92190 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -16,6 +16,16 @@ Display MI240 { } +Display CW12232 { + Driver 'Cwlinux' + Model 'CW12232' + Port '/dev/usb/tts/0' + Speed 19200 + Brightness 2 + Icons 1 +} + + Display CF631 { Driver 'Crystalfontz' Model '631' @@ -513,6 +523,7 @@ Layout testMySQL { #Display 'LK204' #Display 'MI240' +#Display 'CW12232' #Display 'HD44780-20x4' #Display 'M50530-24x8' #Display 'CF631' diff --git a/plugin_i2c_sensors.c b/plugin_i2c_sensors.c index 70e03dc..01bef64 100644 --- a/plugin_i2c_sensors.c +++ b/plugin_i2c_sensors.c @@ -1,4 +1,4 @@ -/* $Id: plugin_i2c_sensors.c,v 1.14 2004/05/09 05:41:42 reinelt Exp $ +/* $Id: plugin_i2c_sensors.c,v 1.15 2004/05/31 21:05:13 reinelt Exp $ * * I2C sensors plugin * @@ -23,6 +23,13 @@ * * * $Log: plugin_i2c_sensors.c,v $ + * Revision 1.15 2004/05/31 21:05:13 reinelt + * + * fixed lots of bugs in the Cwlinux driver + * do not emit EAGAIN error on the first retry + * made plugin_i2c_sensors a bit less 'chatty' + * moved init and exit functions to the bottom of plugin_pop3 + * * Revision 1.14 2004/05/09 05:41:42 reinelt * * i2c fix for kernel 2.6.5 (temp_input1 vs. temp1_input) from Xavier @@ -122,6 +129,7 @@ #include <string.h> #include <stdio.h> #include <unistd.h> +#include <errno.h> #include <fcntl.h> #include <dirent.h> @@ -163,14 +171,14 @@ static int parse_i2c_sensors_sysfs(char *key) stream=fopen(file, "r"); if (stream==NULL) { - error ("fopen(%s) failed",file); + error ("i2c_sensors: fopen(%s) failed: %s", file, strerror(errno)); return -1; } fgets (buffer, sizeof(buffer), stream); fclose (stream); if (!buffer) { - error ("%s empty ?!",file); + error ("i2c_sensors: %s empty ?!", file); return -1; } @@ -215,7 +223,7 @@ static int parse_i2c_sensors_procfs(char *key) char final_key[32]; char *number = &key[strlen(key)-1]; int tokens_index; - //debug("%s -> %s", key, number); + // debug("%s -> %s", key, number); strcpy(file, path); if (!strncmp(key, "temp_", 5)) { @@ -240,27 +248,27 @@ static int parse_i2c_sensors_procfs(char *key) stream=fopen(file, "r"); if (stream==NULL) { - error ("fopen(%s) failed",file); + error ("i2c_sensors: fopen(%s) failed: %s", file, strerror(errno)); return -1; } fgets (buffer, sizeof(buffer), stream); fclose (stream); if (!buffer) { - error ("%s empty ?!",file); + error ("i2c_sensors: %s empty ?!",file); return -1; } running=strdupa(buffer); while(1) { value = strsep (&running, delim); - debug("%s pos %i -> %s", file, pos , value); + // debug("%s pos %i -> %s", file, pos , value); if (!value || !strcmp(value, "")) { - debug("%s pos %i -> BREAK", file, pos); + // debug("%s pos %i -> BREAK", file, pos); break; } else { sprintf (final_key, "%s%s", procfs_tokens[tokens_index][pos], number); - debug ("%s -> %s", final_key, value); + // debug ("%s -> %s", final_key, value); hash_set (&I2Csensors, final_key, value); pos++; } @@ -312,11 +320,6 @@ void my_i2c_sensors_path(char *method) fd1 = opendir(base); if (!fd1) { - if (!strcmp(method, "sysfs")) { - error("[i2c_sensors] Impossible to open %s! Is /sys mounted?", base); - } else if (!strcmp(method, "procfs")) { - error("[i2c_sensors] Impossible to open %s! Is i2c_proc loaded ?", base); - } return; } @@ -336,7 +339,8 @@ void my_i2c_sensors_path(char *method) fd2 = opendir(dname); done = 0; while((file = readdir(fd2))) { - if (!strcmp(file->d_name, "temp_input1") || !strcmp(file->d_name, "temp1_input") || !strcmp(file->d_name, "temp1")) { // FIXME : do all sensors have a temp_input1 ? + // FIXME : do all sensors have a temp_input1 ? + if (!strcmp(file->d_name, "temp_input1") || !strcmp(file->d_name, "temp1_input") || !strcmp(file->d_name, "temp1")) { path = realloc(path, strlen(dname)+1); strcpy(path, dname); done=1; @@ -352,47 +356,42 @@ void my_i2c_sensors_path(char *method) int plugin_init_i2c_sensors (void) { - char *path_cfg=cfg_get(NULL, "i2c_sensors-path", ""); + char *path_cfg = cfg_get(NULL, "i2c_sensors-path", ""); - if (strncmp(path_cfg, "/", 1)) { - //debug("No path to i2c sensors found in the conf, calling my_i2c_sensors_path()"); + if (path_cfg == NULL || *path_cfg == '\0') { + // debug("No path to i2c sensors found in the conf, calling my_i2c_sensors_path()"); my_i2c_sensors_path("sysfs"); if (!path) my_i2c_sensors_path("procfs"); - + if (!path) { - error("[i2c_sensors] No i2c sensors found via the i2c interface !"); - error("[i2c_sensors] Try to specify the path to the sensors !"); + error("i2c_sensors: unable to autodetect i2c sensors!"); } else { - debug("Your i2c sensors are probably in %s", path); - debug("if i2c_sensors doesn't work, try to specify the path in your conf"); + debug("using i2c sensors at %s (autodetected)", path); } - } else { if (path_cfg[strlen(path_cfg)-1] != '/') { // the headless user forgot the trailing slash :/ - debug("adding a trailing slash at the end of the path"); + error("i2c_sensors: please add a trailing slash to %s from %s", path_cfg, cfg_source()); path_cfg = realloc(path_cfg, strlen(path_cfg)+2); strcat(path_cfg, "/"); } - debug("Path to i2c sensors from the conf : %s", path_cfg); - debug("if i2c_sensors doesn't work, double check this value !"); + debug("using i2c sensors at %s (from %s)", path, cfg_source()); path = realloc(path, strlen(path_cfg)+1); strcpy(path, path_cfg); - } - free(path_cfg); - + if (path_cfg) free(path_cfg); + // we activate the function only if there's a possibly path found if (path!=NULL) { if (strncmp(path, "/sys", 4)==0) { - parse_i2c_sensors=parse_i2c_sensors_sysfs; + parse_i2c_sensors = parse_i2c_sensors_sysfs; AddFunction ("i2c_sensors", 1, my_i2c_sensors); } else if (strncmp(path, "/proc", 5)==0) { - parse_i2c_sensors=parse_i2c_sensors_procfs; + parse_i2c_sensors = parse_i2c_sensors_procfs; AddFunction ("i2c_sensors", 1, my_i2c_sensors); } else { - error("[i2c_sensors] unknown path %s, should start with /sys or /proc"); + error("i2c_sensors: unknown path %s, should start with /sys or /proc"); } } @@ -401,5 +400,5 @@ int plugin_init_i2c_sensors (void) void plugin_exit_i2c_sensors(void) { - hash_destroy(&I2Csensors); + hash_destroy(&I2Csensors); } diff --git a/plugin_pop3.c b/plugin_pop3.c index e93ae91..166db8f 100644 --- a/plugin_pop3.c +++ b/plugin_pop3.c @@ -1,4 +1,4 @@ -/* $Id: plugin_pop3.c,v 1.3 2004/05/20 07:14:46 reinelt Exp $ +/* $Id: plugin_pop3.c,v 1.4 2004/05/31 21:05:13 reinelt Exp $ * * Plugin to check POP3 mail accounts * @@ -27,6 +27,13 @@ * * * $Log: plugin_pop3.c,v $ + * Revision 1.4 2004/05/31 21:05:13 reinelt + * + * fixed lots of bugs in the Cwlinux driver + * do not emit EAGAIN error on the first retry + * made plugin_i2c_sensors a bit less 'chatty' + * moved init and exit functions to the bottom of plugin_pop3 + * * Revision 1.3 2004/05/20 07:14:46 reinelt * made all local functions static * @@ -173,24 +180,6 @@ static int getConfig (void) return(n); } -int plugin_init_pop3(void) -{ - - int n = getConfig(); - // by now, head should point to a list of all our accounts - if (head) - { - info("[POP3] %d POP3 accounts have been succesfully defined",n); - AddFunction ("POP3check", 1, my_POP3check); - } - return 0; -} - -void plugin_exit_pop3(void) -{ - check_destroy(&head); -} - // ************************ LIST *********************************** static struct check *check_node_alloc(void) { @@ -341,3 +330,23 @@ static int tcp_connect(struct check *hi) return(sockfd); } + + +int plugin_init_pop3(void) +{ + + int n = getConfig(); + // by now, head should point to a list of all our accounts + if (head) + { + info("[POP3] %d POP3 accounts have been succesfully defined",n); + AddFunction ("POP3check", 1, my_POP3check); + } + return 0; +} + +void plugin_exit_pop3(void) +{ + check_destroy(&head); +} + |