WOrk on >50175 feet altitudes and generating all altitudes

This commit is contained in:
nzkarit 2018-05-06 21:21:19 +12:00
parent c9cae9130a
commit ac80823285
6 changed files with 93 additions and 4 deletions

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ allICAO.py
hackRFAllICAO.sh hackRFAllICAO.sh
allLat.py allLat.py
hackRFAllLat.sh hackRFAllLat.sh
allAlt.py
hackRFAllAlt.sh

View File

@ -56,7 +56,7 @@ def argParser():
parser.add_argument('--tc', '--typecode', action='store', type=int, dest='typecode', default=cfg.getint('plane', 'typecode'), help='The type for the ADS-B message. 11 is an air position message. See https://adsb-decode-guide.readthedocs.io/en/latest/content/introduction.html#ads-b-message-types for more information. 5 bits. Default: %(default)s') parser.add_argument('--tc', '--typecode', action='store', type=int, dest='typecode', default=cfg.getint('plane', 'typecode'), help='The type for the ADS-B message. 11 is an air position message. See https://adsb-decode-guide.readthedocs.io/en/latest/content/introduction.html#ads-b-message-types for more information. 5 bits. Default: %(default)s')
parser.add_argument('--ss', '--surveillancestatus', action='store', type=int, dest='surveillancestatus', default=cfg.getint('plane', 'surveillancestatus'), help='The surveillance status. (Think this is always 0 from ADS-B messages. More info would be appreciated). Default: %(default)s') parser.add_argument('--ss', '--surveillancestatus', action='store', type=int, dest='surveillancestatus', default=cfg.getint('plane', 'surveillancestatus'), help='The surveillance status. (Think this is always 0 from ADS-B messages. More info would be appreciated). Default: %(default)s')
parser.add_argument('--nicsb', '--nicsupplementb', action='store', type=int, dest='nicsupplementb', default=cfg.getint('plane', 'nicsupplementb'), help='The NIC supplement-B.(Think this is always 0 from ADS-B messages. More info would be appreciated). Default: %(default)s') parser.add_argument('--nicsb', '--nicsupplementb', action='store', type=int, dest='nicsupplementb', default=cfg.getint('plane', 'nicsupplementb'), help='The NIC supplement-B.(Think this is always 0 from ADS-B messages. More info would be appreciated). Default: %(default)s')
parser.add_argument('--time', action='store', type=int, dest='time', default=cfg.getint('plane', 'time'), help='The time. (Think this is always 0 from ADS-B messages. More info would be appreciated). Default: %(default)s') parser.add_argument('--time', action='store', type=int, dest='time', default=cfg.getint('plane', 'time'), help='0 indicates the time is not synchronous with UTC. Default: %(default)s')
parser.add_argument('-s', '--surface', action='store', default=cfg.getboolean('plane', 'surface'), type=auto_bool, dest='surface', help='If the plane is on the ground or not. Default: %(default)s') parser.add_argument('-s', '--surface', action='store', default=cfg.getboolean('plane', 'surface'), type=auto_bool, dest='surface', help='If the plane is on the ground or not. Default: %(default)s')
parser.add_argument('-o', '--out', '--output', action='store', type=str, default=cfg.get('general', 'outputfilename'), dest='outputfilename', help='The iq8s output filename. This is the file which you will feed into the hackRF. Default: %(default)s') parser.add_argument('-o', '--out', '--output', action='store', type=str, default=cfg.get('general', 'outputfilename'), dest='outputfilename', help='The iq8s output filename. This is the file which you will feed into the hackRF. Default: %(default)s')
parser.add_argument('-r', '--repeats', action='store', dest='repeats', type=int, default=cfg.getint('general', 'repeats'), help='How many repeats of the data to perform. Default: %(default)s') parser.add_argument('-r', '--repeats', action='store', dest='repeats', type=int, default=cfg.getint('general', 'repeats'), help='How many repeats of the data to perform. Default: %(default)s')

View File

@ -30,7 +30,16 @@ class ModeSLocation:
# Further work on fork # Further work on fork
# Copyright (C) 2017 David Robinson # Copyright (C) 2017 David Robinson
def encode_alt_modes(self, alt, bit13): def encode_alt_modes(self, alt, bit13):
# need to better understand as the >50175 feet not working
# TODO >50175 feet
mbit = False mbit = False
qbit = True
# For altitudes -1000<=X<=50175 feet, set bit 8 AKA the Q bit to true which means 25 feet resoulution
# For >50175 set the qbit to False and use 100 feet resoultion
if alt > 50175:
qbit = False
encalt = int((int(alt) + 1000) / 100)
else:
qbit = True qbit = True
encalt = int((int(alt) + 1000) / 25) encalt = int((int(alt) + 1000) / 25)

79
generateAllAlt.py Executable file
View File

@ -0,0 +1,79 @@
#!/usr/bin/env python3
#
# Will generate a CSV with all Latitudes
import csv
import os
def writeFile(directory, filename, filenameExtension, data, count):
csvFilename = os.path.join(directory, "%s-%s.%s"%(filename, count, filenameExtension))
with open(csvFilename, 'w', newline='') as csvfile:
output = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
output.writerow(['altitude'])
for row in data:
output.writerow([row])
csvfile.close()
return "{'csv':'%s', 'out':'%s-%s.iq8s'},"%(csvFilename, filename, count)
def main():
directory = 'generated'
filename = 'allAlt'
filenameExtension = 'csv'
scriptFilename = 'allAlt.py'
hackRFScriptFilename = 'hackRFAllAlt.sh'
minAlt = -1100
maxAlt = 100000
splitNumber = 1000
step = 1
try:
os.stat(directory)
except:
os.mkdir(directory)
script = open(scriptFilename, 'w')
script.write('#!/usr/bin/env python3\n')
script.write('import time\n')
script.write('import threading\n')
script.write('from ADSB_Encoder import *\n')
hackRFScript = open(hackRFScriptFilename, 'w')
hackRFScript.write('#!/bin/bash\n')
i = minAlt
j = 0
k = 0
data = []
files = ''
while i <= maxAlt:
if j == splitNumber:
files += writeFile(directory, filename, filenameExtension, data, k)
data = []
hackRFScript.write("hackrf_transfer -t %s-%s.iq8s -f 915000000 -s 2000000 -x 10\n" % (filename, k))
k += 1
j = 0
data.append(i)
i += step
j += 1
files += writeFile(directory, filename, filenameExtension, data, k)
data = []
hackRFScript.write("hackrf_transfer -t %s-%s.iq8s -f 915000000 -s 2000000 -x 10\n" % (filename, k))
k += 1
j = 0
files = files[:-1]
script.write('files = [%s]\n' % (files))
script.write('for file in files:\n')
script.write(' t = threading.Thread(target=threadingCSV, args=(file,))\n')
script.write(' t.start()\n')
script.write(' print(file)\n')
script.write(' time.sleep(1)\n')
script.close()
hackRFScript.close()
if __name__ == "__main__":
main()

View File

@ -23,7 +23,6 @@ def main():
minLat = -90 minLat = -90
maxLat = 90 maxLat = 90
# If the number of lat is less than the split it doesn't work
splitNumber = 1000 splitNumber = 1000
step = 0.1 step = 0.1