From ee742cf8db66fff710f48d8680ad780ae4cc6f72 Mon Sep 17 00:00:00 2001 From: Malcolm Robb Date: Fri, 24 May 2013 12:26:06 +0100 Subject: [PATCH] SBS Output Format changes Bug fixes in the SBS output code as a result of an EMAIL from Liviu Some software gets upset if null fields are output where the software is expecting a valid value. This was being caused by DF0's outputting and SBS MSG5. MSG5 needs Atert and SPI flags, which are derived from the FS field. DF0 doesn't have an FS field, so cannot output a MSG5. Change so that DF0 results in an SBS MSG7. Also DF17/DF18 metypes 5 to 18 contain raw Lat/Lon data. However they cannot be decoded into real Lat/Lon values unless both even and odd parts are available Therefore, when we receive a DF17/DF18 we need to check that we have successfully decoded the Lat/Lon before we attempt to send an SBS MSG2 or MSG3. If we don't have a decoded Lat/Lon, send a MSG7 instead. --- dump1090.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/dump1090.c b/dump1090.c index 9543222..e7eb5b3 100644 --- a/dump1090.c +++ b/dump1090.c @@ -3534,22 +3534,28 @@ void modesSendSBSOutput(struct modesMessage *mm) { // // Decide on the basic SBS Message Type - if ((mm->msgtype == 0) || (mm->msgtype == 4) || (mm->msgtype == 20)) { + if ((mm->msgtype == 4) || (mm->msgtype == 20)) { msgType = 5; - } else if ((mm->msgtype == 5) || (mm->msgtype == 21)) { + } else if ((mm->msgtype == 5) || (mm->msgtype == 21)) { msgType = 6; - } else if (mm->msgtype == 16) { + } else if ((mm->msgtype == 0) || (mm->msgtype == 16)) { msgType = 7; - } else if (mm->msgtype == 11) { + } else if (mm->msgtype == 11) { msgType = 8; - } else if (mm->msgtype != 17) { + } else if ((mm->msgtype != 17) && (mm->msgtype != 18)) { return; - } else if (mm->metype == 4) { + } else if ((mm->metype >= 1) && (mm->metype <= 4)) { msgType = 1; } else if ((mm->metype >= 5) && (mm->metype <= 8)) { - msgType = 2; + if (mm->bFlags & MODES_ACFLAGS_LATLON_VALID) + {msgType = 2;} + else + {msgType = 7;} } else if ((mm->metype >= 9) && (mm->metype <= 18)) { - msgType = 3; + if (mm->bFlags & MODES_ACFLAGS_LATLON_VALID) + {msgType = 3;} + else + {msgType = 7;} } else if (mm->metype != 19) { return; } else if ((mm->mesub == 1) || (mm->mesub == 2)) {