Browse Source

work on #33

* moving back to kiosk web front end
* RFID credentials deposited in `credential` file, opening and
  closing on each write instead of keeping an always open file
  for appending
clementinecomputing 4 years ago
parent
commit
ce42c3660d

+ 10 - 16
busunit-PIU/rootfs/etc/rc.local

@@ -20,23 +20,17 @@
 # along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
 #
 
-# permissions should be 755:
-#
-#   chmod 755 /etc/rc.local
-#
-
-/home/bus/bin/ipc_server > /tmp/ipc_server.log &
-
-/home/bus/bin/rfid_manager > /tmp/rfid.log &
+export LOGDIR=/home/bus/log
 
-/home/bus/bin/magstripe_manager > /tmp/mag.log &
+/home/bus/bin/ipc_server > $LOGDIR/ipc_server.log &
+/home/bus/bin/rfid_manager > $LOGDIR/rfid_manager.log &
+/home/bus/bin/magstripe_manager > $LOGDIR/mag_manager.log &
+/home/bus/bin/qr_manager > $LOGDIR/qr_manager.log &
+motion -b -c /home/bus/.motion/motion.conf -p $LOGDIR/motion.pid -l $LOGDIR/motion.log 2>> $LOGDIR/init.log
+/home/bus/bin/piumsgd > $LOGDIR/piumsgd.log &
 
-/home/bus/bin/qr_manager > /tmp/qr.log &
-
-motion -b -c /home/bus/.motion/motion.conf -p /tmp/motion.pid -l /tmp/motion.log 2>> /tmp/init.log
-
-/home/bus/bin/piumsgd > /tmp/piumsgd.log &
-
-( sleep 5 && su -c "/usr/bin/startx /home/bus/popufare/busunit-PIU/scripts/piu_kiosk 2>&1 /tmp/kiosk.log" )  &
+( sleep 5 && su -c "/usr/bin/startx /home/bus/popufare/busunit-PIU/scripts/piu_kiosk 2>&1 $LOGDIR/kiosk.log" )  &
+#( sleep 5 && su -c "/usr/bin/startx /home/bus/bin/piu_wrapp 2>&1 /tmp/piu_wrapp.log" )  &
 
 exit 0
+

+ 3 - 1
busunit-PIU/scripts/magstripe_manager

@@ -24,9 +24,11 @@
 #
 
 BASEDIR=/home/bus
+MAGFARE=$BASEDIR/log/credential.mag
+
 
 stdbuf -eL -oL $BASEDIR/bin/capture-mag-hid | \
-  tee -a /tmp/mag.log
+  tee -a $MAGFARE
 
 #  xargs -n1 -I{} bash -c " $BASEDIR/bin/format_debug_msg.py TOKEN_MAG '{}' | $BASEDIR/bin/debug_client -s " | \
 #  tee -a /tmp/mag.log

+ 15 - 8
busunit-PIU/scripts/qr_cam_filter

@@ -35,7 +35,9 @@ out_type = "stdout"
 #out_type = "x11"
 
 #barcode_ofp = sys.stdout
-barcode_ofp = open("/tmp/qrcode.log", "a")
+#barcode_ofp = open("/tmp/qrcode.log", "a")
+
+BARCODE_CREDENTIAL_FILE = "/home/bus/log/credential.barcode"
 
 cap = cv2.VideoCapture(0)
 
@@ -50,6 +52,11 @@ cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)
 t_prv = time.time()*1000.0
 t_now = t_prv
 
+def write_credential( line ):
+  with open(BARCODE_CREDENTIAL_FILE, "a") as ofp:
+    ofp.write(line)
+    ofp.flush()
+
 while True:
   ret, frame = cap.read()
 
@@ -71,18 +78,18 @@ while True:
     cv2.putText(frame, show_text, (x, y - 10),
       cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
 
-    #barcode_ofp.write( str(datetime.datetime.now()) + ": " + barcode_data + "\n")
-
     t_now = time.time()*1000.0
 
     if LAST_TOK != barcode_data:
-      barcode_ofp.write( str(int(time.time())) + ": " + barcode_data + "\n")
-      barcode_ofp.flush()
+      #barcode_ofp.write( str(int(time.time())) + ": " + barcode_data + "\n")
+      #barcode_ofp.flush()
+      write_credential( str(int(time.time())) + ": " + barcode_data + "\n" )
       t_prv = t_now
       LAST_TOK = barcode_data
     elif (t_now - t_prv) >= RATE_LIMIT_MS:
-      barcode_ofp.write( str(int(time.time())) + ": " + barcode_data + "\n")
-      barcode_ofp.flush()
+      #barcode_ofp.write( str(int(time.time())) + ": " + barcode_data + "\n")
+      #barcode_ofp.flush()
+      write_credential( str(int(time.time())) + ": " + barcode_data + "\n" )
       t_prv = t_now
       LAST_TOK = barcode_data
     else:
@@ -102,7 +109,7 @@ while True:
     if key == ord('q'):
       break
 
-barcode_ofp.close()
+#barcode_ofp.close()
 cap.release()
 cv2.destroyAllWindows()
 

+ 5 - 2
busunit-PIU/scripts/rfid_manager

@@ -26,10 +26,13 @@
 BASEDIR=/home/bus
 d=$BASEDIR/bin
 
+RAWLOG=$BASEDIR/log/rfid_raw.log
+RFIDFARE=$BASEDIR/log/credential.rfid
+
 stdbuf -eL -oL $d/proxmark3 /dev/ttyACM0 -l proxmark3-lf-hid-read.lua | \
-  stdbuf -eL -oL tee -a /tmp/rfid_raw.log | \
+  stdbuf -eL -oL tee -a $RAWLOG | \
   $d/rfid_filter | \
-  tee -a /tmp/rfid.log
+  tee -a $RFIDFARE
 
 #  xargs -n1 -I{} bash -c " $d/format_debug_msg.py TOKEN_RFID -i <( echo -e -n '{}\0' ) | $d/debug_client -s " | \
 #  tee -a /tmp/rfid.log