6 Commits

Author SHA1 Message Date
Flyer350
cb67c63326 Create uplink.py (#55)
First basic functionality for uplink messages - UF and ICAO address.
2019-12-31 11:16:55 +01:00
Xavier Olive
bddaf9aec6 compatibility with bytes (#57) 2019-12-31 11:15:25 +01:00
Junzi Sun
00fc1475ff Merge pull request #53 from dforsi/fix-typos
Fix typos
2019-11-19 11:17:41 +01:00
Daniele Forsi
489c405de0 Fix typos
Fixed with the command:
  codespell --write-changes --ignore-words-list hve,vas
codespell is available at https://github.com/lucasdemarchi/codespell
2019-10-31 13:38:46 +01:00
Junzi Sun
ec2721cfdc Merge pull request #52 from Flyer350/patch-1
Update README.rst
2019-10-30 20:42:19 +01:00
Flyer350
2f13524a7c Update README.rst
fixed typecodes for position messages
2019-10-30 15:54:37 +01:00
17 changed files with 53 additions and 27 deletions

View File

@@ -141,7 +141,7 @@ Common functions
pms.hex2bin(str) # Convert hexadecimal string to binary string
pms.bin2int(str) # Convert binary string to integer
pms.hex2int(str) # Convert hexadecimal string to integer
pms.gray2int(str) # Convert grey code to interger
pms.gray2int(str) # Convert grey code to integer
Core functions for ADS-B decoding
@@ -155,7 +155,7 @@ Core functions for ADS-B decoding
# Typecode 1-4
pms.adsb.callsign(msg)
# Typecode 5-8 (surface), 9-18 (airborne, barometric height), and 9-18 (airborne, GNSS height)
# Typecode 5-8 (surface), 9-18 (airborne, barometric height), and 20-22 (airborne, GNSS height)
pms.adsb.position(msg_even, msg_odd, t_even, t_odd, lat_ref=None, lon_ref=None)
pms.adsb.airborne_position(msg_even, msg_odd, t_even, t_odd)
pms.adsb.surface_position(msg_even, msg_odd, t_even, t_odd, lat_ref, lon_ref)

View File

@@ -20,7 +20,7 @@ def tell(msg):
_print("Downlink Format", df)
if df == 17:
_print("Protocal", "Mode-S Extended Squitter (ADS-B)")
_print("Protocol", "Mode-S Extended Squitter (ADS-B)")
tc = common.typecode(msg)
if 1 <= tc <= 4: # callsign
@@ -29,7 +29,7 @@ def tell(msg):
_print("Callsign:", callsign)
if 5 <= tc <= 8: # surface position
_print("Type", "Surface postition")
_print("Type", "Surface position")
oe = adsb.oe_flag(msg)
msgbin = common.hex2bin(msg)
cprlat = common.bin2int(msgbin[54:71]) / 131072.0
@@ -75,11 +75,11 @@ def tell(msg):
_print("Altitude", alt, "feet")
if df == 20:
_print("Protocal", "Mode-S Comm-B altitude reply")
_print("Protocol", "Mode-S Comm-B altitude reply")
_print("Altitude", common.altcode(msg), "feet")
if df == 21:
_print("Protocal", "Mode-S Comm-B identity reply")
_print("Protocol", "Mode-S Comm-B identity reply")
_print("Squawk code", common.idcode(msg))
if df == 20 or df == 21:

View File

@@ -96,7 +96,7 @@ def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
return airborne_position(msg0, msg1, t0, t1)
else:
raise RuntimeError("incorrect or inconsistant message types")
raise RuntimeError("incorrect or inconsistent message types")
def position_with_ref(msg, lat_ref, lon_ref):
@@ -125,7 +125,7 @@ def position_with_ref(msg, lat_ref, lon_ref):
return airborne_position_with_ref(msg, lat_ref, lon_ref)
else:
raise RuntimeError("incorrect or inconsistant message types")
raise RuntimeError("incorrect or inconsistent message types")
def altitude(msg):
@@ -174,7 +174,7 @@ def velocity(msg, rtn_sources=False):
rate of climb/descent (ft/min), speed type
('GS' for ground speed, 'AS' for airspeed),
direction source ('true_north' for ground track / true north
as refrence, 'mag_north' for magnetic north as reference),
as reference, 'mag_north' for magnetic north as reference),
rate of climb/descent source ('Baro' for barometer, 'GNSS'
for GNSS constellation).
@@ -190,7 +190,7 @@ def velocity(msg, rtn_sources=False):
else:
raise RuntimeError(
"incorrect or inconsistant message types, expecting 4<TC<9 or TC=19"
"incorrect or inconsistent message types, expecting 4<TC<9 or TC=19"
)
@@ -524,7 +524,7 @@ def sil(msg, version):
if tc not in [29, 31]:
raise RuntimeError(
"%s: Not a target state and status messag, \
"%s: Not a target state and status message, \
or operation status message, expecting TC = 29 or 31"
% msg
)

View File

@@ -125,7 +125,7 @@ def infer(msg, mrar=False):
tc = common.typecode(msg)
if 1 <= tc <= 4:
return "BDS08" # indentification and category
return "BDS08" # identification and category
if 5 <= tc <= 8:
return "BDS06" # surface movement
if 9 <= tc <= 18:

View File

@@ -175,7 +175,7 @@ def surface_velocity(msg, rtn_sources=False):
else:
trk = None
# ground movment / speed
# ground movement / speed
mov = common.bin2int(mb[5:12])
if mov == 0 or mov > 124:

View File

@@ -41,7 +41,7 @@ def airborne_velocity(msg, rtn_sources=False):
rate of climb/descent (ft/min), speed type
('GS' for ground speed, 'AS' for airspeed),
direction source ('true_north' for ground track / true north
as refrence, 'mag_north' for magnetic north as reference),
as reference, 'mag_north' for magnetic north as reference),
rate of climb/descent source ('Baro' for barometer, 'GNSS'
for GNSS constellation).
"""

View File

@@ -45,7 +45,7 @@ def is10(msg):
if bin2int(d[9:14]) != 0:
return False
# overlay capabilty conflict
# overlay capability conflict
if d[14] == "1" and bin2int(d[16:23]) < 5:
return False
if d[14] == "0" and bin2int(d[16:23]) > 4:

View File

@@ -63,7 +63,7 @@ def cap17(msg):
msg (String): 28 bytes hexadecimal message string
Returns:
list: list of suport BDS codes
list: list of support BDS codes
"""
allbds = [
"05",

View File

@@ -97,7 +97,7 @@ def temp44(msg):
Returns:
float, float: temperature and alternative temperature in Celsius degree.
Note: Two values returns due to what seems to be an inconsistancy
Note: Two values returns due to what seems to be an inconsistency
error in ICAO 9871 (2008) Appendix A-67.
"""

View File

@@ -165,7 +165,7 @@ def vr60baro(msg):
def vr60ins(msg):
"""Vertical rate messured by onbard equiments (IRS, AHRS)
"""Vertical rate measurd by onbard equiments (IRS, AHRS)
Args:
msg (String): 28 bytes hexadecimal message (BDS60) string

View File

@@ -42,7 +42,7 @@ def np2bin(npbin):
def df(msg):
"""Decode Downlink Format vaule, bits 1 to 5."""
"""Decode Downlink Format value, bits 1 to 5."""
dfbin = hex2bin(msg[:2])
return min(bin2int(dfbin[0:5]), 24)
@@ -63,8 +63,10 @@ def crc(msg, encode=False):
# the CRC generator
G = [int("11111111", 2), int("11111010", 2), int("00000100", 2), int("10000000", 2)]
if encode:
if encode and isinstance(msg, str):
msg = msg[:-6] + "000000"
elif encode:
msg = msg[:-6] + b"000000"
msgbin = hex2bin(msg)
msgbin_split = wrap(msgbin, 8)

24
pyModeS/decoder/uplink.py Normal file
View File

@@ -0,0 +1,24 @@
from pyModeS.decoder import common
def uplink_icao(msg):
"""Calculate the ICAO address from a Mode-S interrogation (uplink message)"""
p_gen = 0xfffa0480 << ((len(msg)-14)*4)
data = int(msg[:-6],16)
PA = int(msg[-6:],16)
ad = 0
topbit = 0b1 << (len(msg)*4-25)
for j in range(0,len(msg)*4,1):
if (data & topbit):
data^=p_gen
data = (data << 1) + ((PA >> 23) & 1)
PA = PA << 1
if (j>(len(msg)*4-26)):
ad = ad + ((data >> (len(msg)*4-25)) & 1)
ad = ad << 1
return "%06X" % (ad >> 2)
def uf(msg):
"""Decode Uplink Format value, bits 1 to 5."""
ufbin = common.hex2bin(msg[:2])
return min(common.bin2int(ufbin[0:5]), 24)

View File

@@ -9,9 +9,9 @@ International Standard Atmosphere
p,rho,T = atmos(H) # atmos as function of geopotential altitude H [m]
a = vsound(H) # speed of sound [m/s] as function of H[m]
p = pressure(H) # calls atmos but retruns only pressure [Pa]
p = pressure(H) # calls atmos but returns only pressure [Pa]
T = temperature(H) # calculates temperature [K]
rho = density(H) # calls atmos but retruns only pressure [Pa]
rho = density(H) # calls atmos but returns only pressure [Pa]
Speed conversion at altitude H[m] in ISA
::

View File

@@ -170,7 +170,7 @@ class TcpClient(object):
Start character '$'
MS field - Payload
Postion 1 through 14:
Position 1 through 14:
14 bytes = 112 bits
Mode-S payload
In case of DF types that only carry 7 bytes of information

View File

@@ -27,7 +27,7 @@ class Decode:
self.dumpto = None
def process_raw(self, adsb_ts, adsb_msg, commb_ts, commb_msg, tnow=None):
"""process a chunk of adsb and commb messages recieved in the same
"""process a chunk of adsb and commb messages received in the same
time period.
"""
if tnow is None:
@@ -259,7 +259,7 @@ class Decode:
return
def get_aircraft(self):
"""all aircraft that are stored in memeory"""
"""all aircraft that are stored in memory"""
acs = self.acs
return acs

View File

@@ -71,7 +71,7 @@ elif SOURCE == "net":
else:
SERVER, PORT, DATATYPE = args.connect
if DATATYPE not in support_rawtypes:
print("Data type not supported, avaiable ones are %s" % support_rawtypes)
print("Data type not supported, available ones are %s" % support_rawtypes)
else:
print('Source must be "rtlsdr" or "net".')

View File

@@ -4,7 +4,7 @@ See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
Steps for deploying a new verison:
Steps for deploying a new version:
1. Increase the version number
2. remove the old deployment under [dist] and [build] folder
3. run: python setup.py sdist