Removed thermometers program and directory. Version 0.4.3

Fri, 18 Sep 2015 12:55:49 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 18 Sep 2015 12:55:49 +0200
changeset 407
ee8f851b4d93
parent 406
44566f986f76
child 408
ec507c1f1df7

Removed thermometers program and directory. Version 0.4.3

configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermometers/Makefile file | annotate | diff | comparison | revisions
thermometers/lcd-pcf8574.c file | annotate | diff | comparison | revisions
thermometers/rdconfig.c file | annotate | diff | comparison | revisions
thermometers/thermometers.c file | annotate | diff | comparison | revisions
thermometers/thermometers.h file | annotate | diff | comparison | revisions
thermometers/xutil.c file | annotate | diff | comparison | revisions
--- a/configure	Thu Sep 17 20:54:34 2015 +0200
+++ b/configure	Fri Sep 18 12:55:49 2015 +0200
@@ -582,7 +582,7 @@
 PACKAGE_BUGREPORT=
 PACKAGE_URL=
 
-ac_unique_file="thermometers/thermometers.c"
+ac_unique_file="thermferm/thermferm.c"
 ac_default_prefix=/usr/local
 # Factoring default headers for most tests.
 ac_includes_default="\
@@ -2030,11 +2030,11 @@
 
 ac_config_headers="$ac_config_headers config.h"
 
-SUBDIRS="dht11 rc433 thermferm thermometers"
+SUBDIRS="dht11 rc433 thermferm"
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.4.2"
+VERSION="0.4.3"
 COPYRIGHT="Copyright (C) 2014-2015 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2015"
 
--- a/configure.ac	Thu Sep 17 20:54:34 2015 +0200
+++ b/configure.ac	Fri Sep 18 12:55:49 2015 +0200
@@ -1,14 +1,14 @@
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT(thermometers/thermometers.c)
+AC_INIT(thermferm/thermferm.c)
 AM_CONFIG_HEADER(config.h)
-SUBDIRS="dht11 rc433 thermferm thermometers"
+SUBDIRS="dht11 rc433 thermferm"
 AC_SUBST(SUBDIRS)
 
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.4.2"
+VERSION="0.4.3"
 COPYRIGHT="Copyright (C) 2014-2015 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2015"
 AC_SUBST(PACKAGE)
