diff --git a/ADSB_Encoder.py b/ADSB_Encoder.py index 3c6bb3e..597499e 100755 --- a/ADSB_Encoder.py +++ b/ADSB_Encoder.py @@ -6,6 +6,7 @@ from location import * from conversions import * from parity import * from HackRF import HackRF +import os ############################################################### @@ -29,7 +30,7 @@ import numpy def df17_pos_rep_encode(ca, icao, tc, ss, nicsb, alt, time, lat, lon, surface): - format = 17 + format = 17 #The format type of an ADSB message enc_alt = encode_alt_modes(alt, surface) #print "Alt(%r): %X " % (surface, enc_alt) @@ -141,10 +142,10 @@ if __name__ == "__main__": lon = float(argv[3]) alt = float(argv[4]) - ca = 5 - tc = 11 - ss = 0 - nicsb = 0 + ca = 5 # Capability + tc = 11 # Type Code see: https://adsb-decode-guide.readthedocs.io/en/latest/content/introduction.html#ads-b-message-types + ss = 0 # Surveillance status + nicsb = 0 # NIC supplement-B time = 0 surface = False @@ -161,5 +162,6 @@ if __name__ == "__main__": hackrf = HackRF() samples_array = hackrf.hackrf_raw_IQ_format(df17_array) - SamplesFile = open("Samples.iq8s", "wb") + SamplesFile = open("Samples.iq8s", "wb") # TODO make this a function and take the file name. Also have the option to run dd on it. SamplesFile.write(samples_array) + os.system("dd if=Samples.iq8s of=Samples_256K.iq8s bs=4k seek=63") # TODO make this a flag, also make it take the file name diff --git a/HackRF.py b/HackRF.py index 70a2ebe..8e97f26 100644 --- a/HackRF.py +++ b/HackRF.py @@ -11,7 +11,7 @@ class HackRF: ppm: this is some data in ppm (pulse position modulation) which you want to convert into raw IQ format Returns: - bytearray containig the IQ data + bytearray: containing the IQ data """ signal = [] diff --git a/location.py b/location.py index b6068b7..71d7e83 100644 --- a/location.py +++ b/location.py @@ -40,6 +40,10 @@ def encode_alt_modes(alt, bit13): latz = 15 def nz(ctype): + """ + Number of geographic latitude zones between equator and a pole. It is set to NZ = 15 for Mode-S CPR encoding + https://adsb-decode-guide.readthedocs.io/en/latest/content/cpr.html + """ return 4 * latz - ctype def dlat(ctype, surface): @@ -68,6 +72,8 @@ def dlon(declat_in, ctype, surface): return tmp / nlcalc #encode CPR position +# https://adsb-decode-guide.readthedocs.io/en/latest/content/cpr.html +# compact position reporting def cpr_encode(lat, lon, ctype, surface): if surface is True: scalar = 2.**19