瀏覽代碼

Merge branch 'master' of https://tree.clementinecomputing.com/clementinecomputing/popufare

clementinecomputing 6 年之前
父節點
當前提交
7f610d06c9
共有 5 個文件被更改,包括 41 次插入21 次删除
  1. 1 1
      busunit/DIUv2/buildit.sh
  2. 1 1
      busunit/DIUv2/diu_main.c
  3. 13 16
      busunit/gps/gps_main.c
  4. 2 3
      busunit/scripts/rc.local
  5. 24 0
      busunit/scripts/reset-gps.py

+ 1 - 1
busunit/DIUv2/buildit.sh

@@ -3,4 +3,4 @@
 common_stuff="../commhub/commhub.c ../commhub/client_utils.c ../common/common_defs.c"
 
 rm -f diu_minder
-$target_cc $target_ccopts -o diu_minder diu_main.c touchscreen.c driver.c mongoose.c mkgmtime.c $common_stuff -lcrypto
+$target_cc $target_ccopts -Wno-format-truncation -o diu_minder diu_main.c touchscreen.c driver.c mongoose.c mkgmtime.c $common_stuff -lcrypto

+ 1 - 1
busunit/DIUv2/diu_main.c

@@ -373,7 +373,7 @@ int update_gps(char *in)
                 //     Pass the time field (f1) and the date field (f9) in to the routine that sets the system clock if needed.
                 // (this routine also stores the utc timestamp derived from the GPS date and time fields so it can be passed to
                 // other modules that may have a need for this information).
-                handle_gps_time(f1,f9);
+                //handle_gps_time(f1,f9);
             }
         }
 

+ 13 - 16
busunit/gps/gps_main.c

@@ -53,7 +53,7 @@ int handle_gps_time(float gtime, int date) {
   int day,month,year;
   int hour,min,sec,frac;
   int n = 0;
-  time_t utc,now;
+  time_t utc, now;
 
   char buffer[32] = {0};
 
@@ -64,18 +64,16 @@ int handle_gps_time(float gtime, int date) {
   day = month = year = 0; 
   hour = min = sec = frac = 0;
 
-     
   //  Just to be *ahem* clear, as per NMEA standard the date is encoded DDMMYY, and the time of day
   // is encoded HHMMSS[.frac] where there is an optional fractional second field denoted by a decimal point.
   // we must be able to decode the fractional seconds field but we discard the information since it is not
   // reliable enough to be worth the bother.
   //
 
-
   // Start out with zero parsed fields
   //
   n = 0;
-     
+
   //  Construct and then re-parse the time from its icky format to discrete values (this should result
   // in at least three (possibly four) fields.
   //
@@ -165,7 +163,7 @@ static int handle_stale_gps_condition() {
   // MAILBOX_GPS_STATUS.
   //
   int return_code = 0;
-     
+
   //   This will hold the gps_good flag as it stood at the beginning of this subroutine
   // previous to any adjustments we make.
   //
@@ -190,7 +188,7 @@ static int handle_stale_gps_condition() {
     }
 
   }
-     
+
   //   If we have determined that we need to declare the GPS data stale and invalid and
   // we have a valid connection to the IPC hub we should use that IPC hub connection to
   // add a note to the diagnostic log indicating that we've declared the GPS data stale.
@@ -346,23 +344,24 @@ int update_gps(char *in) {
       //   Require at least MIN_SATS_FOR_TIME satellites to accept a new system clock value from the GPS unit.
       // This is to keep a crummy GPS fix from generating a bogus or unstable system time.
       //
-  
+
       if(my_gps_stat.num_sats >= MIN_SATS_FOR_TIME) {
 
         //   Pass the time field (f1) and the date field (f9) in to the routine that sets the system clock if needed.
         // (this routine also stores the utc timestamp derived from the GPS date and time fields so it can be passed to
         // other modules that may have a need for this information).
         //
-        handle_gps_time(f1,(int)f9);
+        //handle_gps_time(f1,(int)f9);
 
       }
     }
 
     if(num > 0) {
+
       // update snapshot with latitude
       //
       my_gps_stat.lat = f3 * ((f4 == 'N')?(1):(-1));
-  
+
       // longitude
       //
       my_gps_stat.lon = f5 * ((f6 == 'E')?(1):(-1));
@@ -378,7 +377,7 @@ int update_gps(char *in) {
       // update snapshot's staledate
       //
       my_gps_stat.stamp = time(NULL);
-      
+
       return_code |= 1;
 
     }
@@ -414,8 +413,6 @@ int update_gps(char *in) {
         //
         my_gps_stat.num_sats = f7;
 
-
-           
         //   Do NOT store the timestamp since we only want to remember timestamps of position
         // fixes and the GPGGA message is all metadata (number of satellites, fix quality, etc...).
         // It is worth noting that GPGGA does report altitude, but that is not a piece of information
@@ -495,16 +492,16 @@ int reset_gps() {
 
   if (gps_fd < 0) { return -1; }
 
-  n = stlren(msg_gps_off)+1;
+  n = strlen(msg_gps_off)+1;
   write(gps_fd, msg_gps_off, n);
 
-  n = stlren(msg_gps_poll_off)+1;
+  n = strlen(msg_gps_poll_off)+1;
   write(gps_fd, msg_gps_poll_off, n);
 
-  n = stlren(msg_gps_on)+1;
+  n = strlen(msg_gps_on)+1;
   write(gps_fd, msg_gps_on, n);
 
-  n = stlren(msg_gps_poll_on)+1;
+  n = strlen(msg_gps_poll_on)+1;
   write(gps_fd, msg_gps_poll_on, n);
 
   return 0;

+ 2 - 3
busunit/scripts/rc.local

@@ -33,8 +33,7 @@ sleep 2
 /home/bus/bin/reset-gps 2>&1 >> /tmp/gps.log &
 sleep 2
 
-
-vcgencmd force_audio hdmi 1 2>&1 >> /tmp/audio.log &
-sleep 1
+#vcgencmd force_audio hdmi 1 2>&1 >> /tmp/audio.log &
+#sleep 1
 
 exit 0

+ 24 - 0
busunit/scripts/reset-gps.py

@@ -41,6 +41,30 @@ VERBOSE = True
 
 ser = serial.Serial(DEVGPS, GPS_BAUD, bytesize=8, parity='N', stopbits=1, timeout=1, xonxoff=0, rtscts=0)
 
+###
+###
+
+
+if DEBUG: print "send:", "AT+CGPS=1"
+
+ser.write("AT+CGPS=1\r")
+ser.flush()
+resp = ser.readline()
+while (len(resp) > 0) and (resp[0] == '$'):
+  resp = ser.readline()
+if not  re.search(r'[aA][tT]', resp): print "WARNING: got response: '" + str(resp) + "', expecting 'OK'. continuing"
+resp = ser.readline()
+while (len(resp) > 0) and (resp[0] == '$'):
+  resp = ser.readline()
+if not  re.search(r'[oO][kK]', resp): print "WARNING: got response: '" + str(resp) + "', expecting 'OK'. continuing"
+
+if DEBUG: print "got:", resp
+
+time.sleep(1)
+
+###
+###
+
 if DEBUG: print "send:", "AT+CGPSINFOCFG=" + str(FREQ_SECOND) + "," + str(BITMASK) 
 
 ser.write("AT+CGPSINFOCFG=" + str(FREQ_SECOND) + "," + str(BITMASK) + "\r")