From: Jan "Yenya" Kasprzak Date: Mon, 14 Sep 2015 15:57:49 +0000 (+0200) Subject: Infinite reads handling X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=HEAD;p=openparking.git Infinite reads handling --- diff --git a/firmware/firmware.c b/firmware/firmware.c index 3554dcc..7fbcdf1 100644 --- a/firmware/firmware.c +++ b/firmware/firmware.c @@ -19,11 +19,14 @@ #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) { diff --git a/openparking.otl b/openparking.otl index 5d40d70..529f0c9 100644 --- a/openparking.otl +++ b/openparking.otl @@ -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