Merge branch 'upstream'

This commit is contained in:
Oliver Jowett 2016-02-26 10:38:43 +00:00
commit c6fff0ff32
5 changed files with 29 additions and 16 deletions

View file

@ -373,6 +373,7 @@ static void modesSendBeastOutput(struct modesMessage *mm) {
char *p = prepareWrite(&Modes.beast_out, 2 + 2 * (7 + msgLen)); char *p = prepareWrite(&Modes.beast_out, 2 + 2 * (7 + msgLen));
char ch; char ch;
int j; int j;
int sig;
unsigned char *msg = (Modes.net_verbatim ? mm->verbatim : mm->msg); unsigned char *msg = (Modes.net_verbatim ? mm->verbatim : mm->msg);
if (!p) if (!p)
@ -402,7 +403,12 @@ static void modesSendBeastOutput(struct modesMessage *mm) {
*p++ = (ch = (mm->timestampMsg)); *p++ = (ch = (mm->timestampMsg));
if (0x1A == ch) {*p++ = ch; } if (0x1A == ch) {*p++ = ch; }
*p++ = ch = (char) round(sqrt(mm->signalLevel) * 255); sig = round(sqrt(mm->signalLevel) * 255);
if (mm->signalLevel > 0 && sig < 1)
sig = 1;
if (sig > 255)
sig = 255;
*p++ = ch = (char)sig;
if (0x1A == ch) {*p++ = ch; } if (0x1A == ch) {*p++ = ch; }
for (j = 0; j < msgLen; j++) { for (j = 0; j < msgLen; j++) {
@ -729,8 +735,8 @@ static int decodeBinMessage(struct client *c, char *p) {
clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg); clock_gettime(CLOCK_REALTIME, &mm.sysTimestampMsg);
ch = *p++; // Grab the signal level ch = *p++; // Grab the signal level
mm.signalLevel = ((unsigned char)ch / 256.0); mm.signalLevel = ((unsigned char)ch / 255.0);
mm.signalLevel = mm.signalLevel * mm.signalLevel + 1e-5; mm.signalLevel = mm.signalLevel * mm.signalLevel;
if (0x1A == ch) {p++;} if (0x1A == ch) {p++;}
for (j = 0; j < msgLen; j++) { // and the data for (j = 0; j < msgLen; j++) { // and the data
@ -797,7 +803,7 @@ static int decodeHexMessage(struct client *c, char *hex) {
// Mark messages received over the internet as remote so that we don't try to // Mark messages received over the internet as remote so that we don't try to
// pass them off as being received by this instance when forwarding them // pass them off as being received by this instance when forwarding them
mm.remote = 1; mm.remote = 1;
mm.signalLevel = 1e-5; mm.signalLevel = 0;
// Remove spaces on the left and on the right // Remove spaces on the left and on the right
while(l && isspace(hex[l-1])) { while(l && isspace(hex[l-1])) {
@ -814,8 +820,8 @@ static int decodeHexMessage(struct client *c, char *hex) {
switch(hex[0]) { switch(hex[0]) {
case '<': { case '<': {
mm.signalLevel = ((hexDigitVal(hex[13])<<4) | hexDigitVal(hex[14])) / 256.0; mm.signalLevel = ((hexDigitVal(hex[13])<<4) | hexDigitVal(hex[14])) / 255.0;
mm.signalLevel = mm.signalLevel * mm.signalLevel + 1e-5; mm.signalLevel = mm.signalLevel * mm.signalLevel;
hex += 15; l -= 16; // Skip <, timestamp and siglevel, and ; hex += 15; l -= 16; // Skip <, timestamp and siglevel, and ;
break;} break;}

View file

@ -5,7 +5,7 @@
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=geometry"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=geometry"></script>
<script type="text/javascript" src="config.js"></script> <script type="text/javascript" src="config.js"></script>
<script type="text/javascript" src="markers.js"></script> <script type="text/javascript" src="markers.js"></script>
<script type="text/javascript" src="dbloader.js"></script> <script type="text/javascript" src="dbloader.js"></script>
@ -56,7 +56,7 @@
<b id="infoblock_name">Piaware</b> <b id="infoblock_name">Piaware</b>
</td> </td>
<td align="right"> <td align="right">
<a href="https://github.com/mutability/dump1090" id="dump1090_version" target="_blank"></span> <a href="https://github.com/mutability/dump1090" id="dump1090_version" target="_blank"></a>
</td> </td>
</tr> </tr>
@ -128,7 +128,7 @@
<tr class="infoblock_body"> <tr class="infoblock_body">
<td>Track: <span id="selected_track">n/a</span></td> <td>Track: <span id="selected_track">n/a</span></td>
<td>Last seen: <span id="selected_seen">n/a</span</td> <td>Last seen: <span id="selected_seen">n/a</span></td>
</tr> </tr>
<tr class="infoblock_body"> <tr class="infoblock_body">
@ -143,6 +143,7 @@
<div id="planes_table"> <div id="planes_table">
<table id="tableinfo" width="100%"> <table id="tableinfo" width="100%">
<thead style="background-color: #BBBBBB; cursor: pointer;"> <thead style="background-color: #BBBBBB; cursor: pointer;">
<tr>
<td id="icao" onclick="sortByICAO();">ICAO</td> <td id="icao" onclick="sortByICAO();">ICAO</td>
<td id="flag" onclick="sortByCountry()"><!-- column for flag image --></td> <td id="flag" onclick="sortByCountry()"><!-- column for flag image --></td>
<td id="flight" onclick="sortByFlight();">Flight</td> <td id="flight" onclick="sortByFlight();">Flight</td>
@ -153,6 +154,7 @@
<td id="track" onclick="sortByTrack();" align="right">Track</td> <td id="track" onclick="sortByTrack();" align="right">Track</td>
<td id="msgs" onclick="sortByMsgs();" align="right">Msgs</td> <td id="msgs" onclick="sortByMsgs();" align="right">Msgs</td>
<td id="seen" onclick="sortBySeen();" align="right">Age</td> <td id="seen" onclick="sortBySeen();" align="right">Age</td>
</tr>
</thead> </thead>
<tbody> <tbody>
<tr id="plane_row_template" class="plane_table_row hidden"> <tr id="plane_row_template" class="plane_table_row hidden">

View file

@ -894,10 +894,11 @@ function resetMap() {
function drawCircle(marker, distance) { function drawCircle(marker, distance) {
if (typeof distance === 'undefined') { if (typeof distance === 'undefined') {
return false; return false;
if (!(!isNaN(parseFloat(distance)) && isFinite(distance)) || distance < 0) {
return false;
} }
distance = parseFloat(distance);
if (isNaN(distance) || !isFinite(distance) || distance < 0) {
return false;
} }
distance *= 1000.0; distance *= 1000.0;

View file

@ -66,8 +66,8 @@ struct aircraft *trackCreateAircraft(struct modesMessage *mm) {
// Now initialise things that should not be 0/NULL to their defaults // Now initialise things that should not be 0/NULL to their defaults
a->addr = mm->addr; a->addr = mm->addr;
for (i = 0; i < 8; ++i) for (i = 0; i < 8; ++i)
a->signalLevel[i] = mm->signalLevel; // First time, initialise everything a->signalLevel[i] = 1e-5;
// to the first signal strength a->signalNext = 0;
// mm->msgtype 32 is used to represent Mode A/C. These values can never change, so // mm->msgtype 32 is used to represent Mode A/C. These values can never change, so
// set them once here during initialisation, and don't bother to set them every // set them once here during initialisation, and don't bother to set them every
@ -478,7 +478,10 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
Modes.aircrafts = a; Modes.aircrafts = a;
} }
a->signalLevel[a->messages & 7] = mm->signalLevel;// replace the 8th oldest signal strength if (mm->signalLevel > 0) {
a->signalLevel[a->signalNext] = mm->signalLevel;
a->signalNext = (a->signalNext + 1) & 7;
}
a->seen = now; a->seen = now;
a->messages++; a->messages++;

View file

@ -64,6 +64,7 @@ struct aircraft {
uint32_t addr; // ICAO address uint32_t addr; // ICAO address
char flight[16]; // Flight number char flight[16]; // Flight number
double signalLevel[8]; // Last 8 Signal Amplitudes double signalLevel[8]; // Last 8 Signal Amplitudes
int signalNext; // next index of signalLevel to use
int altitude; // Altitude (Baro) int altitude; // Altitude (Baro)
int altitude_hae; // Altitude (HAE) int altitude_hae; // Altitude (HAE)
int hae_delta; // Difference between HAE and Baro altitudes int hae_delta; // Difference between HAE and Baro altitudes