瀏覽代碼

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

clementinecomputing 6 年之前
父節點
當前提交
090b766777
共有 4 個文件被更改,包括 215 次插入7 次删除
  1. 24 1
      aux/deploy-busunit-interactive
  2. 27 6
      busunit/gps/gps_main.c
  3. 7 0
      busunit/scripts/rc.local
  4. 157 0
      busunit/scripts/reset-gps.py

+ 24 - 1
aux/deploy-busunit-interactive

@@ -122,6 +122,7 @@ read createbususer
 if [[ "$createbususer" =~ ^[yY]?$ ]]; then
   echo "... creating 'bus' user and group"
   sudo adduser bus
+  sudo usermod -a -G dialout bus
 fi
 
 echo ""
@@ -177,11 +178,12 @@ sudo chown -R bus:bus /home/bus/popufare
 sudo bash -c " su - bus -c ' cd /home/bus/popufare/busunit ; ./build_all.sh native ; ' "
 sudo bash -c " cd /home/bus/bin ; ln -s $d/avls . ; ln -s $d/billdb . ; ln -s $d/client_supervisor . ; ln -s $d/debug_client . ; ln -s $d/diu_minder . ; ln -s $d/ipc_server . "
 sudo bash -c " cd /home/bus/bin ; ln -s $d/paddlemgr . ; ln -s $d/passdb . ; ln -s $d/piu_minder . ; ln -s $d/send_billing_record . ; ln -s $d/send_magstripe . "
+sudo bash -c " cd /home/bus/bin ; ln -s $d/gps_minder . "
 
 sudo bash -c " cd /home/bus/bin ; ln -s $bd/DIUv2/diu_kiosk . "
 
 sudo bash -c " cd /home/bus/bin ; ln -s $bd/scripts/init_bus.sh . ; ln -s $bd/scripts/update_loop.sh . ; ln -s $bd/scripts/setup-serial.py . ; ln -s $bd/scripts/get_net_ids.sh . "
-sudo bash -c " cd /home/bus/bin ; ln -s $bd/scripts/connection_tether.sh . "
+sudo bash -c " cd /home/bus/bin ; ln -s $bd/scripts/connection_tether.sh . ; ln -s $bd/scripts/reset-gps.py ./reset-gps "
 
 sudo bash -c " cd /home/bus/config ; ln -s $diudir/html . ; "
 sudo bash -c " cd /home/bus/config ; cp $bd/passdb/init.scm . ; cp $bd/passdb/rfid_patterns.txt . "
@@ -189,6 +191,16 @@ sudo bash -c " cp $tc/equipnum.txt . ; cp $tc/config.tgz.checksum . ; cp $tc/con
 
 sudo bash -c " rm -f /home/bus/bin/common_values.sh ; cp $bd/scripts/common_values.sh /home/bus/bin "
 
+## server endpoint config files
+##
+## sync_server_desc, sync_target, server_list, syn_port
+sudo cp /home/bus/popufare/busunit/testing/config/config.tgz.checksum /home/bus/config/config.tgz.checksum
+sudo cp /home/bus/popufare/busunit/testing/config/config.tgz.version /home/bus/config/config.tgz.version
+sudo cp /home/bus/popufare/busunit/testing/config/firmware.tgz.checksum /home/bus/config/firmware.tgz.checksum
+sudo cp /home/bus/popufare/busunit/testing/config/firmware.tgz.version /home/bus/config/firmware.tgz.version
+
+sudo mkdir -p /home/bus/config/server
+
 echo ""
 
 ##### paddle setup
@@ -408,6 +420,17 @@ if [[ "$setupsound" =~ ^[yY]$ ]] ; then
   echo '  adding> snd-bcm2835'
   sudo bash -c 'echo "snd-bcm2835" >> /etc/modules'
 
+  # trying to mitigate the 'first two seconds cutoff of audio' problem
+  # https://github.com/alexa-pi/AlexaPi/wiki/Devices#raspberry-pi
+  #
+  tfn=`mktemp`
+  echo '@reboot vcgencmd force_audio hdmi 1' > $tfn
+
+  echo "adding `cat $tfn`"
+
+  sudo crontab $tfn
+  rm $tfn
+
 fi
 
 ##### Setup kiosk

+ 27 - 6
busunit/gps/gps_main.c

