Thu, 07 Aug 2014 14:20:11 +0200
Init logfile when a unit is turned on. Added comments for profile processing.
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; |
185 | 252 | float err = 0.0, sp, pv, P_err, 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 | |
111 | 323 | #ifdef HAVE_WIRINGPI_H |
108 | 324 | lcd_buf_write(1, (char *)" ThermFerm "); |
325 | lcd_buf_write(2, (char *)" Version %s ", VERSION); | |
111 | 326 | #endif |
108 | 327 | |
104 | 328 | for (unit = Config.units; unit; unit = unit->next) { |
329 | if (unit->mode != UNITMODE_OFF) { | |
155
0d86f3c0a07b
Unit mode can switch between OFF and NONE.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
330 | initlog(unit->name); |
104 | 331 | } |
332 | } | |
33
2357e8636a60
Added user log with temperatures and cooler state
Michiel Broek <mbroek@mbse.eu>
parents:
29
diff
changeset
|
333 | |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
334 | do { |
46
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
335 | if (my_shutdown) |
000399c64d3f
More client/server communications
Michiel Broek <mbroek@mbse.eu>
parents:
44
diff
changeset
|
336 | run = 0; |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
337 | |
64
2431965e8a8c
Write loglines only every 60 seconds
Michiel Broek <mbroek@mbse.eu>
parents:
63
diff
changeset
|
338 | now = time(NULL); |
104 | 339 | if (now != last) { |
189
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
340 | /* |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
341 | * Each second |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
342 | */ |
64
2431965e8a8c
Write loglines only every 60 seconds
Michiel Broek <mbroek@mbse.eu>
parents:
63
diff
changeset
|
343 | last = now; |
104 | 344 | seconds++; |
345 | ||
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
346 | #ifdef HAVE_WIRINGPI_H |
108 | 347 | row = 3; |
348 | tm = localtime(&now); | |
349 | lcd_buf_write(row++, " %02d-%02d-%04d ", tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900); | |
350 | lcd_buf_write(row++, " %02d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec); | |
182 | 351 | #endif |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
352 | |
108 | 353 | for (unit = Config.units; unit; unit = unit->next) { |
182 | 354 | #ifdef HAVE_WIRINGPI_H |
184 | 355 | lcd_buf_write(row++, "Unit %s ", unit->name); |
356 | lcd_buf_write(row++, "Mode %s ", UNITMODE[unit->mode]); | |
182 | 357 | #endif |
358 | ||
359 | if (unit->air_address) { | |
360 | rc = read_w1_28(unit->air_address, &temp); | |
361 | if (rc == DEVPRESENT_YES) { | |
362 | /* | |
363 | * It is possible to have read errors or extreme values. | |
364 | * This can happen with bad connections so we compare the | |
365 | * value with the previous one. If the difference is too | |
366 | * much, we don't send that value. That also means that if | |
367 | * the next value is ok again, it will be marked invalid too. | |
368 | * Maximum error is 40 degrees for now. | |
369 | */ | |
370 | deviation = 40000; | |
371 | if ((unit->air_temperature == 0) || | |
372 | (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { | |
373 | unit->air_temperature = temp; | |
374 | unit->air_state = 0; | |
188
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
375 | #ifdef HAVE_WIRINGPI_H |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
376 | lcd_buf_write(row++, " Air %.3f %cC ", unit->air_temperature / 1000.0, 0xdf); |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
377 | #endif |
182 | 378 | } else { |
379 | syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); | |
380 | if (debug) { | |
381 | fprintf(stdout, "deviation error deviation=%d, old=%d new=%d\n", deviation, unit->air_temperature, temp); | |
382 | } | |
383 | } | |
384 | } else if (rc == DEVPRESENT_ERROR) { | |
385 | unit->air_state = 1; | |
386 | } else { | |
387 | unit->air_state = 2; | |
388 | } | |
389 | } | |
390 | ||
391 | if (unit->beer_address) { | |
392 | rc = read_w1_28(unit->beer_address, &temp); | |
393 | if (rc == DEVPRESENT_YES) { | |
394 | deviation = 40000; | |
395 | if ((unit->beer_temperature == 0) || | |
396 | (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { | |
397 | unit->beer_temperature = temp; | |
398 | unit->beer_state = 0; | |
188
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
399 | #ifdef HAVE_WIRINGPI_H |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
400 | lcd_buf_write(row++, "Beer %.3f %cC ", unit->beer_temperature / 1000.0, 0xdf); |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
401 | #endif |
182 | 402 | } else { |
403 | syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); | |
404 | if (debug) { | |
405 | fprintf(stdout, "deviation error deviation=%d, old=%d new=%d\n", deviation, unit->beer_temperature, temp); | |
406 | } | |
407 | } | |
408 | } else if (rc == DEVPRESENT_ERROR) { | |
409 | unit->beer_state = 1; | |
410 | } else { | |
411 | unit->beer_state = 2; | |
412 | } | |
413 | } | |
184 | 414 | |
415 | /* | |
189
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
416 | * Handle profile |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
417 | */ |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
418 | if ((unit->mode == UNITMODE_PROFILE) && (unit->profile)) { |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
419 | /* |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
420 | * unit->profile - uuid of the selected profile. |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
421 | * unit->prof_started - start time or 0 if not yet running. |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
422 | * unit->prof_state - PROFILE_OFF|PROFILE_PAUSE|PROFILE_RUN|PROFILE_DONE |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
423 | * unit->prof_target - Calculated target temperature. |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
424 | */ |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
425 | // off. Target is ?? |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
426 | // pause Target is keep target. |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
427 | // run. Target must be calculated using steps. |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
428 | // done. Target is last target. |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
429 | } |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
430 | |
cc2b04d4db99
Init logfile when a unit is turned on. Added comments for profile processing.
Michiel Broek <mbroek@mbse.eu>
parents:
188
diff
changeset
|
431 | /* |
184 | 432 | * Manual switching |
433 | */ | |
434 | if (unit->mode == UNITMODE_NONE) { | |
435 | device_out(unit->heater_address, unit->heater_state); | |
436 | device_out(unit->cooler_address, unit->cooler_state); | |
437 | device_out(unit->fan_address, unit->fan_state); | |
438 | } | |
188
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
439 | #ifdef HAVE_WIRINGPI_H |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
440 | if (unit->heater_address) { |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
441 | lcd_buf_write(row++, "Heater %s ", unit->heater_state ? "On ":"Off"); |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
442 | } |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
443 | if (unit->cooler_address) { |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
444 | lcd_buf_write(row++, "Cooler %s ", unit->cooler_state ? "On ":"Off"); |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
445 | } |
4fc17ef4593f
Added heat/cool state to the LCD display
Michiel Broek <mbroek@mbse.eu>
parents:
185
diff
changeset
|
446 | #endif |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
447 | } |
108 | 448 | |
182 | 449 | #ifdef HAVE_WIRINGPI_H |
108 | 450 | lcd_buf_show(); |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
451 | #endif |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
452 | |
182 | 453 | piddelay++; |
454 | if (piddelay == 15) { | |
455 | piddelay = 0; | |
104 | 456 | |
457 | for (unit = Config.units; unit; unit = unit->next) { | |
184 | 458 | if ((unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_BEER) || (unit->mode == UNITMODE_PROFILE)) { |
459 | /* | |
460 | * PID controller | |
461 | */ | |
462 | sp = unit->beer_set; | |
463 | pv = unit->beer_temperature / 1000.0; | |
464 | if (unit->mode == UNITMODE_FRIDGE) { | |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
465 | 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
|
466 | pv = unit->air_temperature / 1000.0; |
184 | 467 | } else if (unit->mode == UNITMODE_PROFILE) { |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
468 | sp = unit->prof_target; |
184 | 469 | } |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
470 | |
184 | 471 | unit->PID_err_old = err; |
472 | err = sp - pv; | |
185 | 473 | if (err < unit->idle_rangeH && err > unit->idle_rangeL) { |
184 | 474 | err = 0; |
185 | 475 | unit->PID_I_err -= unit->PID_err_old; |
476 | } else { | |
477 | unit->PID_I_err += unit->PID_err_old; | |
478 | } | |
479 | /* Limit intergral error */ | |
480 | if (unit->PID_I_err < -10.0) | |
481 | unit->PID_I_err = -10.0; | |
482 | if (unit->PID_I_err > 10.0) | |
483 | unit->PID_I_err = 10.0; | |
184 | 484 | P_err = err; |
485 | D_err = err - unit->PID_err_old; | |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
486 | |
184 | 487 | /* |
488 | * A postive value means heating, a negative value cooling. | |
489 | */ | |
185 | 490 | Out = (10.0*P_err) + (0.1*unit->PID_I_err) + (5*D_err); |
491 | // Kp 0.1 Ki 0.3 Kd 0.02 | |
184 | 492 | if (debug) |
493 | fprintf(stdout, "sp=%.2f pv=%.2f err_old=%.2f err=%.2f P_err=%.2f I_err=%.2f D_err=%.2f Out=%.2f\n", | |
185 | 494 | sp, pv, unit->PID_err_old, err, P_err, unit->PID_I_err, D_err, Out); |
184 | 495 | if (unit->heater_address) { |
496 | if (Out >= 2) | |
497 | unit->heater_state = 100; | |
498 | else | |
499 | unit->heater_state = 0; | |
500 | device_out(unit->heater_address, unit->heater_state); | |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
501 | } |
184 | 502 | if (unit->cooler_address) { |
503 | if (Out <= -2) | |
504 | unit->cooler_state = 100; | |
505 | else | |
506 | unit->cooler_state = 0; | |
507 | device_out(unit->cooler_address, unit->cooler_state); | |
508 | } | |
509 | } else { | |
510 | err = 0.0; | |
185 | 511 | unit->PID_I_err = 0.0; |
184 | 512 | unit->PID_err_old = 0.0; |
182 | 513 | } |
514 | } | |
515 | } | |
516 | ||
517 | if (seconds == 60) { | |
518 | seconds = 0; | |
519 | ||
520 | /* | |
521 | * Log temperature and status every minute if unit is active. | |
522 | */ | |
523 | for (unit = Config.units; unit; unit = unit->next) { | |
524 | if (unit->mode != UNITMODE_OFF) { | |
176
8c7d87a2c094
Initial code for a simple PID controller.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
525 | |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
526 | snprintf(target, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
527 | snprintf(heater, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
528 | snprintf(cooler, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
529 | snprintf(fan, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
530 | snprintf(door, 39, "NA"); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
531 | |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
532 | if (unit->mode == UNITMODE_BEER) |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
533 | snprintf(target, 39, "%.1f", unit->beer_set); |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
534 | else if (unit->mode == UNITMODE_FRIDGE) |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
535 | 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
|
536 | 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
|
537 | snprintf(target, 39, "%.1f", unit->prof_target); |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
538 | |
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
|
539 | 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
|
540 | 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
|
541 | } |
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
|
542 | 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
|
543 | snprintf(cooler, 39, "%d", unit->cooler_state); |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
544 | } |
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
|
545 | 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
|
546 | 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
|
547 | } |
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
|
548 | 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
|
549 | snprintf(door, 39, "%d", unit->door_state); |
105
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
550 | } |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
551 | |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
552 | 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
|
553 | UNITMODE[unit->mode], unit->air_temperature / 1000.0, |
a5a964148e34
Started code of roulating lcd display
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
554 | unit->beer_temperature / 1000.0, target, heater, cooler, fan, door); |
104 | 555 | filename = xstrcpy(unit->name); |
556 | filename = xstrcat(filename, (char *)".log"); | |
557 | logger(filename, buf); | |
558 | free(filename); | |
559 | filename = NULL; | |
560 | } | |
561 | } | |
167
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
562 | |
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
563 | minutes++; |
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
564 | if (minutes == 60) |
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
565 | minutes = 0; |
56b008563db8
Fixed GET AIR|BEER commands. Save configuration every 30 minutes.
Michiel Broek <mbroek@mbse.eu>
parents:
165
diff
changeset
|
566 | |
174 | 567 | if ((minutes == 15) || (minutes == 45)) { |
568 | 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
|
569 | wrconfig(); |
174 | 570 | } |
64
2431965e8a8c
Write loglines only every 60 seconds
Michiel Broek <mbroek@mbse.eu>
parents:
63
diff
changeset
|
571 | } |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
572 | } |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
573 | usleep(100000); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
574 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
575 | } while (run); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
576 | |
182 | 577 | /* |
578 | * Stop units processing in a neat way | |
579 | */ | |
580 | for (unit = Config.units; unit; unit = unit->next) { | |
581 | /* | |
582 | * Turn everything off | |
583 | */ | |
584 | unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = 0; | |
585 | device_out(unit->heater_address, unit->heater_state); | |
586 | device_out(unit->cooler_address, unit->cooler_state); | |
587 | device_out(unit->fan_address, unit->fan_state); | |
588 | syslog(LOG_NOTICE, "Stopped unit %s mode %s", unit->name, UNITMODE[unit->mode]); | |
589 | } | |
590 | ||
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
591 | if (debug) |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
592 | fprintf(stdout, (char *)"Out of loop\n"); |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
593 | |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
594 | /* |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
595 | * Give threads time to cleanup |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
596 | */ |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
597 | usleep(1500000); |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
598 | |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
599 | #ifdef HAVE_WIRINGPI_H |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
600 | stopLCD(); |
66
805f1d285acd
Compiles with 1-wire bus on PC hardware
Michiel Broek <mbroek@mbse.eu>
parents:
64
diff
changeset
|
601 | #endif |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
602 | |
86
3d7a241329e2
Using final user paths for log, configuration and profiles
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
603 | wrconfig(); |
53 | 604 | |
41
f534ace74eea
Code preparation for client/server communication
Michiel Broek <mbroek@mbse.eu>
parents:
40
diff
changeset
|
605 | ulockprog((char *)"thermferm"); |
34 | 606 | |
28
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
607 | if (debug) |
32ed1ea4d0b6
Coolers working with a hardcode reference
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
608 | fprintf(stdout, "Goodbye\n"); |
26
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
609 | |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
610 | return 0; |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
611 | } |
9322c619c525
Added coolers program, first draft
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
612 |