Sun, 10 Aug 2014 14:45:11 +0200
Added GLOBAL GET and GLOBAL PUT commands.
103
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (C) 2014 |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of the mbsePi-apps |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * mbsePi-apps is distributed in the hope that it will be useful, but |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with EC-65K; see the file COPYING. If not, write to the Free |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | #include "mash.h" |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | #include "lock.h" |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | #include "logger.h" |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | #include "xutil.h" |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | #include "beerxml.h" |
147 | 28 | #include "lcd-pcf8574.h" |
29 | #include "sensors.h" | |
30 | ||
103
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | #ifdef HAVE_WIRINGPI_H |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | |
147 | 34 | /* wiringPi */ |
35 | #include <wiringPi.h> | |
36 | #include <pcf8574.h> | |
37 | #include <lcd.h> | |
103
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | int tempA = 80; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | int tempB = 80; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | int coolerA = 0; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | int coolerB = 0; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | |
147 | 44 | int my_shutdown = FALSE; |
103
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | static pid_t pgrp, mypid; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | |
147 | 47 | extern int debug; |
103
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | extern sys_config Config; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | extern int lcdHandle; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | extern unsigned char lcdbuf[MAX_LCDS][20][4]; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | int lcdupdate; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | void help(void); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | void die(int); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | void stopLCD(void); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | int server(void); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | void help(void) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | fprintf(stdout, "mbsePi-apps mash v%s starting\n\n", VERSION); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | fprintf(stdout, "Usage: mash [-d] [-h]\n"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | fprintf(stdout, " -d --debug Debug and run in foreground\n"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | fprintf(stdout, " -h --help Display this help\n"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | void die(int onsig) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | switch (onsig) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | case SIGHUP: syslog(LOG_NOTICE, "Got SIGHUP, shutting down"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | break; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | case SIGINT: syslog(LOG_NOTICE, "Keyboard interrupt, shutting down"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | break; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | case SIGTERM: syslog(LOG_NOTICE, "Got SIGTERM, shutting down"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | break; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | default: syslog(LOG_NOTICE, "die() on signal %d", onsig); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | |
147 | 82 | my_shutdown = TRUE; |
103
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | void stopLCD(void) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | mb_lcdClear(lcdHandle); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | setBacklight(0); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | int main(int argc, char *argv[]) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | int rc, c, i; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | pid_t frk; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | char buf[80]; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | while (1) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | int option_index = 0; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | static struct option long_options[] = { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | {"debug", 0, 0, 'c'}, |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | {"help", 0, 0, 'h'}, |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | {0, 0, 0, 0} |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | }; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | c = getopt_long(argc, argv, "dh", long_options, &option_index); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | if (c == -1) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | break; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | switch (c) { |
147 | 114 | case 'd': debug = TRUE; |
103
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | break; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | case 'h': help(); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | return 1; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | parseBeerXML((char *)"/home/mbroek/Downloads/SalmoGold.xml"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | return 0; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | openlog("mash", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | syslog(LOG_NOTICE, "mbsePi-apps mash v%s starting", VERSION); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | if (debug) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | fprintf(stdout, "mbsePi-apps mash v%s starting\n", VERSION); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | if (rdconfig((char *)"mash.conf")) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | fprintf(stderr, "Error reading configuration\n"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | syslog(LOG_NOTICE, "halted"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | return 1; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | /* |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | * Catch all the signals we can, and ignore the rest. Note that SIGKILL can't be ignored |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | * but that's live. This daemon should only be stopped by SIGTERM. |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | * Don't catch SIGCHLD. |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | */ |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | for (i = 0; i < NSIG; i++) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP)) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | signal(i, (void (*))die); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | if (wiringPiSetup () ) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | return 1; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | if ((rc = initLCD (16, 2))) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | return 1; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | lcdPosition(lcdHandle, 0, 0); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | sprintf(buf, " Mash"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | mb_lcdPuts(lcdHandle, buf); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | lcdPosition(lcdHandle, 0, 1); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | sprintf(buf, " Version %s", VERSION); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | mb_lcdPuts(lcdHandle, buf); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | if (debug) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | /* |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | * For debugging run in foreground. |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | */ |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | rc = server(); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | } else { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | /* |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | * Server initialization is complete. Now we can fork the |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | * daemon and return to the user. We need to do a setpgrp |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | * so that the daemon will no longer be assosiated with the |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | * users control terminal. This is done before the fork, so |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | * that the child will not be a process group leader. Otherwise, |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
174 | * if the child were to open a terminal, it would become |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | * associated with that terminal as its control terminal. |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | */ |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | if ((pgrp = setpgid(0, 0)) == -1) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
178 | syslog(LOG_NOTICE, "setpgpid failed"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | frk = fork(); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | switch (frk) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | case -1: |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
184 | syslog(LOG_NOTICE, "Daemon fork failed: %s", strerror(errno)); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | syslog(LOG_NOTICE, "Finished, rc=1"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | stopLCD(); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
187 | exit(1); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | case 0: /* |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | * Run the daemon |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | */ |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | fclose(stdin); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | if (open("/dev/null", O_RDONLY) != 0) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | syslog(LOG_NOTICE, "Reopen of stdin to /dev/null failed"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | _exit(2); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | fclose(stdout); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 1) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | syslog(LOG_NOTICE, "Reopen of stdout to /dev/null failed"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | _exit(2); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | fclose(stderr); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 2) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | syslog(LOG_NOTICE, "Reopen of stderr to /dev/null failed"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | _exit(2); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
206 | mypid = getpid(); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | rc = server(); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | break; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | /* Not reached */ |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | default: |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | /* |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | * Here we detach this process and let the child |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | * run the deamon process. |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | */ |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | syslog(LOG_NOTICE, "Starting daemon with pid %d", frk); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | exit(0); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | syslog(LOG_NOTICE, "Finished, rc=%d", rc); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | return rc; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | int server(void) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
227 | { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | char buf[1024]; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
229 | w1_therm *tmp1; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
230 | int rc, run = 1, temp; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | if (lockprog((char *)"mash")) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | syslog(LOG_NOTICE, "Can't lock"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | return 1; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | rc = piThreadCreate(my_sensors_loop); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | if (rc) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
239 | fprintf(stderr, "my_sensors_loop thread didn't start rc=%d\n", rc); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
240 | syslog(LOG_NOTICE, "my_sensors_loop thread didn't start rc=%d", rc); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
242 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
243 | // rc = piThreadCreate(my_server_loop); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
244 | // if (rc) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
245 | // fprintf(stderr, "my_server_loop thread didn't start rc=%d\n", rc); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
246 | // syslog(LOG_NOTICE, "my_server_loop thread didn't start rc=%d", rc); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
247 | // } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
248 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
249 | snprintf(buf, 1023, "temp,step,description"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
250 | logger((char *)"mash.log", (char *)"mash", buf); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
251 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
252 | do { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
253 | lcdupdate = FALSE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
254 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
255 | if (my_shutdown) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
256 | run = 0; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
257 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
258 | tmp1 = Config.w1therms; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
259 | // if (((tmp1->lastval / 100) < (tempA - 5)) && (coolerA == 1)) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
260 | // syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler off", (tmp1->lastval / 1000.0)); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
261 | // lcdupdate = TRUE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
262 | // } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
263 | // if (((tmp1->lastval / 100) > (tempA + 5)) && (coolerA == 0)) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
264 | // syslog(LOG_NOTICE, "Temperature A is %.1f, switched cooler on", (tmp1->lastval / 1000.0)); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
265 | // lcdupdate = TRUE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
266 | // } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
267 | if (tmp1->update) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
268 | tmp1->update = FALSE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
269 | lcdupdate = TRUE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
270 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
271 | // old1 = tmp1->next; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
272 | // tmp1 = old1; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
273 | // if (((tmp1->lastval / 100) < (tempB - 5)) && (coolerB == 1)) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
274 | // syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler off", (tmp1->lastval / 1000.0)); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
275 | // lcdupdate = TRUE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
276 | // } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
277 | // if (((tmp1->lastval / 100) > (tempB + 5)) && (coolerB == 0)) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
278 | // syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler on", (tmp1->lastval / 1000.0)); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
279 | // lcdupdate = TRUE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
280 | // } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
281 | // if (tmp1->update) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
282 | // tmp1->update = FALSE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
283 | // lcdupdate = TRUE; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
284 | // } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
285 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
286 | if (run && lcdupdate) { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
287 | lcdPosition(lcdHandle, 0, 0); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
288 | tmp1 = Config.w1therms; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
289 | snprintf(buf, 16, "%4.1f %cC %s ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
290 | mb_lcdPuts(lcdHandle, buf); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
291 | temp = tmp1->lastval; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
292 | // old1 = tmp1->next; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
293 | // tmp1 = old1; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
294 | lcdPosition(lcdHandle, 0, 1); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
295 | snprintf(buf, 16, " "); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
296 | mb_lcdPuts(lcdHandle, buf); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
297 | snprintf(buf, 1023, "%.1f,%d,%s", temp / 1000.0, 1, (char *)"step description"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
298 | logger((char *)"mash.log", (char *)"mash", buf); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
299 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
300 | usleep(100000); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
301 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
302 | } while (run); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
303 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
304 | if (debug) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
305 | fprintf(stdout, (char *)"Out of loop\n"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
306 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
307 | /* |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
308 | * Give threads time to cleanup |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
309 | */ |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
310 | usleep(1500000); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
311 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
312 | stopLCD(); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
313 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
314 | // wrconfig((char *)"mash.conf"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
315 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
316 | ulockprog((char *)"mash"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
317 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
318 | if (debug) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
319 | fprintf(stdout, "Goodbye\n"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
320 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
321 | return 0; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
322 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
323 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
324 | #else |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
325 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
326 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
327 | int main(int argc, char *argv[]) |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
328 | { |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
329 | parseBeerXML((char *)"/home/mbroek/Downloads/beerxml.xml"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
330 | printBeerXML(); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
331 | // fprintf(stderr, "Compiled on a system without a wiringPi library.\n"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
332 | // fprintf(stderr, "This program is useless and will do nothing.\n"); |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
333 | return 0; |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
334 | } |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
335 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
336 | |
99c47a8a61cb
Added the mash sourcecode, this does nothing useful yet.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
337 | #endif |