Closed e5150 closed 7 years ago
The mask is actually correct; while there are only thirteen bits in the final representation, the so-called "M" bit (indicating metric altitude but so far unused in practice) is present in Mode S-style transmissions, adding a fourteenth bit to the representation and requiring the mask to be fourteen bits wide.
Try running "altitude.py" as a standalone Python program to see the effect of changing this mask.
Replaced the 14-bit 0x3F80 with 13-bit 0x1F80. (The 14-bit mask would have produced correct results as long as the input is 13 bit. But for the sake of correctness…)