Comments on what things are doing and also doing the DD step in the script

This commit is contained in:
nzkarit 2017-09-07 18:59:24 +12:00
parent 4f3f124790
commit 475bc5da83
3 changed files with 15 additions and 7 deletions

View File

@ -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

View File

@ -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 = []

View File

@ -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