forked from lyusupov/ADSB-Out
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerateAllAlt.py
executable file
·79 lines (66 loc) · 2.24 KB
/
generateAllAlt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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()