Ver Fonte

wip

* still trying to get ppp working on bootup
clementinecomputing há 6 anos atrás
pai
commit
a4b8f0f466

+ 11 - 7
busunit/scripts/connection_tether-ppp.sh

@@ -18,7 +18,11 @@
 # along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
 #
 
-. $HOME/bin/common_values.sh 
+export BASEDIR='/home/bus/'
+
+echo "## connection_tether-ppp $BASEDIR"
+
+. $BASEDIR/bin/common_values.sh
 
 # Do this once at boot time, but do it again after a tunnel abort request...
 #
@@ -80,7 +84,7 @@ perform_post_connect_checkin()
   imsi="`output_net_ids_field IMSI`"
   mac="`output_net_ids_field ETH0`"
 
-  #     Send these gathered data to the update daemon.  The leading '#' tells the server that this is a 
+  #     Send these gathered data to the update daemon.  The leading '#' tells the server that this is a
   #checkin, not an update request.
   echo -e "#$busunitnum\t$equipnum\t$mac\t$imei\t$imsi\t$version" | nc -q1 localhost $UPDATE_DAEMON_PORT
 }
@@ -89,7 +93,7 @@ perform_post_connect_checkin()
 # the network by equipment number, serial number, or bus number. The three parameters are:
 #
 # 1:   The path to the file containing the identifying number
-# 2:   The base port number on the remote server to add the identifying number to to get the server-side port that will 
+# 2:   The base port number on the remote server to add the identifying number to to get the server-side port that will
 #    forward to port 22 (sshd) on the client side.
 # 3:   An optional parameter which if present is taken as a set of command line flags to cut to apply to the contents
 #    of the file specified by $1 to extract the numeric component (for instance, serial numbers may be in the form XYZ-1234
@@ -108,7 +112,7 @@ generate_reverse_phonehome_component()
       #Grab the desired substring
       num="`cat $file | cut $cut_cmdline`"
     else
-      #Grab its contents   
+      #Grab its contents
       num="`cat $file`";
     fi
 
@@ -162,7 +166,7 @@ clean_up_after_tunnel_teardown()
     #Sleep until it is time to try again
     /bin/sleep $SLEEP_AFTER_TUNNEL_ABORT
 
-    
+
   else
     #OTHERWISE, we assume that the modem lost signal, or the router or remote server went wonky...
 
@@ -180,7 +184,7 @@ clean_up_after_tunnel_teardown()
     debug_print "Sleeping before any retry attempts..."
     #Sleep before trying this again...
     /bin/sleep $SLEEP_AFTER_TUNNEL_FAILURE
-  
+
   fi
 }
 
@@ -192,7 +196,7 @@ while true; do
     ssh_fail_counter=0
     debug_print "Attempting to dial..."
 
-    # Try to re-"dial" our ISP 
+    # Try to re-"dial" our ISP
     #
     /usr/bin/pon gprs
 

+ 23 - 1
busunit/scripts/get_net_ids.sh

@@ -50,6 +50,7 @@ function query_modem
 	query_command="$1"
 	reply_regex="$2"
 	
+  if [[ ! -e $SERIAL_PORT ]] ; then return ; fi
 
 	if [ -z "$query_command" ]; then
 		query_command="AT"
@@ -95,6 +96,8 @@ function query_mac_address
 
 function setup_modem
 {
+  if [[ ! -e $SERIAL_PORT ]] ; then return ; fi
+
 	stty -F $SERIAL_PORT $PORT_CONFIG
 	query_modem 'AT' 2>&1 > /dev/null
 	sleep 2
@@ -103,10 +106,25 @@ function setup_modem
 	query_modem 'ATZ' 'OK' 2>&1 > /dev/null
 }
 
+maxtries=5
+tries=0
+
+while [[ ! -e $SERIAL_PORT && $tries -lt $maxtries ]] ; do
+  echo "# $tries / $maxtries"
+  sleep 5
+	tries=$((tries + 1))
+done
+
+if [[ ! -e $SERIAL_PORT ]] ; then
+  echo "IMEI = " > $COOKED_DROPFILE
+  echo "IMSI = " >> $COOKED_DROPFILE
+  echo "ETH0 = `query_mac_address eth0 2> /dev/null`"  >> $COOKED_DROPFILE
+  exit
+fi
+
 setup_modem
 query_modem 'AT+CMEE=1'	'OK' 2>&1 > /dev/null
 
-maxtries=5
 tries=0
 
 while !(echo $imei | egrep '[0-9]+') && [ $tries -lt $maxtries ]; do
@@ -114,6 +132,8 @@ while !(echo $imei | egrep '[0-9]+') && [ $tries -lt $maxtries ]; do
 	tries=$((tries + 1))
 done
 
+echo ">> $tries"
+
 tries=0
 
 while !(echo $imsi | egrep '[0-9]+') && [ $tries -lt $maxtries ]; do
@@ -121,6 +141,8 @@ while !(echo $imsi | egrep '[0-9]+') && [ $tries -lt $maxtries ]; do
 	tries=$((tries + 1))
 done
 
+echo ">> $tries"
+
 echo "IMEI = $imei" > $COOKED_DROPFILE
 echo "IMSI = $imsi" >> $COOKED_DROPFILE
 echo "ETH0 = `query_mac_address eth0 2> /dev/null`"  >> $COOKED_DROPFILE

+ 52 - 0
busunit/scripts/setup-serial-dmesg.py

@@ -0,0 +1,52 @@
+#!/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 serial
+import sys
+import re
+import time
+import subprocess as sp
+from os import listdir
+from os.path import isfile, join
+from os import system
+
+DEBUG = True
+VERBOSE = True
+
+ret = system("rm -f /dev/ttyPIU /dev/ttyGPRS /dev/ttyDIU /dev/ttyGPS")
+
+DEVDIR = "/dev"
+
+for devfn in ["ttyUSB0", "ttyUSB1"]:
+  s = sp.check_output("dmesg | grep " + devfn + " | tail -n1", shell=True)
+  s = s.strip()
+
+  print s
+
+  if re.search(r'FTDI', s):
+    print devfn, "-> /dev/ttyPIU (ftdi)"
+    system("ln -s " + devfn + " /dev/ttyPIU")
+  elif re.search(r'pl2303', s):
+    print devfn, "-> /dev/ttyGPRS (pl2303)"
+    system("ln -s " + devfn + " /dev/ttyGPRS")
+
+system("ln -s /dev/ttyACM0 /dev/ttyGPS")
+
+

+ 20 - 1
busunit/scripts/setup-serial.py

@@ -1,4 +1,23 @@
 #!/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 serial
 import sys
@@ -8,7 +27,7 @@ from os import listdir
 from os.path import isfile, join
 from os import system
 
-DEBUG = False
+DEBUG = True
 VERBOSE = True
 
 ret = system("rm -f /dev/ttyPIU /dev/ttyGPRS /dev/ttyDIU /dev/ttyGPS")