Tue, 05 Aug 2014 15:44:29 +0200
Removing units thread
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (C) 2014 |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of the mbsePi-apps |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * mbsePi-apps is distributed in the hope that it will be useful, but |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with EC-65K; see the file COPYING. If not, write to the Free |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
106 | 23 | #include "lock.h" |
24 | #include "logger.h" | |
25 | #include "rdconfig.h" | |
160 | 26 | #include "devices.h" |
106 | 27 | #include "server.h" |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
28 | #include "thermferm.h" |
106 | 29 | #include "lcd-pcf8574.h" |
30 | #include "lcd-buffer.h" | |
31 | #include "futil.h" | |
32 | #include "xutil.h" | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | |
131
528dc0bb81ab
Always use uuid to select units and remove numeric record id's.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
35 | char *current_unit = NULL; |
33
2357e8636a60
Added user log with temperatures and cooler state
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
36 | int tempA = 80; |
2357e8636a60
Added user log with temperatures and cooler state
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
37 | int tempB = 80; |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
38 | |
48 | 39 | key_t key = 5680; /* key to be passed to shmget() */ |
40 | int shmid; | |
41 | ||
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
42 | int my_shutdown = FALSE; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | static pid_t pgrp, mypid; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
45 | extern int debug; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | extern sys_config Config; |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
47 | #ifdef HAVE_WIRINGPI_H |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | extern int lcdHandle; |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
49 | extern unsigned char lcdbuf[MAX_LCDS][20][4]; |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
50 | #endif |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | int lcdupdate; |
74 | 52 | #ifndef HAVE_WIRINGPI_H |
164
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
53 | pthread_t threads[4]; |
74 | 54 | #endif |
104 | 55 | extern const char UNITMODE[5][8]; |
56 | ||
40
dafbbd5e9922
Prepared unix socket communication
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
57 | |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
58 | int server(void); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | void help(void); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | void die(int); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
61 | #ifdef HAVE_WIRINGPI_H |
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
62 | void sendRCswitch(char *, int); |
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
63 | void stopLCD(void); |
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
64 | void stopRCswitch(void); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
65 | #endif |
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
66 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | void help(void) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | { |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
71 | fprintf(stdout, "mbsePi-apps thermferm v%s starting\n\n", VERSION); |
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
72 | fprintf(stdout, "Usage: thermferm [-d] [-h]\n"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | fprintf(stdout, " -d --debug Debug and run in foreground\n"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | fprintf(stdout, " -h --help Display this help\n"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | void die(int onsig) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | switch (onsig) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | case SIGHUP: syslog(LOG_NOTICE, "Got SIGHUP, shutting down"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | case SIGINT: syslog(LOG_NOTICE, "Keyboard interrupt, shutting down"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | case SIGTERM: syslog(LOG_NOTICE, "Got SIGTERM, shutting down"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | default: syslog(LOG_NOTICE, "die() on signal %d", onsig); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
91 | my_shutdown = TRUE; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
96 | #ifdef HAVE_WIRINGPI_H |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | void stopLCD(void) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | { |
40
dafbbd5e9922
Prepared unix socket communication
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
99 | mb_lcdClear(lcdHandle); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | setBacklight(0); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | } |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
102 | #endif |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
103 | |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
104 | |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
105 | |
182 | 106 | int read_w1_28(char *address, int *val) |
107 | { | |
108 | devices_list *device; | |
109 | int tmp; | |
110 | ||
111 | for (device = Config.devices; device; device = device->next) { | |
112 | if (strcmp(address, device->uuid) == 0) { | |
113 | tmp = device->value; | |
114 | *val = tmp; | |
115 | return device->present; | |
116 | } | |
117 | } | |
118 | ||
119 | return DEVPRESENT_NO; | |
120 | } | |
121 | ||
122 | ||
123 | ||
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | int main(int argc, char *argv[]) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | int rc, c, i; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | pid_t frk; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | while (1) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | int option_index = 0; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | static struct option long_options[] = { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | {"debug", 0, 0, 'c'}, |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | {"help", 0, 0, 'h'}, |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | {0, 0, 0, 0} |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | }; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | c = getopt_long(argc, argv, "dh", long_options, &option_index); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | if (c == -1) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | switch (c) { |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
142 | case 'd': debug = TRUE; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | case 'h': help(); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | return 1; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
149 | openlog("thermferm", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER); |
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
150 | syslog(LOG_NOTICE, "mbsePi-apps thermferm v%s starting", VERSION); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | if (debug) |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
152 | fprintf(stdout, "mbsePi-apps thermferm v%s starting\n", VERSION); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
154 | if (rdconfig()) { |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | fprintf(stderr, "Error reading configuration\n"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | syslog(LOG_NOTICE, "halted"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | return 1; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | * Catch all the signals we can, and ignore the rest. Note that SIGKILL can't be ignored |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | * but that's live. This daemon should only be stopped by SIGTERM. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | * Don't catch SIGCHLD. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | for (i = 0; i < NSIG; i++) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP)) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | signal(i, (void (*))die); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
170 | #ifdef HAVE_WIRINGPI_H |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
171 | if (wiringPiSetup () ) |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
172 | return 1; |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
173 | |
108 | 174 | if ((rc = initLCD (Config.lcd_cols, Config.lcd_rows))) { |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | return 1; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | } |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
178 | #endif |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
179 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | if (debug) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | * For debugging run in foreground. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
184 | rc = server(); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | } else { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
187 | * Server initialization is complete. Now we can fork the |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | * daemon and return to the user. We need to do a setpgrp |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | * so that the daemon will no longer be assosiated with the |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | * users control terminal. This is done before the fork, so |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | * that the child will not be a process group leader. Otherwise, |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | * if the child were to open a terminal, it would become |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | * associated with that terminal as its control terminal. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | if ((pgrp = setpgid(0, 0)) == -1) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | syslog(LOG_NOTICE, "setpgpid failed"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | frk = fork(); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | switch (frk) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | case -1: |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | syslog(LOG_NOTICE, "Daemon fork failed: %s", strerror(errno)); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | syslog(LOG_NOTICE, "Finished, rc=1"); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
204 | #ifdef HAVE_WIRINGPI_H |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | stopLCD(); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
206 | #endif |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | exit(1); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | case 0: /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | * Run the daemon |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | fclose(stdin); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | if (open("/dev/null", O_RDONLY) != 0) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | syslog(LOG_NOTICE, "Reopen of stdin to /dev/null failed"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | _exit(2); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | fclose(stdout); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 1) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | syslog(LOG_NOTICE, "Reopen of stdout to /dev/null failed"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | _exit(2); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | fclose(stderr); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 2) { |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | syslog(LOG_NOTICE, "Reopen of stderr to /dev/null failed"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | _exit(2); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | mypid = getpid(); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
227 | rc = server(); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | break; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
229 | /* Not reached */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
230 | default: |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | /* |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | * Here we detach this process and let the child |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | * run the deamon process. |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | */ |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | syslog(LOG_NOTICE, "Starting daemon with pid %d", frk); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | exit(0); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
239 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
240 | syslog(LOG_NOTICE, "Finished, rc=%d", rc); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | return rc; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
242 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
243 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
244 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
245 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
246 | int server(void) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
247 | { |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
248 | char buf[1024], *filename, target[40], heater[40], cooler[40], fan[40], door[40]; |
64
2431965e8a8c
Write loglines only every 60 seconds
Michiel Broek <mbroek@mbse.eu>
parents:
63
diff
changeset
|
249 | time_t now, last = (time_t)0; |
104 | 250 | units_list *unit; |
182 | 251 | int rc, run = 1, seconds = 0, minutes = 0, piddelay = 0, temp, deviation; |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
252 | float err = 0.0, sp, pv, P_err, I_err = 0.0, D_err, Out; |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
253 | #ifdef HAVE_WIRINGPI_H |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
254 | struct tm *tm; |
108 | 255 | int row; |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
256 | #else |
74 | 257 | long t = 0; |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
258 | #endif |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
259 | |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
260 | if (lockprog((char *)"thermferm")) { |
34 | 261 | syslog(LOG_NOTICE, "Can't lock"); |
262 | return 1; | |
263 | } | |
264 | ||
158 | 265 | rc = devices_detect(); |
266 | if (rc) { | |
267 | syslog(LOG_NOTICE, "Detected %d new devices", rc); | |
268 | if (debug) | |
269 | fprintf(stdout, "Detected %d new devices\n", rc); | |
270 | wrconfig(); | |
271 | } | |
272 | ||
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
273 | #ifdef HAVE_WIRINGPI_H |
164
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
274 | rc = piThreadCreate(my_devices_loop); |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
275 | #else |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
276 | rc = pthread_create(&threads[t], NULL, my_devices_loop, (void *)t ); |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
277 | #endif |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
278 | if (rc) { |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
279 | fprintf(stderr, "my_devices_loop thread didn't start rc=%d\n", rc); |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
280 | syslog(LOG_NOTICE, "my_devices_loop thread didn't start rc=%d", rc); |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
281 | #ifndef HAVE_WIRINGPI_H |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
282 | } else { |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
283 | t++; |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
284 | #endif |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
285 | } |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
286 | |
f16def8472ba
Threads partly working via new devices interface
Michiel Broek <mbroek@mbse.eu>
parents:
160
diff
changeset
|
287 | #ifdef HAVE_WIRINGPI_H |
43 | 288 | rc = piThreadCreate(my_server_loop); |
74 | 289 | #else |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
290 | rc = pthread_create(&threads[t], NULL, my_server_loop, (void *)t ); |
74 | 291 | #endif |
43 | 292 | if (rc) { |
293 | fprintf(stderr, "my_server_loop thread didn't start rc=%d\n", rc); | |
294 | syslog(LOG_NOTICE, "my_server_loop thread didn't start rc=%d", rc); | |
75
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
295 | #ifndef HAVE_WIRINGPI_H |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
296 | } else { |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
297 | t++; |
4b976601737d
Writes a basic xml configuration next to the plain ascii config file
Michiel Broek <mbroek@mbse.eu>
parents:
74
diff
changeset
|
298 | #endif |
43 | 299 | } |
300 | ||
182 | 301 | /* |
302 | * Initialize units for processing | |
303 | */ | |
304 | for (unit = Config.units; unit; unit = unit->next) { | |
305 | /* | |
306 | * Safety, turn everything off | |
307 | */ | |
308 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = 0; | |
309 | if (unit->profile && (int)unit->prof_started && (unit->mode == UNITMODE_PROFILE)) { | |
310 | syslog(LOG_NOTICE, "Starting unit %s profile %s", unit->name, unit->profile); | |
311 | } else if (unit->mode == UNITMODE_BEER) { | |
312 | syslog(LOG_NOTICE, "Starting unit %s beer cooler at %.1f degrees", unit->name, unit->beer_set); | |
313 | } else if (unit->mode == UNITMODE_FRIDGE) { | |
314 | syslog(LOG_NOTICE, "Starting unit %s as refridgerator at %.1f degrees", unit->name, unit->fridge_set); | |
315 | } else if (unit->mode == UNITMODE_NONE) { | |
316 | syslog(LOG_NOTICE, "Starting unit %s in inactive state", unit->name); | |
317 | } else { | |
318 | syslog(LOG_NOTICE, "Starting unit %s in off state", unit->name); | |
319 | } | |
320 | } | |
321 | ||
93
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
322 | #ifdef HAVE_WIRINGPI_H |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
323 | rc = piThreadCreate(my_units_loop); |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
324 | #else |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
325 | rc = pthread_create(&threads[t], NULL, my_units_loop, (void *)t ); |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
326 | #endif |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
327 | if (rc) { |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
328 | fprintf(stderr, "my_units_loop thread didn't start rc=%d\n", rc); |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
329 | syslog(LOG_NOTICE, "my_units_loop thread didn't start rc=%d", rc); |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
330 | #ifndef HAVE_WIRINGPI_H |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
331 | } else { |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
332 | t++; |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
333 | #endif |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
334 | } |
b759f814469d
Added units processing thread
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
335 | |
111 | 336 | #ifdef HAVE_WIRINGPI_H |
108 | 337 | lcd_buf_write(1, (char *)" ThermFerm "); |
338 | lcd_buf_write(2, (char *)" Version %s ", VERSION); | |
111 | 339 | #endif |
108 | 340 | |
104 | 341 | for (unit = Config.units; unit; unit = unit->next) { |
342 | if (unit->mode != UNITMODE_OFF) { | |
155
0d86f3c0a07b
Unit mode can switch between OFF and NONE.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
343 | initlog(unit->name); |
104 | 344 | } |
345 | } | |
33
2357e8636a60
Added user log with temperatures and cooler state
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
346 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
347 | do { |
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
348 | if (my_shutdown) |
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
349 | run = 0; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
350 | |
104 | 351 | /* |
352 | * Timed schedulers | |
353 | */ | |
64
2431965e8a8c
Write loglines only every 60 seconds
Michiel Broek <mbroek@mbse.eu>
parents:
63
diff
changeset
|
354 | now = time(NULL); |
104 | 355 | if (now != last) { |
64
2431965e8a8c
Write loglines only every 60 seconds
Michiel Broek <mbroek@mbse.eu>
parents:
63
diff
changeset
|
356 | last = now; |
104 | 357 | seconds++; |
358 | ||
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
359 | #ifdef HAVE_WIRINGPI_H |
108 | 360 | row = 3; |
361 | tm = localtime(&now); | |
362 | lcd_buf_write(row++, " %02d-%02d-%04d ", tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900); | |
363 | lcd_buf_write(row++, " %02d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec); | |
182 | 364 | #endif |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
365 | |
108 | 366 | for (unit = Config.units; unit; unit = unit->next) { |
182 | 367 | #ifdef HAVE_WIRINGPI_H |
108 | 368 | lcd_buf_write(row++, "Unit %s ", unit->name); |
369 | lcd_buf_write(row++, "Mode %s ", UNITMODE[unit->mode]); | |
370 | if (unit->air_address) { | |
371 | lcd_buf_write(row++, " Air %.3f %cC ", unit->air_temperature / 1000.0, 0xdf); | |
372 | } | |
373 | if (unit->beer_address) { | |
374 | lcd_buf_write(row++, "Beer %.3f %cC ", unit->beer_temperature / 1000.0, 0xdf); | |
375 | } | |
182 | 376 | #endif |
377 | ||
378 | if (unit->air_address) { | |
379 | rc = read_w1_28(unit->air_address, &temp); | |
380 | if (rc == DEVPRESENT_YES) { | |
381 | /* | |
382 | * It is possible to have read errors or extreme values. | |
383 | * This can happen with bad connections so we compare the | |
384 | * value with the previous one. If the difference is too | |
385 | * much, we don't send that value. That also means that if | |
386 | * the next value is ok again, it will be marked invalid too. | |
387 | * Maximum error is 40 degrees for now. | |
388 | */ | |
389 | deviation = 40000; | |
390 | if ((unit->air_temperature == 0) || | |
391 | (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { | |
392 | unit->air_temperature = temp; | |
393 | unit->air_state = 0; | |
394 | } else { | |
395 | syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); | |
396 | if (debug) { | |
397 | fprintf(stdout, "deviation error deviation=%d, old=%d new=%d\n", deviation, unit->air_temperature, temp); | |
398 | } | |
399 | } | |
400 | } else if (rc == DEVPRESENT_ERROR) { | |
401 | unit->air_state = 1; | |
402 | } else { | |
403 | unit->air_state = 2; | |
404 | } | |
405 | } | |
406 | ||
407 | if (unit->beer_address) { | |
408 | rc = read_w1_28(unit->beer_address, &temp); | |
409 | if (rc == DEVPRESENT_YES) { | |
410 | deviation = 40000; | |
411 | if ((unit->beer_temperature == 0) || | |
412 | (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { | |
413 | unit->beer_temperature = temp; | |
414 | unit->beer_state = 0; | |
415 | } else { | |
416 | syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); | |
417 | if (debug) { | |
418 | fprintf(stdout, "deviation error deviation=%d, old=%d new=%d\n", deviation, unit->beer_temperature, temp); | |
419 | } | |
420 | } | |
421 | } else if (rc == DEVPRESENT_ERROR) { | |
422 | unit->beer_state = 1; | |
423 | } else { | |
424 | unit->beer_state = 2; | |
425 | } | |
426 | } | |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
427 | } |
108 | 428 | |
182 | 429 | #ifdef HAVE_WIRINGPI_H |
108 | 430 | lcd_buf_show(); |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
431 | #endif |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
432 | |
182 | 433 | piddelay++; |
434 | if (piddelay == 15) { | |
435 | piddelay = 0; | |
104 | 436 | |
437 | for (unit = Config.units; unit; unit = unit->next) { | |
438 | if (unit->mode != UNITMODE_OFF) { | |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
439 | |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
440 | if (unit->mode != UNITMODE_NONE) { |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
441 | /* |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
442 | * PID controller |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
443 | */ |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
444 | sp = unit->beer_set; |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
445 | pv = unit->beer_temperature / 1000.0; |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
446 | if (unit->mode == UNITMODE_FRIDGE) { |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
447 | sp = unit->fridge_set; |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
448 | pv = unit->air_temperature / 1000.0; |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
449 | } else if (unit->mode == UNITMODE_PROFILE) { |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
450 | sp = unit->prof_target; |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
451 | } |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
452 | |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
453 | unit->PID_err_old = err; |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
454 | err = sp - pv; |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
455 | if (err < unit->idle_rangeH && err > unit->idle_rangeL) |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
456 | err = 0; |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
457 | P_err = err; |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
458 | I_err += unit->PID_err_old; |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
459 | D_err = err - unit->PID_err_old; |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
460 | |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
461 | /* |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
462 | * A postive value means heating, a negative value cooling. |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
463 | */ |
182 | 464 | Out = (5.0*P_err) + (0.25*I_err) + (1.5*D_err); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
465 | // Kp 0.1 Ki 0.3 Kd 0.02 |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
466 | if (debug) |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
467 | fprintf(stdout, "sp=%.2f pv=%.2f err_old=%.2f err=%.2f P_err=%.2f I_err=%.2f D_err=%.2f Out=%.2f\n", |
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
468 | sp, pv, unit->PID_err_old, err, P_err, I_err, D_err, Out); |
179
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
469 | if (unit->heater_address) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
470 | if (Out >= 2) |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
471 | unit->heater_state = 100; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
472 | else |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
473 | unit->heater_state = 0; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
474 | device_out(unit->heater_address, unit->heater_state); |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
475 | } |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
476 | if (unit->cooler_address) { |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
477 | if (Out <= -2) |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
478 | unit->cooler_state = 100; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
479 | else |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
480 | unit->cooler_state = 0; |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
481 | device_out(unit->cooler_address, unit->cooler_state); |
417ee898fb02
Added PID implementation and 433 MHz radio control switches. Not reliable yet.
Michiel Broek <mbroek@mbse.eu>
parents:
177
diff
changeset
|
482 | } |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
483 | } |
182 | 484 | } |
485 | } | |
486 | } | |
487 | ||
488 | if (seconds == 60) { | |
489 | seconds = 0; | |
490 | ||
491 | /* | |
492 | * Log temperature and status every minute if unit is active. | |
493 | */ | |
494 | for (unit = Config.units; unit; unit = unit->next) { | |
495 | if (unit->mode != UNITMODE_OFF) { | |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
496 | |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
497 | snprintf(target, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
498 | snprintf(heater, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
499 | snprintf(cooler, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
500 | snprintf(fan, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
501 | snprintf(door, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
502 | |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
503 | if (unit->mode == UNITMODE_BEER) |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
504 | snprintf(target, 39, "%.1f", unit->beer_set); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
505 | else if (unit->mode == UNITMODE_FRIDGE) |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
506 | snprintf(target, 39, "%.1f", unit->fridge_set); |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
507 | else if (unit->mode == UNITMODE_PROFILE) |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
508 | snprintf(target, 39, "%.1f", unit->prof_target); |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
509 | |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
510 | if (unit->heater_address) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
511 | snprintf(heater, 39, "%d", unit->heater_state); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
512 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
513 | if (unit->cooler_address) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
514 | snprintf(cooler, 39, "%d", unit->cooler_state); |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
515 | } |
175
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
516 | if (unit->fan_address) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
517 | snprintf(fan, 39, "%d", unit->fan_state); |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
518 | } |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
519 | if (unit->door_address) { |
b73490398368
Units editing is more or less complete. Changed structures for heating, cooling, fan and door. Updated the web interface to confuigure all these things.
Michiel Broek <mbroek@mbse.eu>
parents:
174
diff
changeset
|
520 | snprintf(door, 39, "%d", unit->door_state); |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
521 | } |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
522 | |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
523 | snprintf(buf, 1023, "%s,%.3f,%.3f,%s,%s,%s,%s,%s", |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
524 | UNITMODE[unit->mode], unit->air_temperature / 1000.0, |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
525 | unit->beer_temperature / 1000.0, target, heater, cooler, fan, door); |
104 | 526 | filename = xstrcpy(unit->name); |
527 | filename = xstrcat(filename, (char *)".log"); | |
528 | logger(filename, buf); | |
529 | free(filename); | |
530 | filename = NULL; | |
531 | } | |
532 | } | |
167
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
533 | |
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
534 | minutes++; |
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
535 | if (minutes == 60) |
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
536 | minutes = 0; |
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
537 | |
174 | 538 | if ((minutes == 15) || (minutes == 45)) { |
539 | syslog(LOG_NOTICE, "minutes %d seconds %d", minutes, seconds); | |
167
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
540 | wrconfig(); |
174 | 541 | } |
64
2431965e8a8c
Write loglines only every 60 seconds
Michiel Broek <mbroek@mbse.eu>
parents:
63
diff
changeset
|
542 | } |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
543 | } |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
544 | usleep(100000); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
545 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
546 | } while (run); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
547 | |
182 | 548 | /* |
549 | * Stop units processing in a neat way | |
550 | */ | |
551 | for (unit = Config.units; unit; unit = unit->next) { | |
552 | /* | |
553 | * Turn everything off | |
554 | */ | |
555 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = 0; | |
556 | device_out(unit->heater_address, unit->heater_state); | |
557 | device_out(unit->cooler_address, unit->cooler_state); | |
558 | device_out(unit->fan_address, unit->fan_state); | |
559 | syslog(LOG_NOTICE, "Stopped unit %s mode %s", unit->name, UNITMODE[unit->mode]); | |
560 | } | |
561 | ||
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
562 | if (debug) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
563 | fprintf(stdout, (char *)"Out of loop\n"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
564 | |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
565 | /* |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
566 | * Give threads time to cleanup |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
567 | */ |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
568 | usleep(1500000); |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
569 | |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
570 | #ifdef HAVE_WIRINGPI_H |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
571 | stopLCD(); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
572 | #endif |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
573 | |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
574 | wrconfig(); |
53 | 575 | |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
576 | ulockprog((char *)"thermferm"); |
34 | 577 | |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
578 | if (debug) |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
579 | fprintf(stdout, "Goodbye\n"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
580 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
581 | return 0; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
582 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
583 |