Commit 2bc2194a3caa0c961e0273f44cf942287bb893c8

Authored by henyxia
1 parent 2c7e20e4

Revert "Fixed some printx"

This reverts commit 846585f9ccacd0022ecbbb6806071766ef90dcdd.
Showing 4 changed files with 8 additions and 22 deletions   Show diff stats
.gitignore
... ... @@ -2,4 +2,3 @@
2 2 *.o
3 3 tweekd
4 4 *.log
5   -*.csv
... ...
... ... @@ -35,42 +35,36 @@ void processCmd(char* buffer)
35 35 }
36 36 else if(strcmp(buffer, "setpumpon") == 0)
37 37 {
38   - printx(INFO, BUS, "Setting PUMP ON\n");
  38 + printx(INFO, BUS, "Setting PUMP ON");
39 39 setPumpWantedState(true);
40 40 }
41 41 else if(strcmp(buffer, "setpumpoff") == 0)
42 42 {
43   - printx(INFO, BUS, "Setting PUMP OFF\n");
  43 + printx(INFO, BUS, "Setting PUMP OFF");
44 44 setPumpWantedState(false);
45 45 }
46 46 else if(strcmp(buffer, "setheaton") == 0)
47 47 {
48   - printx(INFO, BUS, "Setting HEAT ON\n");
  48 + printx(INFO, BUS, "Setting HEAT ON");
49 49 setHeatWantedState(true);
50 50 }
51 51 else if(strcmp(buffer, "setheatoff") == 0)
52 52 {
53   - printx(INFO, BUS, "Setting HEAT OFF\n");
  53 + printx(INFO, BUS, "Setting HEAT OFF");
54 54 setHeatWantedState(false);
55 55 }
56 56 else if(strcmp(buffer, "setheaton5s") == 0)
57 57 {
58   - printx(INFO, BUS, "Setting HEAT ON for 5 secs\n");
  58 + printx(INFO, BUS, "Setting HEAT ON for 5 secs");
59 59 setHeatTimer(5);
60 60 setHeatWantedState(true);
61 61 }
62 62 else if(strcmp(buffer, "setpumpon5s") == 0)
63 63 {
64   - printx(INFO, BUS, "Setting PUMP ON for 5 secs\n");
  64 + printx(INFO, BUS, "Setting PUMP ON for 5 secs");
65 65 setPumpTimer(5);
66 66 setPumpWantedState(true);
67 67 }
68   - else if(strcmp(buffer, "setheaton35s") == 0)
69   - {
70   - printx(INFO, BUS, "Setting HEAT ON for 35 secs\n");
71   - setHeatTimer(35);
72   - setHeatWantedState(true);
73   - }
74 68  
75 69 //printx(DEBUG, BUS, "STRLEN : %d and strcmp ret %d", strlen(buffer), strcmp(buffer, "quit"));
76 70 }
... ... @@ -87,8 +81,7 @@ void* processBus(void* we)
87 81 printx(DEBUG, BUS, "Event receved !\n");
88 82 busFree = false;
89 83 lseek(bus, 0, SEEK_SET);
90   - read(bus, buffer, CMD_MAX);
91   - //printx(DEBUG, BUS, "Data read %d\n", read(bus, buffer, CMD_MAX));
  84 + printx(DEBUG, BUS, "Data read %d\n", read(bus, buffer, CMD_MAX));
92 85 ftruncate(bus, 0);
93 86 sync();
94 87 processCmd(buffer);
... ...
... ... @@ -104,7 +104,6 @@ void* processHVC(void* we)
104 104 sendData(&hvc_fd, GET_TEMP);
105 105 data = getData(&hvc_fd);
106 106 setTemp(data);
107   - printx(DEBUG, HVC, "TEMP %d\n", data);
108 107  
109 108 if(tHeatTimer > 0)
110 109 {
... ... @@ -113,7 +112,6 @@ void* processHVC(void* we)
113 112 {
114 113 wHeat = false;
115 114 tHeatTimer = 0;
116   - printx(INFO, HVC, "Shutting down HEAT according to timer\n");
117 115 }
118 116  
119 117 }
... ... @@ -125,7 +123,6 @@ void* processHVC(void* we)
125 123 {
126 124 wPump = false;
127 125 tPumpTimer = 0;
128   - printx(INFO, HVC, "Shutting down PUMP according to timer\n");
129 126 }
130 127 }
131 128  
... ...
printx.c
... ... @@ -14,7 +14,6 @@
14 14 FILE* logfile = NULL;
15 15 char s_color[4][12] = {"\x1b[01;31m", "\x1b[01;33m", "\x1b[01;32m", "\x1b[01;36m"};
16 16 char f_name[5][5] = {"MAIN", "UI ", "NFC ", "HVC ", "BUS "};
17   -time_t start;
18 17  
19 18 void removeCharFromString(char c, char *str)
20 19 {
... ... @@ -27,7 +26,6 @@ void removeCharFromString(char c, char *str)
27 26  
28 27 bool initLog()
29 28 {
30   - start = clock();
31 29 char filename[FILENAME_LENGTH];
32 30 time_t now = time(NULL);
33 31  
... ... @@ -55,11 +53,10 @@ void printx(severity s, msgfrom from, char* str, ...)
55 53 {
56 54 char buffer1[MAX_BUFFER];
57 55 char buffer2[MAX_BUFFER];
58   - time_t now = clock();
59 56 va_list arglist;
60 57 va_start(arglist, str);
61 58 vsprintf(buffer1, str, arglist);
62   - fprintf(logfile, "[%6lu] %s", (now - start)/CLOCKS_PER_SEC , buffer1);
  59 + fprintf(logfile, buffer1);
63 60 fflush(logfile);
64 61 sprintf(buffer2, "[%s] %s%s%s", f_name[from], s_color[s], buffer1, S_RESET);
65 62 removeCharFromString('\n', buffer2);
... ...