Commit ac0ae6b0e71f4967feba1998d903e4c235ff9dea
1 parent
9e9f365e
HVC can now use the pump and the heater
Showing
3 changed files
with
62 additions
and
4 deletions
Show diff stats
@@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
9 | #include "printx.h" | 9 | #include "printx.h" |
10 | #include "ui.h" | 10 | #include "ui.h" |
11 | #include "nfc.h" | 11 | #include "nfc.h" |
12 | +#include "hvc.h" | ||
12 | 13 | ||
13 | #define CMD_MAX 70 | 14 | #define CMD_MAX 70 |
14 | 15 | ||
@@ -28,12 +29,32 @@ void processCmd(char* buffer) | @@ -28,12 +29,32 @@ void processCmd(char* buffer) | ||
28 | { | 29 | { |
29 | printx(INFO, BUS, "Exit request receved, processing ...\n"); | 30 | printx(INFO, BUS, "Exit request receved, processing ...\n"); |
30 | stopNFC(); | 31 | stopNFC(); |
31 | - //stopHVC(); | 32 | + stopHVC(); |
32 | stopBus(); | 33 | stopBus(); |
33 | stopUI(); | 34 | stopUI(); |
34 | } | 35 | } |
35 | - //else | ||
36 | - //printx(DEBUG, BUS, "STRLEN : %d and strcmp ret %d", strlen(buffer), strcmp(buffer, "quit")); | 36 | + else if(strcmp(buffer, "setpumpon") == 0) |
37 | + { | ||
38 | + printx(INFO, BUS, "Setting PUMP ON"); | ||
39 | + setPumpWantedState(true); | ||
40 | + } | ||
41 | + else if(strcmp(buffer, "setpumpoff") == 0) | ||
42 | + { | ||
43 | + printx(INFO, BUS, "Setting PUMP OFF"); | ||
44 | + setPumpWantedState(false); | ||
45 | + } | ||
46 | + else if(strcmp(buffer, "setheaton") == 0) | ||
47 | + { | ||
48 | + printx(INFO, BUS, "Setting HEAT ON"); | ||
49 | + setHeatWantedState(true); | ||
50 | + } | ||
51 | + else if(strcmp(buffer, "setheatoff") == 0) | ||
52 | + { | ||
53 | + printx(INFO, BUS, "Setting HEAT OFF"); | ||
54 | + setHeatWantedState(false); | ||
55 | + } | ||
56 | + | ||
57 | + //printx(DEBUG, BUS, "STRLEN : %d and strcmp ret %d", strlen(buffer), strcmp(buffer, "quit")); | ||
37 | } | 58 | } |
38 | 59 | ||
39 | void* processBus(void* we) | 60 | void* processBus(void* we) |
@@ -15,11 +15,15 @@ | @@ -15,11 +15,15 @@ | ||
15 | 15 | ||
16 | #define DEVICE1 "/dev/ttyACM1" | 16 | #define DEVICE1 "/dev/ttyACM1" |
17 | #define SPEED B19200 | 17 | #define SPEED B19200 |
18 | -#define HVC_POLLING_TIME 500000 | 18 | +#define HVC_POLLING_TIME 50000 |
19 | #define WAIT_BEFORE_RETRY 5000 | 19 | #define WAIT_BEFORE_RETRY 5000 |
20 | #define GET_DEVICE_MODEL 'A' | 20 | #define GET_DEVICE_MODEL 'A' |
21 | #define DEVICE_MODEL_HVC 'C' | 21 | #define DEVICE_MODEL_HVC 'C' |
22 | #define GET_TEMP 'H' | 22 | #define GET_TEMP 'H' |
23 | +#define SET_HEAT_ON 'E' | ||
24 | +#define SET_HEAT_OFF 'G' | ||
25 | +#define SET_PUMP_ON 'B' | ||
26 | +#define SET_PUMP_OFF 'D' | ||
23 | 27 | ||
24 | // Globals | 28 | // Globals |
25 | int hvc_fd = -1; | 29 | int hvc_fd = -1; |
@@ -27,6 +31,23 @@ bool hvcStop = false; | @@ -27,6 +31,23 @@ bool hvcStop = false; | ||
27 | bool sPump = false; | 31 | bool sPump = false; |
28 | bool sHeat = false; | 32 | bool sHeat = false; |
29 | struct termios hvcSaveterm; | 33 | struct termios hvcSaveterm; |
34 | +bool wHeat = false; | ||
35 | +bool wPump = false; | ||
36 | + | ||
37 | +void stopHVC() | ||
38 | +{ | ||
39 | + hvcStop = true; | ||
40 | +} | ||
41 | + | ||
42 | +void setPumpWantedState(bool s) | ||
43 | +{ | ||
44 | + wPump = s; | ||
45 | +} | ||
46 | + | ||
47 | +void setHeatWantedState(bool s) | ||
48 | +{ | ||
49 | + wHeat = s; | ||
50 | +} | ||
30 | 51 | ||
31 | bool initHVC() | 52 | bool initHVC() |
32 | { | 53 | { |
@@ -63,6 +84,20 @@ void* processHVC(void* we) | @@ -63,6 +84,20 @@ void* processHVC(void* we) | ||
63 | data = getData(&hvc_fd); | 84 | data = getData(&hvc_fd); |
64 | setTemp(data); | 85 | setTemp(data); |
65 | 86 | ||
87 | + if(wHeat ^ sHeat) | ||
88 | + { | ||
89 | + sendData(&hvc_fd, wHeat ? SET_HEAT_ON : SET_HEAT_OFF); | ||
90 | + sHeat = wHeat; | ||
91 | + setHeat(sHeat); | ||
92 | + } | ||
93 | + | ||
94 | + if(wPump ^ sPump) | ||
95 | + { | ||
96 | + sendData(&hvc_fd, wPump ? SET_PUMP_ON : SET_PUMP_OFF); | ||
97 | + sPump = wPump; | ||
98 | + setPump(sPump); | ||
99 | + } | ||
100 | + | ||
66 | usleep(HVC_POLLING_TIME); | 101 | usleep(HVC_POLLING_TIME); |
67 | } | 102 | } |
68 | 103 |