Skip to content

Commit

Permalink
Improve/Fix SBS-1 ADS-B Parsing (ArduPilot#3218)
Browse files Browse the repository at this point in the history
* Fix ADSB: heading, speed & callsign, fix unit conv

* Add Squawk codes to SBS-1 decode
  • Loading branch information
MUSTARDTIGERFPV authored Nov 28, 2023
1 parent 77451af commit 0068db5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ExtLibs/Utilities/adsb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,13 @@ public static void ReadMessage(Stream st1)
}
catch { }

ushort squawk = 0;
try
{
squawk = ushort.Parse(strArray[17]); // Squawk transponder code
}
catch { }

bool is_on_ground = strArray[21] != "0";//Boolean. Flag to indicate ground squat switch is active.

if (Planes[hex_ident] == null)
Expand All @@ -823,7 +830,15 @@ public static void ReadMessage(Stream st1)
continue;

if (UpdatePlanePosition != null && plane != null)
UpdatePlanePosition(null, new PointLatLngAltHdg(lat, lon, altitude / 3.048, (float)plane.heading, -1 , hex_ident, DateTime.Now));
{
double METERS_PER_FOOT = 3.28;
PointLatLngAltHdg plln = new PointLatLngAltHdg(lat, lon, altitude / METERS_PER_FOOT, (float)plane.heading, plane.ground_speed, hex_ident, DateTime.Now)
{
CallSign = plane.CallSign,
Squawk = squawk
};
UpdatePlanePosition(null, plln);
}
}
else if (strArray[1] == "4")
{
Expand Down

0 comments on commit 0068db5

Please sign in to comment.