瀏覽代碼

resolves #14, #10 and #11

* reduced heartbeat to once every minute
* added diagnostic buttons
* added sound control and test button
clementinecomputing 6 年之前
父節點
當前提交
7c3e3be3ec

+ 3 - 5
busunit/DIUv2/diu_main.c

@@ -1263,8 +1263,9 @@ int main(int argc, char **argv) {
   time_t last_stale_gps_check = 0;
 
   long long int _usec_now, _usec_prv, _usec_del;
-
-  _usec_del = 1000000;
+  _usec_now = get_usec_time();
+  _usec_prv = _usec_now;
+  _usec_del = 60000000;
 
   // setup mongoose web server
   //
@@ -1303,9 +1304,6 @@ int main(int argc, char **argv) {
 
   clear_diu_messages();
 
-  _usec_now = get_usec_time();
-  _usec_prv = _usec_now;
-
   // This is the main dispatch loop:
   //
   // * reset watchdog to make sure we haven't crashed/frozen

+ 13 - 5
busunit/PIU/piu_main.c

@@ -311,6 +311,12 @@ int main(int argc, char **argv) {
 
   int i, j;
 
+  long long int _usec_now, _usec_prv, _usec_del;
+  _usec_now = get_usec_time();
+  _usec_prv = _usec_now;
+  _usec_del = 60000000;
+
+
   configure_signal_handlers(argv[0]);
   maintain_ipc_hub_connect(argv[0]);
 
@@ -335,12 +341,14 @@ int main(int argc, char **argv) {
 
     RESET_WATCHDOG();
 
+    //DEBUG
+    _usec_now = get_usec_time();
+    if ((_usec_now - _usec_prv) > _usec_del) {
+      printf("[%lli] piu_minder: heartbeat\n", get_usec_time());
+      _usec_prv = _usec_now;
+    }
+    //DEBUG
 
-    // DEBUG
-    //
-    printf("[%lli] piu_minder: heartbeat\n", get_usec_time());
-    //
-    // DEBUG
 
     maintain_ipc_hub_connect(argv[0]);
 

+ 10 - 1
busunit/avls/avls_communication.c

@@ -208,6 +208,11 @@ int main(int argc, char **argv)
 
     struct message_record incoming_msg;
 
+    long long int _usec_now, _usec_prv, _usec_del;
+    _usec_del = 60000000;
+    _usec_now = get_usec_time();
+    _usec_prv = _usec_now;
+
     //------------------
 
     load_avls_config();
@@ -227,7 +232,11 @@ int main(int argc, char **argv)
         RESET_WATCHDOG();
 
         //DEBUG
-        printf("[%lli] avls: heartbeat\n", get_usec_time());
+        _usec_now = get_usec_time();
+        if ((_usec_now - _usec_prv) > _usec_del) {
+          printf("[%lli] avls: heartbeat\n", get_usec_time());
+          _usec_prv = _usec_now;
+        }
         //DEBUG
 
         if(hup_request_status)

+ 10 - 1
busunit/billdb/bill_communication.c

@@ -449,6 +449,11 @@ int main(int argc, char **argv)
     int input_idx = 0;
     int checked_idx = 0;
 
+    long long int _usec_now, _usec_prv, _usec_del;
+    _usec_del = 60000000;
+    _usec_now = get_usec_time();
+    _usec_prv = _usec_now;
+
     billdb_context ctx = {0};
 
 
@@ -494,7 +499,11 @@ int main(int argc, char **argv)
         RESET_WATCHDOG();
 
         //DEBUG
-        printf("[%lli] billdb: heartbeat\n", get_usec_time());
+        _usec_now = get_usec_time();
+        if ((_usec_now - _usec_prv) > _usec_del) {
+          printf("[%lli] billdb: heartbeat\n", get_usec_time());
+          _usec_prv = _usec_now;
+        }
         //DEBUG
 
         maintain_ipc_hub_connect(argv[0]);

+ 11 - 1
busunit/commhub/commserver.c

@@ -852,6 +852,11 @@ int main(int argc, char **argv)
     int rebuild;
     struct message_record msg;
 
+    long long int _usec_now, _usec_prv, _usec_del;
+    _usec_del = 60000000;
+    _usec_now = get_usec_time();
+    _usec_prv = _usec_now;
+
     //Install our signal handlers and watchdog
     configure_signal_handlers(argv[0]);
 
@@ -878,9 +883,14 @@ int main(int argc, char **argv)
     {
 
       //DEBUG
-      printf("[%lli] ipc_server: heartbeat\n", get_usec_time());
+      _usec_now = get_usec_time();
+      if ((_usec_now - _usec_prv) > _usec_del) {
+        printf("[%lli] ipc_server: heartbeat\n", get_usec_time());
+        _usec_prv = _usec_now;
+      }
       //DEBUG
 
+
         RESET_WATCHDOG();
         
         if(rebuild)	//if we have been flagged to rebuild our client fd list

+ 22 - 4
busunit/gps/gps_main.c

@@ -526,6 +526,16 @@ int main(int argc, char **argv) {
   time_t now;
   time_t last_stale_gps_check = 0;
 
+  long long int _usec_now, _usec_prv, _usec_del;
+  _usec_now = get_usec_time();
+  _usec_prv = _usec_now;
+  _usec_del = 60000000;
+
+  long long int _usec_ratelimit_now, _usec_ratelimit_prv, _usec_ratelimit_del;
+  _usec_ratelimit_now = get_usec_time();
+  _usec_ratelimit_del = 1000000;
+  _usec_ratelimit_prv = _usec_ratelimit_now - _usec_ratelimit_del;
+
   // Configure our signal handlers to deal with SIGINT, SIGTERM, etc... 
   // and make graceful exits while logging
   //
@@ -544,19 +554,27 @@ int main(int argc, char **argv) {
   //
   while( exit_request_status == EXIT_REQUEST_NONE ) {
 
+    RESET_WATCHDOG();
+
     //DEBUG
-    printf("[%lli] gps_minder: heartbeat\n", get_usec_time());
+    _usec_now = get_usec_time();
+    if ((_usec_now - _usec_prv) > _usec_del) {
+      printf("[%lli] gps_minder: heartbeat\n", get_usec_time());
+      _usec_prv = _usec_now;
+    }
     //DEBUG
 
-    RESET_WATCHDOG();
-
     maintain_ipc_hub_connect(argv[0]);
 
     if(gps_fd < 0) {
       gps_fd = open_rs232_device(GPS_PORT, GPS_DEFAULT_BAUD, RS232_LINE);
 
       if(gps_fd < 0) {
-        fprintf(stderr, "Cannot open serial port %s for GPS!\n", GPS_PORT);
+        _usec_ratelimit_now = get_usec_time();
+        if ((_usec_ratelimit_now - _usec_ratelimit_prv) > _usec_ratelimit_del) {
+          fprintf(stderr, "Cannot open serial port %s for GPS!\n", GPS_PORT);
+          _usec_ratelimit_prv = _usec_ratelimit_now;
+        }
       }
 
     }

+ 11 - 1
busunit/paddlemgr/paddlemgr.c

@@ -400,6 +400,11 @@ int main(int argc, char **argv)
 
   struct message_record incoming_msg;
 
+  long long int _usec_now, _usec_prv, _usec_del;
+  _usec_now = get_usec_time();
+  _usec_prv = _usec_now;
+  _usec_del = 60000000;
+
   configure_signal_handlers(argv[0]);
   maintain_ipc_hub_connect(argv[0]);
 
@@ -418,9 +423,14 @@ int main(int argc, char **argv)
     RESET_WATCHDOG();
 
     //DEBUG
-    printf("[%lli] paddlemgr: heartbeat\n", get_usec_time());
+    _usec_now = get_usec_time();
+    if ((_usec_now - _usec_prv) > _usec_del) {
+      printf("[%lli] paddlemgr: heartbeat\n", get_usec_time());
+      _usec_prv = _usec_now;
+    }
     //DEBUG
 
+
     maintain_ipc_hub_connect(argv[0]);
 
     nfds=0;

+ 11 - 1
busunit/passdb/pass_communication.c

@@ -1041,6 +1041,11 @@ int main(int argc, char **argv)
     int input_idx = 0;
     int checked_idx = 0;
 
+		long long int _usec_now, _usec_prv, _usec_del;
+		_usec_now = get_usec_time();
+		_usec_prv = _usec_now;
+		_usec_del = 60000000;
+
     passdb_context ctx = {0};
 
     passdb_context_alloc(&ctx);
@@ -1101,9 +1106,14 @@ int main(int argc, char **argv)
         RESET_WATCHDOG();
 
         //DEBUG
-        printf("[%lli] passdb: heartbeat\n", get_usec_time());
+        _usec_now = get_usec_time();
+        if ((_usec_now - _usec_prv) > _usec_del) {
+          printf("[%lli] passdb: heartbeat\n", get_usec_time());
+          _usec_prv = _usec_now;
+        }
         //DEBUG
 
+
         maintain_ipc_hub_connect(argv[0]);
 
         if( (now - last_piu_update) > 0)