Procházet zdrojové kódy

mostly cleanup but some fixes:

* signal variables now are sig_atomic_t to prevent race conditions
* GPS baud now default to 115200
* added gps minder to modules list
Abram Connelly před 6 roky
rodič
revize
79bcb4a9be

+ 1 - 0
busunit/client_modules.list

@@ -6,3 +6,4 @@ PIU
 DIUv2
 paddlemgr
 client_supervisor
+gps

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1151 - 964
busunit/client_supervisor/client_supervisor.c


+ 2 - 1
busunit/common/common_defs.h

@@ -178,7 +178,8 @@ int open_rs232_device(char *devname, int custom_baud, int linemode);
 //Defines for the above
 
 #define USE_DEFAULT_BAUD	(0)
-#define GPS_DEFAULT_BAUD (9600)
+//#define GPS_DEFAULT_BAUD (9600)
+#define GPS_DEFAULT_BAUD (115200)
 
 #define RS232_RAW		(0)
 #define RS232_LINE		(1)

+ 17 - 39
busunit/gps/gps_main.c

@@ -522,23 +522,9 @@ int main(int argc, char **argv) {
   //
   register_system_status_callbacks();
 
-
-  // This is the main dispatch loop:
-  //
-  // * reset watchdog to make sure we haven't crashed/frozen
-  // * if need be, open a connection to the DIU microcontroller, quieting all messages except for acks
-  // * handle GPS message dispatch through IPC
-  // * if need be, handle reload of menu.xml
-  // * manage driver status message communication
-  // * handle paddle change
-  // * draw menu
-  // * listen on the mailboxes for messages and process. This includes
-  //   - touchscreen events
-  //   - gps updates
-  //   - warning/debug/error messages
+  // loop until we get asked to exit...
   //
-  while( exit_request_status == EXIT_REQUEST_NONE )  //loop until we get asked to exit...
-  {
+  while( exit_request_status == EXIT_REQUEST_NONE ) {
 
     //DEBUG
     printf("[%lli] gps_minder: heartbeat\n", get_usec_time());
@@ -599,16 +585,14 @@ int main(int argc, char **argv) {
 
     nfd = 0;
 
-    if(hub_fd >= 0)
-    {
+    if(hub_fd >= 0) {
       fds[nfd].fd = hub_fd;
       fds[nfd].events = POLLIN;
       fds[nfd].revents = 0;
       nfd++;
     }
 
-    if(gps_fd >= 0)
-    {
+    if(gps_fd >= 0) {
       fds[nfd].fd = gps_fd;
       fds[nfd].events = POLLIN;
       fds[nfd].revents = 0;
@@ -632,7 +616,7 @@ int main(int argc, char **argv) {
 
     // if poll didn't net us any work to do,
     //
-    if(poll_return < 1) {
+    if (poll_return < 1) {
       // lets try again
       //
       continue;
@@ -640,15 +624,15 @@ int main(int argc, char **argv) {
 
     // Loop through all polled file descriptors
     //
-    for(i = 0; i < nfd; i++) {
+    for (i = 0; i < nfd; i++) {
 
       // If we're looking at the DIU...
       //
-      if( fds[i].fd == gps_fd ) {
+      if ( fds[i].fd == gps_fd ) {
 
         // if poll says our serial port has become bogus...
         //
-        if(fds[i].revents & (POLLHUP | POLLERR | POLLNVAL)) {
+        if (fds[i].revents & (POLLHUP | POLLERR | POLLNVAL)) {
           fprintf(stderr, "This is very odd... Poll returned flags %d on our serial port...\n", fds[i].revents);
 
           // close it, flag as invalid, 
@@ -659,10 +643,10 @@ int main(int argc, char **argv) {
           break;    
         }
 
-        if(fds[i].revents & POLLIN) {
+        if (fds[i].revents & POLLIN) {
           read_return = read(fds[i].fd, line, sizeof(line));
 
-          if(read_return > 0) {
+          if (read_return > 0) {
             char *trav = line;
 
             line[read_return] = '\0';
@@ -670,14 +654,14 @@ int main(int argc, char **argv) {
 
             // advance until EOL or we hit our start sentinel
             //
-            while(*trav && (*trav != '$') ) {
+            while (*trav && (*trav != '$') ) {
               trav++;
             }
 
             // Check to see that our address header is intact...
             //
             if (trav[0] == '$') {
-              switch(trav[1]) {
+              switch (trav[1]) {
 
                 case 'G':  //-----------------------------------"/G:" means it is a new GPS input
 
@@ -729,7 +713,7 @@ int main(int argc, char **argv) {
 
       // If we're looking at the IPC hub...
       //
-      else if( fds[i].fd == hub_fd ) {
+      else if ( fds[i].fd == hub_fd ) {
 
         // if poll says our connection to the IPC hub has died...
         //
@@ -746,11 +730,11 @@ int main(int argc, char **argv) {
 
         // if we have mail in any of our mailboxes...
         //
-        if(fds[i].revents & POLLIN) {
+        if (fds[i].revents & POLLIN) {
 
           read_return = get_message(hub_fd, &incoming_msg);
 
-          if(read_return < 0) {
+          if (read_return < 0) {
             fprintf(stderr, "The connection to the IPC hub has gone away...\n");  //complain
 
             // close it, flag it invalid and break out of the
@@ -772,14 +756,8 @@ int main(int argc, char **argv) {
     }
   }
 
-
-  if(hub_fd >= 0) {
-    close(hub_fd);
-  }
-
-  if(gps_fd >= 0) {
-    close(gps_fd);
-  }
+  if (hub_fd >= 0) { close(hub_fd); }
+  if (gps_fd >= 0) { close(gps_fd); }
 
   return 0;
 }