[hamradio-commits] [dump1090] 99/373: Changes to prevent stale output in SBS-1 format

Matthew Ernisse mernisse-guest at moszumanska.debian.org
Thu Oct 23 14:58:09 UTC 2014


This is an automated email from the git hooks/post-receive script.

mernisse-guest pushed a commit to branch backport
in repository dump1090.

commit 3d25f4bf1ade5c4771301a513c471d26b1a4c5df
Author: Malcolm Robb <Support at ATTAvionics.com>
Date:   Wed Apr 17 23:09:01 2013 +0100

    Changes to prevent stale output in SBS-1 format
    
    The original code calculates Lat/Long only if it receives two DF-17
    (subtype 9 or 18) within one second of each other. I have no idea why.
    It then caches the results in the aircrafts data structure for use in
    the --interactive display.
    
    When SBS-1 style ASCII output is selected (port 30003) the code does not
    attempt to calculate Lat/Long from the data just received - instead it
    picks it up from the cached information in the aircraft's data
    structure.
    
    However, if the data isn't being updated this results in stale Lat/Long
    being sent out. This is most likely to occur when the aircraft is at the
    extreme edge of the receivers range when it may be getting some DF-17s
    containing Lat/Long, but not 2 per second. The program will continue
    sending the stale data until the aircraft finally times out (default 60
    seconds)
    
    I have modified the code to include a sbsflags variable in the aircraft
    data structure. When a new Lat/Long is decoded and put into the
    structure, a bit is set to indicate SBS_LAT_LONG_FRESH. Then, once the
    Lat/Long is output the first time, the bit is cleared. Thereafter the
    code will not populate the Lat/Long fields in the output message until
    SBS_LAT_LONG_FRESH is set again.
---
 dump1090.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/dump1090.c b/dump1090.c
index d8eb833..bb31714 100644
--- a/dump1090.c
+++ b/dump1090.c
@@ -91,6 +91,8 @@
 #define MODES_UNIT_FEET 0
 #define MODES_UNIT_METERS 1
 
+#define MODES_SBS_LAT_LONG_FRESH (1<<0)
+
 #define MODES_DEBUG_DEMOD (1<<0)
 #define MODES_DEBUG_DEMODERR (1<<1)
 #define MODES_DEBUG_BADCRC (1<<2)
@@ -142,6 +144,7 @@ struct aircraft {
     int even_cprlat;
     int even_cprlon;
     double lat, lon;    /* Coordinated obtained from CPR encoded data. */
+    int sbsflags;
     uint64_t odd_cprtime, even_cprtime;
     int squawk;
     struct aircraft *next; /* Next aircraft in our linked list. */
@@ -1749,6 +1752,7 @@ struct aircraft *interactiveCreateAircraft(uint32_t addr) {
     a->even_cprtime = 0;
     a->lat = 0;
     a->lon = 0;
+    a->sbsflags = 0;
     a->seen = time(NULL);
     a->messages = 0;
     a->squawk = 0;
@@ -1895,6 +1899,7 @@ void decodeCPR(struct aircraft *a) {
         a->lat = rlat1;
     }
     if (a->lon > 180) a->lon -= 360;
+    a->sbsflags |= MODES_SBS_LAT_LONG_FRESH;
 }
 
 /* Receive new messages and populate the interactive mode with more info. */
@@ -2331,15 +2336,17 @@ void modesSendSBSOutput(struct modesMessage *mm, struct aircraft *a) {
         p += sprintf(p, "MSG,1,%s,%s,,,,,,,,0,0,0,0",           strCommon, mm->flight);
 
     } else if (mm->msgtype == 17 && mm->metype >= 9 && mm->metype <= 18) {
-      if (a->lat == 0 && a->lon == 0)
+      if ( ((a->lat == 0) && (a->lon == 0)) || ((a->sbsflags & MODES_SBS_LAT_LONG_FRESH) == 0) ){
         p += sprintf(p, "MSG,3,%s,,%d,,,,,,,0,0,0,0",           strCommon, mm->altitude);
-      else
+      } else {
         p += sprintf(p, "MSG,3,%s,,%d,,,%1.5f,%1.5f,,,0,0,0,0", strCommon, mm->altitude, a->lat, a->lon);
+        a->sbsflags &= ~MODES_SBS_LAT_LONG_FRESH;
+      }
 
     } else if (mm->msgtype == 17 && mm->metype == 19 && mm->mesub == 1) {
         int vr = (mm->vert_rate_sign==0?1:-1) * (mm->vert_rate-1) * 64;
 
-        p += sprintf(p, "MSG,4,%s,,,%d,%d,,,%i,,0,0,0,0",       strCommon, a->speed, a->track, vr);
+        p += sprintf(p, "MSG,4,%s,,,%d,%d,,,%i,,0,0,0,0",       strCommon, mm->velocity, mm->heading, vr);
 
     } else if (mm->msgtype == 21) {
         p += sprintf(p, "MSG,6,%s,,,,,,,,%d,%d,%d,%d,%d",       strCommon, mm->identity, alert, emergency, spi, ground);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git



More information about the pkg-hamradio-commits mailing list