-
Notifications
You must be signed in to change notification settings - Fork 0
/
fireman.c
57 lines (46 loc) · 1.29 KB
/
fireman.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <stdlib.h>
#include "gpio.h"
#include "test.h"
#include "config.h"
int main(int argc, char *argv[], char **envp)
{
if (argc != 2) {
fprintf(stderr, "Bad argument. Usage : %s [config file path]\n", argv[0]);
exit(-1);
}
setupConfig(argv[1]);
setupGpio();
int warningLightState = getWarningLightState();
int testState = getTestState();
if (testState == 0) {
if (getConfigDebug() == 1) {
printf("TEST NOK\n");
}
if (!warningLightState) {
char *bashFailFilePath = getConfigBashFail();
if (0 != strcmp(bashFailFilePath, "false")) {
runBashScript(bashFailFilePath);
}
setWarningLightState(1);
int i;
for (i = 0; i<2; i++) {
morse();
sleep(1);
}
}
} else {
if (getConfigDebug() == 1) {
printf("TEST OK\n");
}
if (warningLightState) {
setWarningLightState(0);
victory();
char *bashSuccessFilePath = getConfigBashSuccess();
if (0 != strcmp(bashSuccessFilePath, "false")) {
runBashScript(bashSuccessFilePath);
}
}
}
return 0;
}