]> www.fi.muni.cz Git - openparking.git/commitdiff
Infinite reads handling master
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Mon, 14 Sep 2015 15:57:49 +0000 (17:57 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Mon, 14 Sep 2015 15:57:49 +0000 (17:57 +0200)
firmware/firmware.c
openparking.otl

index 3554dcc768e38e6deda7bdd7fe5fb8459e52a2c2..7fbcdf18601b65f661edfb46b9cced58d937a72a 100644 (file)
 #define thresholds     (hold_regs+1)
 #define led1_sensors   (hold_regs[13])
 #define led2_sensors   (hold_regs[14])
+#define long_as_free   (hold_regs[15])
+#define long_thr       (hold_regs[16])
 
 #define led_bitmap     (hold_regs[MB_N_HOLD_REGS_EEPROM])
 #define distances      (hold_regs+MB_N_HOLD_REGS_EEPROM+1)
 #define free_bitmap    (hold_regs[MB_N_HOLD_REGS_EEPROM+13])
 #define err_bitmap     (hold_regs[MB_N_HOLD_REGS_EEPROM+14])
+#define long_bitmap    (hold_regs[MB_N_HOLD_REGS_EEPROM+15])
 #define max_distances  (hold_regs+MB_N_HOLD_REGS_EEPROM+21)
 #define err_counts     (hold_regs+MB_N_HOLD_REGS_EEPROM+41)
 
@@ -126,7 +129,8 @@ static void do_measurement(unsigned char trig)
                        }
                        /*
                         * If the echo pulse is too long, do not treat it
-                        * as error, just count it as maximum length.
+                        * as error, just count it as maximum length
+                        * and notify the state in the bitmap.
                         */
                        distances[off] = now - starttimes[i];
                }
@@ -195,7 +199,7 @@ static void leds_update()
 
 static void eval_bitmaps()
 {
-       uint16_t free_b = 0, err_b = 0, mask;
+       uint16_t free_b = 0, err_b = 0, long_b = 0, mask;
        uint8_t i;
 
        for (i = 0; i < N_SENSORS; i++) {
@@ -205,13 +209,21 @@ static void eval_bitmaps()
                        if (distances[i] == -1) {
                                err_b |= mask;
                        } else if (distances[i] > thresholds[i]) {
-                               free_b |= mask;
+                               if (long_thr && distances[i] > long_thr) {
+                                       long_b |= mask;
+                                       if (long_as_free & mask) {
+                                               free_b |= mask;
+                                       }
+                               } else {
+                                       free_b |= mask;
+                               }
                        }
                }
        }
 
        free_bitmap = free_b;
        err_bitmap  = err_b;
+       long_bitmap = long_b;
 
        if (led1_sensors) {
                if (led1_sensors & err_bitmap) {
index 5d40d70840195615d8a6e8e51e2d9d3d726c916d..529f0c95c8163a3b5f9f30577271860fa5bdd031 100644 (file)
@@ -120,18 +120,23 @@ Software kontroleru:
                        12x porucha senzoru (r)
                        2x LED (rw)
                holding regs
-                       1000-1019 permanent,rw
-                       1000 unit ID
-                       1001-1012 distance thresholds
-                       1013 sensors for LED1 (0 = externally controled)
-                       1014 sensors for LED2 ( =="== )
+                       0-19 permanent (backed by EEPROM)
+                       0 unit ID
+                       1-12 distance thresholds
+                       13 sensors for LED1 (0 = externally controled)
+                       14 sensors for LED2 ( =="== )
+                       15 bitmap of sensors where long read counts as free place (1=on)
+                       16 threshhold of long reads
+
+                       20-... transient (not backed by EEPROM)
+                       20 LED state bitmap (00 = busy, 01 = free, 1x = err)
+                       21-32 measured distances
+                       33 free_bitmap (1=free)
+                       34 err_bitmap (1=err)
+                       35 long_bitmap (1=long)
+                       41-52 maximum measured distances
+                       61-72 error state (upper byte: @ of long reads, lower: # off errs)
 
-                       1020-1039 transient
-                       1020 LED state bitmap
-                       1021-1032 measured distances
-                       1033 free_bitmap (1=free)
-                       1034 err_bitmap (1=err)
-                       1041-1052 maximum measured distances
 
        Hlavni smycka, cca 5 vterin:
                ? zmerit teplotu z ATmegy