--- a/thermometers/Makefile	Thu Sep 17 20:54:34 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-# Makefile for the mbsePi-apps/thermometers.
-
-include ../Makefile.global
-
-SRCS		= $(wildcard *.c)
-HDRS		= $(wildcard *.h)
-OBJS		= $(SRCS:.c=.o)
-TARGET		= thermometers
-OTHER		= Makefile
-
-#############################################################################
-
-.c.o:
-		${CC} ${CFLAGS} ${INCLUDES} ${DEFINES} -c $<
-
-all:		${TARGET}
-
-thermometers:	${OBJS}
-		${CC} -o thermometers ${OBJS} ${LDFLAGS} ${LIBS}
-
-clean:
-		rm -f ${TARGET} *.o *.h~ *.c~ core filelist Makefile.bak
-
-install:	all
-		${INSTALL} -c -s -g root -o root -m 0755 thermometers ${BINDIR}
-
-filelist:	Makefile
-		BASE=`pwd`; \
-		BASE=`basename $${BASE}`; \
-		(for f in ${SRCS} ${HDRS} ${OTHER} ;do echo ${PACKAGE}-${VERSION}/$${BASE}/$$f; done) >filelist
-
-depend:
-	@rm -f Makefile.bak; \
-	mv Makefile Makefile.bak; \
-	sed -e '/^# DO NOT DELETE/,$$d' Makefile.bak >Makefile; \
-	${ECHO} '# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT' \
-		>>Makefile; \
-	${ECHO} '# Dependencies generated by make depend' >>Makefile; \
-	for f in ${SRCS}; \
-	do \
-		${ECHO} "Dependencies for $$f:\c"; \
-		${ECHO} "`basename $$f .c`.o:\c" >>Makefile; \
-		for h in `sed -n -e \
-			's/^#[ 	]*include[ 	]*"\([^"]*\)".*/\1/p' $$f`; \
-		do \
-			${ECHO} " $$h\c"; \
-			${ECHO} " $$h\c" >>Makefile; \
-		done; \
-		${ECHO} " done."; \
-		${ECHO} "" >>Makefile; \
-	done; \
-	${ECHO} '# End of generated dependencies' >>Makefile
-
-# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
-# Dependencies generated by make depend
-thermometers.o: thermometers.h
-lcd-pcf8574.o: thermometers.h
-xutil.o: thermometers.h
-rdconfig.o: thermometers.h
-# End of generated dependencies
--- a/thermometers/lcd-pcf8574.c	Thu Sep 17 20:54:34 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * lcd-pcf8574.c:
- *	Text-based LCD driver library code
- *	This is designed to drive the HD44780U LCD display connected via
- *	a "LCM1602 IIC  A0 A1 A2" board with a PCF8574 I2C controller.
- *
- * Copyright (c) 2012-2013 Gordon Henderson.
- * Copyright (c) 2014 Michiel Broek.
- ***********************************************************************
- *
- *    mbsePi is free software: you can redistribute it and/or modify
- *    it under the terms of the GNU Lesser General Public License as published by
- *    the Free Software Foundation, either version 3 of the License, or
- *    (at your option) any later version.
- *
- *    mbsePi 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 Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU Lesser General Public License
- *    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
- ***********************************************************************
- */
-
-#include "thermometers.h"
-
-#ifdef HAVE_WIRINGPI_H
-
-int			lcdHandle;
-unsigned char		lcdbuf[MAX_LCDS][20][4];
-
-struct lcdDataStruct
-{
-    int bits, rows, cols ;
-    int rsPin, strbPin ;
-    int dataPins [8] ;
-    int cx, cy ;
-};
-extern struct lcdDataStruct	*lcds [MAX_LCDS];
-
-
-/*
- * Some LCD functions are extended shadow copies of the wiringPi functions.
- * The difference is that the lcdbuf will be updated with the contents on
- * the hardware display. This copy can then be used for a remote display
- */
-
-
-/*
- * setBacklight:
- *********************************************************************************
- */
-
-void setBacklight (int value)
-{
-  pinMode (AF_BACKLIGHT, OUTPUT) ;
-  digitalWrite (AF_BACKLIGHT, (value & 1)) ;
-}
-
-
-
-/*
- * initLCD:
- *********************************************************************************
- */
-
-int initLCD (int cols, int rows)
-{
-    int	x, y;
-
-    if (!((rows == 1) || (rows == 2) || (rows == 4))) {
-    	fprintf (stderr, "rows must be 1, 2 or 4\n") ;
-    	return EXIT_FAILURE ;
-    }
-
-    if (!((cols == 16) || (cols == 20))) {
-    	fprintf (stderr, "cols must be 16 or 20\n") ;
-    	return EXIT_FAILURE ;
-    }
-
-    pcf8574Setup(AF_BASE, 0x27) ;
-    pinMode (AF_RW, OUTPUT) ;
-    digitalWrite (AF_RW, LOW) ;        // Not used with wiringPi - always in write mode
-
-    /*
-     * The other control pins are initialised with lcdInit ()
-     */
-    lcdHandle = lcdInit (rows, cols, 4, AF_RS, AF_E, AF_DB4, AF_DB5, AF_DB6, AF_DB7, 0, 0, 0, 0) ;
-    if (lcdHandle < 0) {
-    	fprintf (stderr, "lcdInit failed\n") ;
-    	return -1 ;
-    }
-
-    lcdClear (lcdHandle) ;
-    for (x = 0; x < 20; x++)
-	for (y = 0; y < 4; y++)
-	    lcdbuf[lcdHandle][x][y] = ' ';
-
-    setBacklight (1) ;
-
-    return 0 ;
-}
-
-
-
-void mb_lcdPutchar(const int fd, unsigned char data)
-{
-    struct lcdDataStruct *lcd = lcds[fd];
-
-    /*
-     * Write to our buffer first, then to the wiringPi driver.
-     * Writing to wiringPi updates the cursor position.
-     */
-    lcdbuf[fd][lcd->cx][lcd->cy] = data;
-    lcdPutchar(fd, data);
-}
-
-
-
-void mb_lcdPuts(const int fd, const char *string)
-{
-    while (*string)
-	mb_lcdPutchar (fd, *string++);
-}
-
-
-
-void mb_lcdClear(const int fd)
-{
-    int	x, y;
-
-    lcdClear(fd);
-    for (x = 0; x < 20; x++)
-	for (y = 0; y < 4; y++)
-	    lcdbuf[fd][x][y] = ' ';
-}
-
-
-
-#endif
-
--- a/thermometers/rdconfig.c	Thu Sep 17 20:54:34 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,331 +0,0 @@
-/*****************************************************************************
- * Copyright (C) 2014
- *   
- * Michiel Broek <mbroek at mbse dot eu>
- *
- * This file is part of the mbsePi-apps
- *
- * This 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.
- *
- * mbsePi-apps 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 EC-65K; see the file COPYING.  If not, write to the Free
- * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *****************************************************************************/
-
-#include "thermometers.h"
-
-
-int		debug = FALSE;
-static char	*mypath;
-static char	*k, *v;
-static int	linecnt = 0;
-sys_config	Config;			/* System configuration		*/
-
-
-
-static int getw1(char **);
-#ifdef HAVE_WIRINGPI_H
-static int getint(char **);
-static int getrcs(char **);
-#endif
-
-#define XSTR(x) #x
-#define STR(x) XSTR(x)
-
-/*
- * System configuration table
- */
-key_list keytab[] = {
-    {(char *)"w1therm",		getw1,		(char **)&Config.w1therms},
-#ifdef HAVE_WIRINGPI_H
-    {(char *)"lcd_cols",	getint,		(char **)&Config.lcd_cols},
-    {(char *)"lcd_rows",	getint,		(char **)&Config.lcd_rows},
-    {(char *)"rx433",		getint,		(char **)&Config.rx433},
-    {(char *)"tx433",		getint,		(char **)&Config.tx433},
-    {(char *)"rcswitch",	getrcs,		(char **)&Config.rcswitch},
-#endif
-    {NULL,			NULL,		NULL}
-};
-
-
-
-void killconfig(void)
-{
-    w1_therm	*tmp1, *old1;
-#ifdef HAVE_WIRINGPI_H
-    rc_switch	*tmp2, *old2;
-#endif
-
-    if (Config.name)
-	free(Config.name);
-    Config.name = NULL;
-
-    for (tmp1 = Config.w1therms; tmp1; tmp1 = old1) {
-	old1 = tmp1->next;
-	if (tmp1->master)
-	    free(tmp1->master);
-	if (tmp1->name)
-	    free(tmp1->name);
-	if (tmp1->alias)
-	    free(tmp1->alias);
-	free(tmp1);
-    }
-    Config.w1therms = NULL;
-    Config.my_port = 6554;
-
-#ifdef HAVE_WIRINGPI_H
-    Config.lcd_cols = 16;
-    Config.lcd_rows = 2;
-    Config.rx433 = -1;
-    Config.tx433 = -1;
-
-    for (tmp2 = Config.rcswitch; tmp2; tmp2 = old2) {
-	old2 = tmp2->next;
-	if (tmp2->address)
-	    free(tmp2->address);
-	tmp2->address = NULL;
-	if (tmp2->alias)
-	    free(tmp2->alias);
-	tmp2->alias = NULL;
-	free(tmp2);
-    }
-    Config.rcswitch = NULL;
-
-#endif
-}
-
-
-
-int rdconfig(char *config) 
-{
-    char	buf[256], *p;
-    FILE	*fp;
-    int		i, rc = 0;
-
-    killconfig();
-
-    /*
-     * Search config file
-     */
-    mypath = xstrcpy(getenv((char *)"HOME"));
-    mypath = xstrcat(mypath, (char *)"/mbsepi-apps/");
-    mypath = xstrcat(mypath, config);
-    if ((fp = fopen(mypath, "r")) == NULL) {
-	/*
-	 * Not in the users home directory
-	 */
-	free(mypath);
-	mypath = xstrcpy((char *)"/etc/mbsepi-apps/");
-	mypath = xstrcat(mypath, config);
-	if ((fp = fopen(mypath, "r")) == NULL) {
-	    /*
-	     * Try /usr/local/etc
-	     */
-	    free(mypath);
-	    mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/");
-	    mypath = xstrcat(mypath, config);
-	    if ((fp = fopen(mypath, "r")) == NULL) {
-		syslog(LOG_NOTICE, "rdconfig: could not open %s", mypath);
-		return 1;
-	    }
-	}
-    }
-
-    linecnt = 0;
-    while (fgets(buf, sizeof(buf) -1, fp)) {
-	linecnt++;
-	if (*(p = buf + strlen(buf) -1) != '\n') {
-	    syslog(LOG_NOTICE, "rdconfig: %s(%d): \"%s\" - line too long", mypath, linecnt, buf);
-	    rc = 1;
-	    break;
-	}
-	*p-- = '\0';
-	while ((p >= buf) && isspace(*p))
-	    *p-- = '\0';
-	k = buf;
-	while (*k && isspace(*k))
-	    k++;
-	p = k;
-	while (*p && !isspace(*p))
-	    p++;
-	*p++='\0';
-	v = p;
-	while (*v && isspace(*v)) 
-	    v++;
-
-	if ((*k == '\0') || (*k == '#')) {
-	    continue;
-	}
-
-	for (i = 0; keytab[i].key; i++)
-	    if (strcasecmp(k,keytab[i].key) == 0)
-		break;
-
-	if (keytab[i].key == NULL) {
-	    syslog(LOG_NOTICE, "rdconfig: %s(%d): %s %s - unknown keyword", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
-	    rc = 1;
-	    break;
-	} else if ((keytab[i].prc(keytab[i].dest))) {
-	    rc = 1;
-	    break;
-	}
-
-    }
-    fclose(fp);
-
-    free(mypath);
-    mypath = NULL;
-
-    return rc;
-}
-
-
-
-#ifdef HAVE_WIRINGPI_H
-static int getint(char **dest)
-{
-    if (debug)
-	syslog(LOG_NOTICE, "rdconfig: getint: %s(%d): %s %s", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
-
-    if (strspn(v,"0123456789") != strlen(v)) 
-	syslog(LOG_NOTICE, "rdconfig: %s(%d): %s %s - bad numeric", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
-    else 
-	*((int*)dest)=atoi(v);
-    return 0;
-}
-#endif
-
-
-
-static int getw1(char **dest)
-{
-    char	*p, *q = NULL, *r = NULL;
-    w1_therm	**tmpm;
-    int		rc = 0, tmpp;
-
-    for (p = v; *p && !isspace(*p); p++);
-    if (*p)
-	*p++ = '\0';
-    while (*p && isspace(*p))
-	p++;
-    if (*p == '\0') {
-	syslog(LOG_NOTICE, "rdconfig: %s(%d): less then two tokens", mypath, linecnt);
-	return 1;
-    }
-
-    for (q = p; *q && !isspace(*q); q++);
-    if (*q && isspace(*q)) {
-	if (*q)
-	    *q++ = '\0';
-	while (*q && isspace(*q))
-	    q++;
-
-	for (r = q; *r && !isspace(*r); r++);
-	if (*r)
-	    *r++ = '\0';
-	rc = sscanf(p, "%d", &tmpp);
-	if (rc != 1) {
-	    syslog(LOG_NOTICE, "rdconfig: getw1: %s(%d): %s is not a integer value", mypath, linecnt, p);
-	    return 1;
-	}
-	if (debug)
-	    syslog(LOG_NOTICE, "rdconfig: getw1: %s(%d): %s %d %s %s", mypath, linecnt, v, tmpp, q, r);
-    }
-
-    for (tmpm = (w1_therm**)dest; *tmpm; tmpm=&((*tmpm)->next));
-    (*tmpm) = (w1_therm *) xmalloc(sizeof(w1_therm));
-    (*tmpm)->next = NULL;
-    (*tmpm)->master = xstrcpy(v);
-    (*tmpm)->bus = tmpp;
-    (*tmpm)->name = xstrcpy(q);
-    (*tmpm)->alias = xstrcpy(r);
-    (*tmpm)->present = 0;
-    (*tmpm)->lastval = 0;
-    (*tmpm)->update = 0;
-
-    return 0;
-}
-
-
-
-#ifdef HAVE_WIRINGPI_H
-static int getrcs(char **dest)
-{
-    char        *p, *q = NULL, *r = NULL;
-    rc_switch   **tmpm;
-
-    for (p = v; *p && !isspace(*p); p++);
-	if (*p)
-	    *p++ = '\0';
-    while (*p && isspace(*p))
-	p++;
-    if (*p == '\0') {
-	syslog(LOG_NOTICE, "rdconfig: %s(%d): less then two tokens", mypath, linecnt);
-	return 1;
-    }
-
-    for (q = p; *q && !isspace(*q); q++);
-    if (*q && isspace(*q)) {
-	if (*q)
-	    *q++ = '\0';
-	while (*q && isspace(*q))
-	    q++;
-
-	for (r = q; *r && !isspace(*r); r++);
-	if (*r)
-	    *r++ = '\0';
-	if (debug)
-	    syslog(LOG_NOTICE, "rdconfig: getrcs: %s(%d): %s %s", mypath, linecnt, v, p);
-    }
-
-    for (tmpm = (rc_switch**)dest; *tmpm; tmpm=&((*tmpm)->next));
-    (*tmpm) = (rc_switch *) xmalloc(sizeof(rc_switch));
-    (*tmpm)->next = NULL;
-    (*tmpm)->address = xstrcpy(v);
-    (*tmpm)->alias = xstrcpy(p);
-
-    return 0;
-}
-#endif
-
-
-/*
-static int getbyt(char **dest)
-{
-    Log_Msg("[rdconfig] getbyt: %s(%d): %s %s", mypath, linecnt, k, v);
-    if (strspn(v,"0123456789") != strlen(v))
-	Log_Msg("[rdconfig] %s(%d): %s %s - bad numeric", mypath, linecnt, S(k), S(v));
-    else
-	*((Uint8*)dest)=atoi(v);
-    return 0;
-}
-*/
-
-
-/*
-static int gethex(char **dest)
-{
-    unsigned int    val = 0;
-    int		    rc;
-
-    Log_Msg("[rdconfig] gethex: %s(%d): %s %s", mypath, linecnt, k, v);
-    rc = sscanf(v, "%08x", &val);
-    if (rc != 1) {
-	Log_Msg("[rdconfig] %s(%d): %s %s - bad hex value", mypath, linecnt, S(k), S(v));
-	return 1;
-    }
-    *((int*)dest) = val;
-
-    return 0;
-}
-*/
-
-
--- a/thermometers/thermometers.c	Thu Sep 17 20:54:34 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,317 +0,0 @@
-/*****************************************************************************
- * Copyright (C) 2014
- *   
- * Michiel Broek <mbroek at mbse dot eu>
- *
- * This file is part of the mbsePi-apps
- *
- * This 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.
- *
- * mbsePi-apps 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 EC-65K; see the file COPYING.  If not, write to the Free
- * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *****************************************************************************/
-
-#include "thermometers.h"
-
-
-static int		my_shutdown = FALSE;
-static pid_t		pgrp, mypid;
-
-extern int		debug;
-extern sys_config	Config;
-#ifdef HAVE_WIRINGPI_H
-extern int		lcdHandle;
-#endif
-
-int server(void);
-void help(void);
-void die(int);
-
-
-void help(void)
-{
-    fprintf(stdout, "mbsePi-apps thermometers v%s starting\n\n", VERSION);
-    fprintf(stdout, "Usage: thermomeneters [-d] [-h]\n");
-    fprintf(stdout, "  -d --debug              Debug and run in foreground\n");
-    fprintf(stdout, "  -h --help               Display this help\n");
-}
-
-
-
-void die(int onsig)
-{
-    switch (onsig) {
-	case SIGHUP:	syslog(LOG_NOTICE, "Got SIGHUP, shutting down");
-			break;
-	case SIGINT:	syslog(LOG_NOTICE, "Keyboard interrupt, shutting down");
-			break;
-	case SIGTERM:	syslog(LOG_NOTICE, "Got SIGTERM, shutting down");
-			break;
-	default:	syslog(LOG_NOTICE, "die() on signal %d", onsig);
-    }
-
-    my_shutdown = TRUE;
-}
-
-
-
-#ifdef HAVE_WIRINGPI_H
-void stopLCD(void)
-{
-   lcdClear(lcdHandle);
-   setBacklight(0);
-}
-#endif
-
-
-
-int main(int argc, char *argv[])
-{
-    int		rc, c, i;
-    pid_t	frk;
-#ifdef HAVE_WIRINGPI_H
-    char	buf[80];
-#endif
-
-    while (1) {
-	int option_index = 0;
-	static struct option long_options[] = {
-	    {"debug", 0, 0, 'c'},
-	    {"help", 0, 0, 'h'},
-	    {0, 0, 0, 0}
-	};
-
-	c = getopt_long(argc, argv, "dh", long_options, &option_index);
-	if (c == -1)
-	    break;
-
-	switch (c) {
-	    case 'd':	debug = TRUE;
-			break;
-	    case 'h':	help();
-			return 1;
-	}
-    }
-
-    openlog("thermometers", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER);
-    syslog(LOG_NOTICE, "mbsePi-apps thermometers v%s starting", VERSION);
-    if (debug)
-	fprintf(stdout, "mbsePi-apps thermometers v%s starting\n", VERSION);
-
-    if (rdconfig((char *)"thermometers.conf")) {
-	fprintf(stderr, "Error reading configuration\n");
-	syslog(LOG_NOTICE, "Error reading configuration, halted");
-	return 1;
-    }
-
-    /*
-     *  Catch all the signals we can, and ignore the rest. Note that SIGKILL can't be ignored
-     *  but that's live. This daemon should only be stopped by SIGTERM.
-     *  Don't catch SIGCHLD.
-     */
-    for (i = 0; i < NSIG; i++) {
-    	if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP))
-	    signal(i, (void (*))die);
-    }
-
-#ifdef HAVE_WIRINGPI_H
-
-    if (wiringPiSetup () )
-	return 1;
-
-    if ((rc = initLCD (16, 2))) {
-	fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc);
-	return 1;
-    }
-
-    lcdPosition(lcdHandle, 0, 0);
-    lcdPuts(lcdHandle, "Thermometers");
-    lcdPosition(lcdHandle, 0, 1);
-    sprintf(buf, "Version %s", VERSION);
-    lcdPuts(lcdHandle, buf);
-#endif
-
-    if (debug) {
-	/*
-	 * For debugging run in foreground.
-	 */
-	rc = server();
-    } else {
-	/*
-	 * Server initialization is complete. Now we can fork the 
-	 * daemon and return to the user. We need to do a setpgrp
-	 * so that the daemon will no longer be assosiated with the
-	 * users control terminal. This is done before the fork, so
-	 * that the child will not be a process group leader. Otherwise,
-	 * if the child were to open a terminal, it would become
-	 * associated with that terminal as its control terminal.
-	 */
-	if ((pgrp = setpgid(0, 0)) == -1) {
-	    syslog(LOG_NOTICE, "setpgpid failed");
-	}
-
-	frk = fork();
-	switch (frk) {
-	    case -1:	
-		    	syslog(LOG_NOTICE, "Daemon fork failed: %s", strerror(errno));
-			syslog(LOG_NOTICE, "Finished, rc=1");
-#ifdef HAVE_WIRINGPI_H
-			stopLCD();
-#endif
-			exit(1);
-	    case 0:	/*
-			 * Run the daemon
-			 */
-			fclose(stdin);
-			if (open("/dev/null", O_RDONLY) != 0) {
-			    syslog(LOG_NOTICE, "Reopen of stdin to /dev/null failed");
-			    _exit(2);
-			}
-			fclose(stdout);
-			if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 1) {
-			    syslog(LOG_NOTICE, "Reopen of stdout to /dev/null failed");
-			    _exit(2);
-			}
-			fclose(stderr);
-			if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 2) {
-			    syslog(LOG_NOTICE, "Reopen of stderr to /dev/null failed");
-			    _exit(2);
-			}
-			mypid = getpid();
-			rc = server();
-			break;
-			/* Not reached */
-	    default:
-			/*
-			 * Here we detach this process and let the child
-			 * run the deamon process.
-			 */
-			syslog(LOG_NOTICE, "Starting daemon with pid %d", frk);
-			exit(0);
-	}
-    }
-
-    syslog(LOG_NOTICE, "Finished, rc=%d", rc);
-    return rc;
-}
-
-
-
-int server(void)
-{
-    int                 temp, rc = 0;
-#ifdef HAVE_WIRINGPI_H
-    char		buf[1024];
-    int			lcdupdate;
-#endif
-    w1_therm		*tmp1;
-    char		*device, line[60], *p = NULL;
-    FILE		*fp;
-
-    if (debug)
-	fprintf(stdout, (char *)"Enter loop\n");
-
-    do {
-#ifdef HAVE_WIRINGPI_H
-	    lcdupdate = FALSE;
-#endif
-
-	    /*
-	     * Here send our 1-wire sensors values
-	     */
-	    for (tmp1 = Config.w1therms; tmp1; tmp1 = tmp1->next) {
-
-		/*
-		 * Build path and alias topic
-		 */
-		device = xstrcpy((char *)"/sys/bus/w1/devices/");
-		device = xstrcat(device, tmp1->master);
-		device = xstrcat(device, (char *)"/");
-		device = xstrcat(device, tmp1->name);
-		device = xstrcat(device, (char *)"/w1_slave");
-
-		/*
-		 * Read sensor data
-		 */
-		if ((fp = fopen(device, "r"))) {
-		    /*
-		     * The output looks like:
-		     * 72 01 4b 46 7f ff 0e 10 57 : crc=57 YES
-		     * 72 01 4b 46 7f ff 0e 10 57 t=23125
-		     */
-		    fgets(line, 50, fp);
-		    line[strlen(line)-1] = '\0';
-		    if ((line[36] == 'Y') && (line[37] == 'E')) {
-			/*
-			 * CRC is Ok, continue
-			 */
-		    	fgets(line, 50, fp);
-			line[strlen(line)-1] = '\0';
-			strtok(line, (char *)"=");
-			p = strtok(NULL, (char *)"=");
-			rc = sscanf(p, "%d", &temp);
-			if ((rc == 1) && (tmp1->lastval != temp)) {
-			    tmp1->lastval = temp;
-#ifdef HAVE_WIRINGPI_H
-			    lcdupdate = TRUE;
-#endif
-			}
-		    } else {
-			syslog(LOG_NOTICE, "sensor %s/%s CRC error", tmp1->master, tmp1->name);
-		    }
-		    fclose(fp);
-		    tmp1->present = 1;
-		} else {
-		    tmp1->present = 0;
-		    if (debug)
-		    	printf("sensor %s is missing\n", tmp1->name);
-		}
-
-		free(device);
-		device = NULL;
-	    }
-
-#ifdef HAVE_WIRINGPI_H
-	    if (lcdupdate) {
-		lcdPosition(lcdHandle, 0, 0);
-		tmp1 = Config.w1therms;
-		snprintf(buf, 16, "%5.1f %cC %s            ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias);
-		lcdPuts(lcdHandle, buf);
-		tmp1 = tmp1->next;
-		lcdPosition(lcdHandle, 0, 1);
-		snprintf(buf, 16, "%5.1f %cC %s            ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias);
-		lcdPuts(lcdHandle, buf);
-	    }
-#endif
-
-	    if (my_shutdown) {
-#ifdef HAVE_WIRINGPI_H
-		lcdClear(lcdHandle);
-		lcdPosition(lcdHandle, 0, 0);
-		lcdPuts(lcdHandle, "Shuting down ...");
-#endif
-	    }
-
-	    usleep(100000);
-
-    } while (! my_shutdown);
-
-    if (debug)
-	fprintf(stdout, (char *)"Out of loop\n");
-
-#ifdef HAVE_WIRINGPI_H
-    stopLCD();
-#endif
-
-    return rc;
-}
-
--- a/thermometers/thermometers.h	Thu Sep 17 20:54:34 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-#ifndef	_THERMOMETERS_H
-#define	_THERMOMETERS_H
-
-
-#define TRUE 1
-#define FALSE 0
-
-#include "../config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <time.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <errno.h>
-#include <signal.h>
-#include <getopt.h>
-#include <limits.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <poll.h>
-
-
-/* mosquitto */
-//#include <mosquitto.h>
-
-#ifdef HAVE_WIRINGPI_H
-/* wiringPi */
-#include <wiringPi.h>
-#include <pcf8574.h>
-#include <lcd.h>
-
-#endif
-
-#define TRUE 1
-#define FALSE 0
-
-#define MBSE_SS(x) (x)?(x):"(null)"
-
-/* rdconfig.c */
-typedef struct _key_list {
-    char	*key;
-    int		(*prc)(char **);
-    char	**dest;
-} key_list;
-
-typedef struct _w1_therm {
-    struct _w1_therm    *next;
-    char                *master;                /* Master for this device       */
-    int                 bus;                    /* Reserved for ds2482-800      */
-    char                *name;                  /* Name of this device          */
-    char                *alias;                 /* Friendly name                */
-    int                 present;                /* 1=present, 0=absent          */
-    int                 lastval;                /* Last valid value             */
-    int			update;			/* Value updated		*/
-} w1_therm;
-
-typedef struct _rc_switch {
-    struct _rc_switch	*next;
-    char		*address;		/* Address code			*/
-    char		*alias;			/* Friendly name		*/
-} rc_switch;
-
-typedef struct _sys_config {
-    char		*name;			/* Configuration name		*/
-    int			my_port;		/* my client/server port	*/
-    w1_therm		*w1therms;		/* 1-wire temp sensors		*/
-#ifdef HAVE_WIRINGPI_H
-    int			lcd_cols;		/* LCD display columns		*/
-    int			lcd_rows;		/* LCD display rows		*/
-    int			rx433;			/* 433 MHz receiver pin		*/
-    int			tx433;			/* 433 MHz transmitter pin	*/
-    rc_switch		*rcswitch;		/* 433 MHz RC Power switches	*/
-#endif
-} sys_config;
-
-
-void killconfig(void);
-int  rdconfig(char *);
-
-
-/* xutil.c */
-char *xmalloc(size_t);
-char *xstrcpy(char *);
-char *xstrcat(char *, char *);
-
-
-#ifdef HAVE_WIRINGPI_H
-
-/* lcd-pcf8574.c */
-// Defines for the pcf8574 Pi LCD interface board
-#define AF_BASE         100
-
-#define AF_RS           (AF_BASE + 0)
-#define AF_RW           (AF_BASE + 1)
-#define AF_E            (AF_BASE + 2)
-#define AF_BACKLIGHT    (AF_BASE + 3)
-#define AF_DB4          (AF_BASE + 4)
-#define AF_DB5          (AF_BASE + 5)
-#define AF_DB6          (AF_BASE + 6)
-#define AF_DB7          (AF_BASE + 7)
-
-void setBacklight (int);
-int  initLCD (int, int);
-void mb_lcdPutchar(const int, unsigned char);
-void mb_lcdPuts(const int, const char *);
-void mb_lcdClear(const int);
-
-
-
-#endif
-
-
-#endif
-
--- a/thermometers/xutil.c	Thu Sep 17 20:54:34 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*****************************************************************************
- * Copyright (C) 2008-2014
- *   
- * Michiel Broek <mbroek at mbse dot eu>
- *
- * This file is part of the mbsePi-apps
- *
- * This 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.
- *
- * mbsePi-apps 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 EC-65K; see the file COPYING.  If not, write to the Free
- * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *****************************************************************************/
-
-#include "thermometers.h"
-
-
-char *xmalloc(size_t size)
-{
-    char *tmp;
-
-    tmp = malloc(size);
-    if (!tmp) 
-	abort();
-			            
-    return tmp;
-}
-
-
-
-char *xstrcpy(char *src)
-{
-    char    *tmp;
-
-    if (src == NULL) 
-	return(NULL);
-    tmp = xmalloc(strlen(src)+1);
-    strcpy(tmp, src);
-    return tmp;
-}
-
-
-
-char *xstrcat(char *src, char *add)
-{
-    char    *tmp;
-    size_t  size = 0;
-
-    if ((add == NULL) || (strlen(add) == 0))
-	return src;
-    if (src)
-	size = strlen(src);
-    size += strlen(add);
-    tmp = xmalloc(size + 1);
-    *tmp = '\0';
-    if (src) {
-	strcpy(tmp, src);
-	free(src);
-    }
-    strcat(tmp, add);
-    return tmp;
-}
-
-

mercurial