浏览代码

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

clementinecomputing 6 年之前
父节点
当前提交
2369bb4cf9

+ 10 - 1
busunit/DIUv2/diu_kiosk

@@ -28,7 +28,16 @@ mv $tmpfn $HOME/.config/chromium/Preferences
 
 #/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk ./html/index.html
 #
-/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk 'http://localhost:60535'
+#  --disable-application-cache \
+/usr/bin/chromium-browser \
+  --noerrdialogs \
+  --disable-infobars \
+  --aggressive-cache-discard \
+  --incognito \
+  --kiosk \
+  'http://localhost:60535'
+
+
 
 # refresh
 #

+ 64 - 28
busunit/DIUv2/html/js/diu_ui-ORG.js

@@ -1,6 +1,24 @@
-
-var _ADDRESS = "192.168.0.110";
-//var _URL = "http://localhost";
+/*
+ * 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/>.
+ *
+ */
+
+var _ADDRESS = "localhost";
 var _URL = "http://" + _ADDRESS;
 var _PORT = 60535;
 
@@ -9,6 +27,8 @@ var _fqADDRESS = _ADDRESS + ":" + _PORT;
 var BG_COLOR = "#f7f7f7";
 var TEXT_COLOR = "#444444";
 
+var DIU_UI_VERSION = "0.1.0";
+var DIU_UI_VERSION_DATE = "2019-09-04 15:24:11";
 
 var g_ctx = {
 
@@ -31,25 +51,6 @@ var g_ctx = {
 
   "diu_status" : {},
 
-  /*
-  "rule" : {
-    "adult":"CASH-ADULT",
-    "youth":"CASH-YOUTH",
-    "half":"CASH-HALF",
-    "bike":"MISC-BIKE",
-    "wheelchair":"MISC-WHEELCHAIR",
-    "transfer":"MISC-TRANSFER",
-    "interline":"MISC-INTERLINE",
-    "event":"MISC-EVENT",
-    "schoola":"OVR-SCHOOLA",
-    "schoolb":"OVR-SCHOOLB",
-    "schoolc":"OVR-SCHOOLC",
-    "orga":"OVR-ORGA",
-    "orgb":"OVR-ORGB",
-    "orgc":"OVR-ORGC",
-  },
-  */
-
   "x": ""
 };
 
@@ -478,27 +479,56 @@ function _bulkaccept_input(inp) {
 //-------------
 //-------------
 
+
+// space pad
+// default 10
+//
+function _sp(str, align, pad) {
+  align = ((typeof align=="undefined") ? "left" : align);
+  pad = ((typeof pad==="undefined") ? 10 : pad);
+
+  var n = 0;
+  n = pad - str.length;
+
+  if (align == "left") {
+    for (var i=0; i<n; i++) { str += " "; }
+  }
+  else if (align == "center") {
+    var rem = n%2;
+    var n2 = Math.floor(n/2);
+    var pfx = "", sfx = "";
+    for (var i=0; i<n2; i++) { pfx += " "; }
+    for (var i=0; i<(n2+rem); i++) { sfx += " "; }
+    str = pfx + str + sfx;
+  }
+  else if (align == "right") {
+    var pfx = "";
+    for (var i=0; i<n; i++) { pfx += " "; }
+    str = prx + str;
+  }
+
+  return str;
+}
+
 function _cb_status(inp) {
-  //console.log("_cb_status>>\n", inp);
 
   var tok = inp.split(" ");
   if (tok.length < 2) { return; }
   if (tok[0]!="ok") { return; }
 
-  var valtok = tok[1].split("\n");
+  valtok = tok.slice(1).join(" ").split("\n");
   if (valtok[0]!="msg=status") { return; }
 
   g_ctx.diu_status = {};
   var fields = valtok[1].split("|");
   for (var ii=0; ii<fields.length; ii++) {
     var kv = fields[ii].split("=");
-    g_ctx.diu_status[kv[0]] = kv[1];
+    if (kv.length!=2) { continue; }
+    g_ctx.diu_status[kv[0].trim()] = kv[1].trim();
 
 
   }
 
-  //for (var x in fv) { console.log(x, ";;;", fv[x]); }
-
   var m = g_ctx.diu_status;
   if (g_ctx.current_ui === "ui_login") {
     var ele = document.getElementById("ui_login_status");
@@ -507,9 +537,15 @@ function _cb_status(inp) {
     str += "Last Token Read (" + m["last_token"] + ")\n";
     str += "GPS: " + m["gps"] + "\n";
     str += "\n";
+    //      012345678012345678901234567890
     str += "Package   Version   Installed\n";
+    //str += "-----------------------------\n";
+    str += _sp("ui") + _sp(DIU_UI_VERSION) + _sp(DIU_UI_VERSION_DATE) + "\n";
     str += "\n";
-    str += "\n";
+
+    if ("IMEI" in m) { str += "IMEI = " + m["IMEI"] + "\n"; }
+    if ("IMSI" in m) { str += "IMSI = " + m["IMSI"] + "\n"; }
+    if ("ETH0" in m) { str += "ETH0 = " + m["ETH0"] + "\n"; }
 
     ele.innerHTML = str;
   }

+ 4 - 4
busunit/common/common_config.h

@@ -397,11 +397,11 @@
 
 //This defines the expected size of the pass database and its RAM based index tables:
 
-//#define NUM_STORED_PASSES  (131072)  //A nice round number that multiplies by sizeof(rider_record) to a page boundary
-//#define STORED_PASS_HASH  (131101)  //A prime number larger than NUM_STORED_PASSES
+#define NUM_STORED_PASSES  (131072)  //A nice round number that multiplies by sizeof(rider_record) to a page boundary
+#define STORED_PASS_HASH  (131101)  //A prime number larger than NUM_STORED_PASSES
 
-#define NUM_STORED_PASSES  (262144)  //A nice round number that multiplies by sizeof(rider_record) to a page boundary
-#define STORED_PASS_HASH  (262147)  //A prime number larger than NUM_STORED_PASSES
+//#define NUM_STORED_PASSES  (262144)  //A nice round number that multiplies by sizeof(rider_record) to a page boundary
+//#define STORED_PASS_HASH  (262147)  //A prime number larger than NUM_STORED_PASSES
 
 //#define NUM_STORED_PASSES  (1048576)  //A nice round number that multiplies by sizeof(rider_record) to a page boundary
 //#define STORED_PASS_HASH  (1048583)  //A prime number larger than NUM_STORED_PASSES

+ 2 - 1
busunit/passdb/buildit.sh

@@ -4,7 +4,8 @@ tinyscheme_opts="-fpic  -I. -c -g -Wno-char-subscripts -O -DUSE_STRLWR=1 -DSTAND
 
 rm -f passdb scheme.o
 
-$target_cc $tinyscheme_opts tinyscheme1.39/scheme.c
+#$target_cc $tinyscheme_opts tinyscheme1.39/scheme.c
+$target_cc $tinyscheme_opts tinyscheme/scheme.c
 $target_cc $target_ccopts -g -o passdb passdb.c rfid_decoder.c pass_communication.c rules.c ../common/common_defs.c ../common/gpsmath.c ../commhub/commhub.c ../commhub/client_utils.c scheme.o -lm -lz
 
 rm -f send_magstripe

+ 5 - 0
busunit/passdb/pass_communication.c

@@ -370,6 +370,8 @@ int handle_pass_update_request(char *line, passdb_context *ctx, int sync)
     int input_idx = 0;
     int eol = 0;
 
+    memset(buffer, 0, sizeof(char)*LINE_BUFFER_SIZE);
+
     //Extract the first tab-delimited field from the input line...
     input_idx += get_field(buffer, line + input_idx, sizeof(buffer), &eol);
 
@@ -1407,6 +1409,9 @@ int main(int argc, char **argv)
         server_fd = -1;
     }
 
+    printf("Unloading rules...\n");
+    unload_rules();
+
     printf("Goodbye.\n");
 
     return 0;

+ 7 - 3
busunit/passdb/passdb.c

@@ -345,7 +345,7 @@ int format_new_passdb()
 
     if( fd < 0 )
     {
-        fprintf(stderr, "Cannot create pass file!\n");
+        fprintf(stderr, "Cannot create pass file '%s'!\n", PASSES_FILE);
         return FAIL_DATABASE;
     }
 
@@ -355,7 +355,7 @@ int format_new_passdb()
     {
         if( write(fd, &blank, sizeof(blank)) != sizeof(blank) )
         {
-            fprintf(stderr, "Cannot write blank data to passes file!\n");
+            fprintf(stderr, "Cannot write blank data to passes file '%s'!\n", PASSES_FILE);
             close(fd);
             return FAIL_DATABASE;
         }
@@ -449,7 +449,7 @@ int attach_to_passdb(passdb_context *ctx)
 
     if(fd < 0)
     {
-        fprintf(stderr, "Cannot open passes file!\n");
+        fprintf(stderr, "Cannot open passes file '%s'!\n", PASSES_FILE);
         return FAIL_DATABASE;
     }
 
@@ -819,6 +819,10 @@ int update_rider(passdb_context *ctx, rider_record *rec, int sync)
     mag_idx = find_mag_in_hash(ctx, rec->magstripe_value);
     rf_idx = find_rf_in_hash(ctx, rec->rfid_value);
 
+    if ((mag_idx < 0) || (rf_idx < 0)) {
+      //pass
+    }
+
 //  We want to allow a short period of magstrip or RFID collision as the lesser of two evils vs.       **STUPID**
 //  possibly losing a record due to a degenerately stupid administrator doing the following:
 //

+ 1 - 0
busunit/passdb/tinyscheme

@@ -0,0 +1 @@
+tinyscheme-1.41/