Use INVALID_ALTITUDE in a few more places.

This commit is contained in:
Oliver Jowett 2016-08-26 21:38:06 +01:00
parent 08c14484cd
commit 8b8f8d7a40
3 changed files with 11 additions and 9 deletions

View file

@ -167,6 +167,8 @@ typedef struct rtlsdr_dev rtlsdr_dev_t;
#define MODES_ACFLAGS_LLBOTH_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID) #define MODES_ACFLAGS_LLBOTH_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
#define MODES_ACFLAGS_AOG_GROUND (MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG) #define MODES_ACFLAGS_AOG_GROUND (MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG)
#define INVALID_ALTITUDE (-9999)
#define MODES_NON_ICAO_ADDRESS (1<<24) // Set on addresses to indicate they are not ICAO addresses #define MODES_NON_ICAO_ADDRESS (1<<24) // Set on addresses to indicate they are not ICAO addresses
#define MODES_DEBUG_DEMOD (1<<0) #define MODES_DEBUG_DEMOD (1<<0)

View file

@ -39,9 +39,10 @@ int ModeAToModeC(unsigned int ModeA)
unsigned int FiveHundreds = 0; unsigned int FiveHundreds = 0;
unsigned int OneHundreds = 0; unsigned int OneHundreds = 0;
if ( (ModeA & 0xFFFF8889) // check zero bits are zero, D1 set is illegal if ((ModeA & 0xFFFF8889) != 0 || // check zero bits are zero, D1 set is illegal
|| ((ModeA & 0x000000F0) == 0) ) // C1,,C4 cannot be Zero (ModeA & 0x000000F0) == 0) { // C1,,C4 cannot be Zero
{return -9999;} return INVALID_ALTITUDE;
}
if (ModeA & 0x0010) {OneHundreds ^= 0x007;} // C1 if (ModeA & 0x0010) {OneHundreds ^= 0x007;} // C1
if (ModeA & 0x0020) {OneHundreds ^= 0x003;} // C2 if (ModeA & 0x0020) {OneHundreds ^= 0x003;} // C2
@ -51,8 +52,9 @@ int ModeAToModeC(unsigned int ModeA)
if ((OneHundreds & 5) == 5) {OneHundreds ^= 2;} if ((OneHundreds & 5) == 5) {OneHundreds ^= 2;}
// Check for invalid codes, only 1 to 5 are valid // Check for invalid codes, only 1 to 5 are valid
if (OneHundreds > 5) if (OneHundreds > 5) {
{return -9999;} return INVALID_ALTITUDE;
}
//if (ModeA & 0x0001) {FiveHundreds ^= 0x1FF;} // D1 never used for altitude //if (ModeA & 0x0001) {FiveHundreds ^= 0x1FF;} // D1 never used for altitude
if (ModeA & 0x0002) {FiveHundreds ^= 0x0FF;} // D2 if (ModeA & 0x0002) {FiveHundreds ^= 0x0FF;} // D2

View file

@ -111,8 +111,6 @@ static int decodeID13Field(int ID13Field) {
return (hexGillham); return (hexGillham);
} }
#define INVALID_ALTITUDE (-9999)
// //
//========================================================================= //=========================================================================
// //