Fixed compiling for systems with wiringPi. Improved handling of udp sockets if there is no brewpanel running.

Sun, 15 Nov 2015 21:12:11 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 15 Nov 2015 21:12:11 +0100
changeset 423
02653162b03b
parent 422
13502d0dda65
child 424
d5e36ca9085f

Fixed compiling for systems with wiringPi. Improved handling of udp sockets if there is no brewpanel running.

thermferm/slcd.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/slcd.c	Sat Nov 14 23:40:51 2015 +0100
+++ b/thermferm/slcd.c	Sun Nov 15 21:12:11 2015 +0100
@@ -60,14 +60,18 @@
 	return;
 
     if (sendto(sock, &data, sizeof(uint16_t), 0, (struct sockaddr *)&sendaddr, sizeof(sendaddr)) != sizeof(uint16_t)) {
-	syslog(LOG_NOTICE, "Socket send failed, closing socket: %s", strerror(errno));
+	syslog(LOG_NOTICE, "Socket %d send failed, closing socket: %s", sock, strerror(errno));
 	if (shutdown(sock, SHUT_RDWR)) {
 	    syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno));
 	}
 	sock = -1;
     } else {
 	if (recvfrom(sock, &rdat, sizeof(uint16_t), 0, (struct sockaddr *) &sendaddr, &slen) != sizeof(uint16_t)) {
-	    syslog(LOG_NOTICE, "Socket recvfrom failed, closing socket: %s", strerror(errno));
+	    syslog(LOG_NOTICE, "Socket %d recvfrom failed, closing socket: %s", sock, strerror(errno));
+	    if (shutdown(sock, SHUT_RDWR)) {
+		syslog(LOG_NOTICE, "Can't shutdown socket: %s", strerror(errno));
+	    }
+	    sock = -1;
 	} else {
 	    if ((rdat & SLCD_MKEYS) == SLCD_KEYS) {
 		if (((rdat & 0x00ff) != keys) && debug)
--- a/thermferm/thermferm.c	Sat Nov 14 23:40:51 2015 +0100
+++ b/thermferm/thermferm.c	Sun Nov 15 21:12:11 2015 +0100
@@ -977,7 +977,7 @@
     }
 
 #ifdef HAVE_WIRINGPI_H
-    rc = piThreadCreate(my_panel_loop) {
+    rc = piThreadCreate(my_panel_loop);
 #else
     rc = pthread_create(&threads[t], NULL, my_panel_loop, (void *)t );
 #endif

mercurial