@@ -483,11 +483,38 @@ void maintain_ipc_hub_connect(char *progname) {
   }
 }
 
+// This might be better done at a higher level but kept here
+// in case we need it.
+//
+int reset_gps() {
+  char msg_gps_off[] = "AT+CGPS=0\n",
+       msg_gps_on[] = "AT+CGPS=1\n",
+       msg_gps_poll_off[] = "AT+CGPSINFOCFG=0\n",
+       msg_gps_poll_on[] = "AT+CGPSINFOCFG=3,31\n";
+  size_t n;
+
+  if (gps_fd < 0) { return -1; }
+
+  n = stlren(msg_gps_off)+1;
+  write(gps_fd, msg_gps_off, n);
+
+  n = stlren(msg_gps_poll_off)+1;
+  write(gps_fd, msg_gps_poll_off, n);
 
+  n = stlren(msg_gps_on)+1;
+  write(gps_fd, msg_gps_on, n);
+
+  n = stlren(msg_gps_poll_on)+1;
+  write(gps_fd, msg_gps_poll_on, n);
+
+  return 0;
+}
 
 //----------------------------------
 
 int main(int argc, char **argv) {
+  int i;
+
   char line[LINE_BUFFER_SIZE] = {0};
 
   struct message_record incoming_msg;
@@ -499,15 +526,9 @@ int main(int argc, char **argv) {
   int poll_return;
   int read_return;
 
-  int i;
-
   time_t now;
-
-  //int retval = 0;
-
   time_t last_stale_gps_check = 0;
 
-
   // Configure our signal handlers to deal with SIGINT, SIGTERM, etc... 
   // and make graceful exits while logging
   //

+ 7 - 0
busunit/scripts/rc.local

@@ -30,4 +30,11 @@ sleep 2
 /home/bus/bin/update_loop.sh 2>&1 >> /tmp/run.log &
 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
+
 exit 0

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

@@ -0,0 +1,157 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+#
+# This file is part of PopuFare.
+#
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+import os
+import serial
+import sys
+import re
+import time
+from os import listdir
+from os.path import isfile, join
+from os import system
+
+GPS_BAUD = 115200
+FREQ_SECOND = 3
+BITMASK = 31
+
+DEVGPS = "/dev/ttyGPS"
+
+DEBUG = True
+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+CGPSINFOCFG=" + str(FREQ_SECOND) + "," + str(BITMASK) 
+
+ser.write("AT+CGPSINFOCFG=" + str(FREQ_SECOND) + "," + str(BITMASK) + "\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 "closing connection"
+ser.close()
+
+sys.exit(0);
+
+###
+###
+
+#if DEBUG: print "send:", "AT"
+#
+#ser.write("\rAT\r")
+#ser.flush()
+#
+#resp = ser.readline()
+#if not re.search(r'[aA][tT]', resp):
+#  print "ERROR: got response: '" + str(resp) + "', expecting 'OK', exiting"
+#  sys.exit(-1)
+#
+#resp = ser.readline()
+#if not re.search(r'[oO][kK]', resp):
+#  print "ERROR: got response: '" + str(resp) + "', expecting 'OK', exiting"
+#  sys.exit(-1)
+#
+#if DEBUG: print "got:", resp
+#
+###
+###
+
+if DEBUG: print "send:", "AT+CGPSINFOCFG=0"
+
+ser.write("AT+CGPSINFOCFG=0\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()
+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+CGPS=0"
+
+ser.write("AT+CGPS=0\r")
+ser.flush()
+
+resp = ser.readline()
+if not  re.search(r'[aA][tT]', resp): print "WARNING: got response: '" + str(resp) + "', expecting 'OK'. continuing"
+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(2)
+
+###
+###
+
+if DEBUG: print "send:", "AT+CGPS=1"
+
+ser.write("AT+CGPS=1\r")
+ser.flush()
+resp = ser.readline()
+if not  re.search(r'[aA][tT]', resp): print "WARNING: got response: '" + str(resp) + "', expecting 'OK'. continuing"
+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")
+ser.flush()
+resp = ser.readline()
+if not  re.search(r'[aA][tT]', resp): print "WARNING: got response: '" + str(resp) + "', expecting 'OK'. continuing"
+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 "closing connection"
+ser.close()